
function openForgotPassword(){
	jQuery.get('/prg/index?do=customerform&type=forgotpwd&'+new Date().getTime(), function(data) { jQuery.facebox(data); })
}

function openRegistration(){
	jQuery.get('/prg/index?do=customerform&type=register&'+new Date().getTime(), function(data) { jQuery.facebox(data); })
}

function attachNextUrl(obj){
	var sNextUrl = "&nexturl=" + encodeURIComponent(location.href);
	if (obj.href.indexOf("?")!=-1)
		obj.href += sNextUrl;
	else
		obj.href += "?" + sNextUrl;
}

function switchOption(value){
	var sUrl = location.href;
	var nIndex = sUrl.indexOf("&option=");
	if (nIndex!=-1)
		sUrl = sUrl.substring(0,nIndex)+"&option="+value+"&"+new Date().getTime();
	else
		sUrl += "&option="+value+"&"+new Date().getTime();
	location.href = (sUrl);
}

function removeNextUrl(obj){
	var sNextUrl = "&nexturl=" + encodeURIComponent(location.href);
	if (obj.href.indexOf(sNextUrl)!=-1)
		obj.href = obj.href.replace(sNextUrl,"");
}

function updateCallBackNo(obj){
	var sCallBackNo = "&callbackno=" + encodeURIComponent(obj.value);
	if (null!=document.getElementById("link_callerid"))
	{
		var sUrl = document.getElementById("link_callerid").href;
		var nIndex = sUrl.indexOf("&callbackno=");
		if (sUrl.indexOf("&callbackno=")!=-1)
			sUrl = sUrl.substring(0,nIndex) +sCallBackNo+"&"+new Date().getTime();
		else
			sUrl += sCallBackNo+"&"+new Date().getTime();
		document.getElementById("link_callerid").href = sUrl;
	}
}

function validateSearchOrder(form){
	if (form.area.value.length>0 || form.phone1.value.length>0 || form.phone2.value.length>0){
		if (!form.area.value){alert("Please enter area code."); form.area.focus(); return false;}
		else if (!form.phone1.value){alert("Please enter phone number."); form.phone1.focus(); return false;}
		else if (!form.phone2.value){alert("Please enter phone number."); form.phone2.focus(); return false;}
	}else if (!form.query.value){alert("Please enter name or phone number."); form.query.focus(); return false;}

	form.submit.value="Processing...";
	form.submit.disabled=true;
	form.phone.value = form.area.value + form.phone1.value + form.phone2.value;	
    
	return true;	
}

function validateOrderInfo(form){
	form.submit.value="Processing...";
	form.submit.disabled=true; 
	var sNexturl = location.href;
	if (sNexturl.indexOf("&popurl")!=-1){
		sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
	}
	form.nexturl.value=sNexturl; 	
	
	return true;	
}

function validateLinkInfo(form){
	if (!form.title.value){alert("Please enter title."); form.title.focus(); return false;}
	else if (!form.url.value){alert("Please enter URL."); form.url.focus(); return false;}
	else if (!form.level.value){alert("Please enter level value."); form.level.focus(); return false;}
	else if (!form.position.value){alert("Please enter position value."); form.position.focus(); return false;}
	else{
		var sUrl = form.url.value;
		if (sUrl.length>0 && sUrl.indexOf("http://")==-1 && sUrl.indexOf("/prg/index")==-1){
			form.url.value = "http://" + sUrl;
		}
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.nexturl.value=sNexturl; 	
		return true;	
	}
}

function validateTellFriendInfo(form){
	if (!form.your_email.value){alert("Please enter your email."); form.your_email.focus(); return false;}
	else if (!form.friend_emails.value){alert("Please enter friend email(s)."); form.friend_emails.focus(); return false;}
	else{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.nexturl.value=sNexturl; 	
		return true;	
	}	
}

function validateAddFriendInfo(form){
	form.submit.value="Processing...";
	form.submit.disabled=true; 
	var sNexturl = location.href;
	if (sNexturl.indexOf("&popurl")!=-1){
		sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
	}
	form.nexturl.value=sNexturl; 	
	return true;	
}

function validateFriendSearch(form){
	if (!form.query.value){alert("Please enter your friend name or email."); form.query.focus(); return false;}
	else
  	{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		return true;	
	}	
}

function validateCustomerSearch(form){
	if (form.area.value.length>0 || form.phone1.value.length>0 || form.phone2.value.length>0){
		if (!form.area.value){alert("Please enter area code."); form.area.focus(); return false;}
		else if (!form.phone1.value){alert("Please enter phone number."); form.phone1.focus(); return false;}
		else if (!form.phone2.value){alert("Please enter phone number."); form.phone2.focus(); return false;}
	}
	else if (!form.query.value){alert("Please enter customer name or email."); form.query.focus(); return false;}

	form.submit.value="Processing...";
	form.submit.disabled=true;
	form.phone.value = form.area.value + form.phone1.value + form.phone2.value;	
	return true;	
}

function validateSendFriendMessage(form){
  	{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.nexturl.value=sNexturl; 	
		return true;	
	}	
}


function validateShowInfo(form){
	form.submit.value="Processing...";
	form.submit.disabled=true; 
	form.nexturl.value=location.href; 		
	return true;	
}

function validateCardInfo(form){
	if (!form.cardname.value){alert("Please enter card name."); form.cardname.focus(); return false;}
	else if (!form.sku.value){alert("Please enter SKU."); form.sku.focus(); return false;}
	else if (!form.cardvalue.value){alert("Please enter card value."); form.cardvalue.focus(); return false;}
	else if (!form.cardquantity.value){alert("Please enter card quantity."); form.cardquantity.focus(); return false;}
	else if (!form.bonusvalue.value){alert("Please enter bonus value."); form.bonusvalue.focus(); return false;}
	else{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.nexturl.value=sNexturl; 	
		return true;	
	}	
}

function validateCardCodeInfo(form){
	if (!form.giftcardid.value){alert("Please select card name."); form.giftcardid.focus(); return false;}
	else if (!form.idcode.value){alert("Please enter ID Code."); form.idcode.focus(); return false;}
	else if (!form.cardvalue.value){alert("Please enter card value."); form.cardvalue.focus(); return false;}
	else{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.nexturl.value=sNexturl; 	
		return true;	
	}	
}

function validateVendorInfo(form){
	if (!form.company.value){alert("Please enter company."); form.company.focus(); return false;}
	else if (!form.email.value){alert("Please enter email."); form.email.focus(); return false;}
	else if (form.email.value=="admin@ibc.tv"){alert("This email is reserved. Please select another one"); form.email.value="";form.email.focus();return false;}
	else if (!form.password.value){alert("Please enter password."); form.password.focus(); return false;}
	else if (!form.firstname.value){alert("Please enter first name."); form.firstname.focus(); return false;}
	else if (!form.lastname.value){alert("Please enter last name."); form.lastname.focus(); return false;}
	else if (!form.expiration.value){alert("Please enter expiration."); form.expiration.focus(); return false;}
	else{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		form.workphone.value = form.area.value + form.phone1.value + form.phone2.value;
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.nexturl.value=sNexturl; 	
		return true;	
	}	
}

function validateAgentInfo(form){
	if (!form.company.value){alert("Please enter company."); form.company.focus(); return false;}
	else if (!form.email.value){alert("Please enter email."); form.email.focus(); return false;}
	else if (form.email.value=="admin@ibc.tv"){alert("This email is reserved. Please select another one"); form.email.value="";form.email.focus();return false;}
	else if (!form.password.value){alert("Please enter password."); form.password.focus(); return false;}
	else if (!form.firstname.value){alert("Please enter first name."); form.firstname.focus(); return false;}
	else if (!form.lastname.value){alert("Please enter last name."); form.lastname.focus(); return false;}
	else{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		form.workphone.value = form.area.value + form.phone1.value + form.phone2.value;
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.nexturl.value=sNexturl; 	
		return true;	
	}	
}

function validateRegisterCustomerInfo(form){
	if (!form.email.value){alert("Please enter email."); form.email.focus(); return false;}
	else if (form.email.value=="admin@ibc.tv"){alert("This email is reserved. Please select another one"); form.email.value="";form.email.focus();return false;}
	else if (!form.email2.value){alert("Please enter confirm email."); form.email2.focus(); return false;}
	else if (form.email.value!=form.email2.value){alert("Email and Confirm Email are not same. Please correct and try again."); form.email.focus(); return false;}
	else if (!form.password.value){alert("Please enter password."); form.password.focus(); return false;}
	else if (!form.password2.value){alert("Please enter confirm password."); form.password2.focus(); return false;}
	else if (form.password.value!=form.password2.value){alert("Password and Confirm Password are not same. Please correct and try again."); form.password.focus(); return false;}
	else if (!form.firstname.value){alert("Please enter first name."); form.firstname.focus(); return false;}
	else if (!form.lastname.value){alert("Please enter last name."); form.lastname.focus(); return false;}
	else if (!form.address.value){alert("Please enter address."); form.address.focus(); return false;}
	else if (!form.city.value){alert("Please enter city."); form.city.focus(); return false;}
	else if (!form.state.value){alert("Please enter state."); form.state.focus(); return false;}
	else if (!form.zipcode.value){alert("Please enter zipcode."); form.zipcode.focus(); return false;}
	else if (!form.area.value){alert("Please enter area code."); form.area.focus(); return false;}
	else if (!form.phone1.value){alert("Please enter phone."); form.phone1.focus(); return false;}
	else if (!form.phone2.value){alert("Please enter phone."); form.phone2.focus(); return false;}
	else if (!form.accept.checked){alert("You have to accept \"Term Of Service\" and \"Privacy Policy\" in order to register."); return false;}
	else{
		form.submit.value="Processing...";
		form.ship_address.value = form.address.value;
		form.ship_city.value = form.city.value;
		form.ship_state.value = form.state.value;
		form.ship_zipcode.value = form.zipcode.value;
		form.submit.disabled=true; 
		form.phone.value = form.area.value + form.phone1.value + form.phone2.value;
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.nexturl.value=sNexturl; 	
		return true;	
	}	
}

function validateUpdatedCustomerInfo(form){
	if (!form.email.value){alert("Please enter email."); form.email.focus(); return false;}
	else if (form.email.value=="admin@ibc.tv"){alert("This email is reserved. Please select another one"); form.email.value="";form.email.focus();return false;}
	else if (!form.email2.value){alert("Please enter confirm email."); form.email2.focus(); return false;}
	else if (form.email.value!=form.email2.value){alert("Email and Confirm Email are not same. Please correct and try again."); form.email.focus(); return false;}
	else if (!form.password.value){alert("Please enter password."); form.password.focus(); return false;}
	else if (!form.password2.value){alert("Please enter confirm password."); form.password2.focus(); return false;}
	else if (form.password.value!=form.password2.value){alert("Password and Confirm Password are not same. Please correct and try again."); form.password.focus(); return false;}
	else if (!form.firstname.value){alert("Please enter first name."); form.firstname.focus(); return false;}
	else if (!form.lastname.value){alert("Please enter last name."); form.lastname.focus(); return false;}
	else if (!form.address.value){alert("Please enter address."); form.address.focus(); return false;}
	else if (!form.city.value){alert("Please enter city."); form.city.focus(); return false;}
	else if (!form.state.value){alert("Please enter state."); form.state.focus(); return false;}
	else if (!form.zipcode.value){alert("Please enter zipcode."); form.zipcode.focus(); return false;}
	else if (!form.area.value){alert("Please enter area code."); form.area.focus(); return false;}
	else if (!form.phone1.value){alert("Please enter phone."); form.phone1.focus(); return false;}
	else if (!form.phone2.value){alert("Please enter phone."); form.phone2.focus(); return false;}
	else{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		form.phone.value = form.area.value + form.phone1.value + form.phone2.value;
		// Temporary removed for Sept release
		/*form.showordertofriend.value = form.check_showordertofriend.checked?"1":"0";*/
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.nexturl.value=sNexturl; 	
		return true;	
	}	
}

function validateFileStorageFolderInfo(form){
	if (!form.folder.value){alert("Please enter folder name."); form.folder.focus(); return false;}
	else{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.nexturl.value=sNexturl; 	
		return true;	
	}	
}

function validateFileStorageFileInfo(form){
	if (!form.fileupload.value){alert("Please enter file name."); form.fileupload.focus(); return false;}
	else{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.action=form.action+"&nexturl="+encodeURIComponent(sNexturl);
		return true;	
	}	
}

function validateFileStorageFileInfoUpdate(form){
	form.submit.value="Processing...";
	form.submit.disabled=true; 
	var sNexturl = location.href;
	if (sNexturl.indexOf("&popurl")!=-1){
		sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
	}
	form.nexturl.value=sNexturl; 	
	return true;	
}

function validateStaffInfo(form){
	if (!form.email.value){alert("Please enter email."); form.email.focus(); return false;}
	else if (form.email.value=="admin@ibc.tv"){alert("This email is reserved. Please select another one."); form.email.value="";form.email.focus();return false;}
	else if (!form.password.value){alert("Please enter password."); form.password.focus(); return false;}
	else if (!form.firstname.value){alert("Please enter first name."); form.firstname.focus(); return false;}
	else if (!form.lastname.value){alert("Please enter last name."); form.lastname.focus(); return false;}
	else{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		form.workphone.value = form.area.value + form.phone1.value + form.phone2.value;
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.nexturl.value=sNexturl; 	
		return true;	
	}	
}

function validatePostFeedback(form) {
	if (!form.email.value){alert("Please enter email."); form.email.focus(); return false;}
	else if (!form.firstname.value){alert("Please enter first name."); form.firstname.focus(); return false;}
	else if (!form.lastname.value){alert("Please enter last name."); form.lastname.focus(); return false;}
	else if (!form.phonenumber.value){alert("Please enter phone number."); form.phonenumber.focus(); return false;}
	else if (!form.title.value){alert("Please enter subject."); form.title.focus(); return false;}
	else if (!form.msgtext.value){alert("Please enter message."); form.msgtext.focus(); return false;}
	else{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.action=form.action+"&nexturl="+encodeURIComponent(sNexturl);
		
		return true;	
	}
}

function validatePostMessage(form) {
	if (!form.title.value){alert("Please enter subject."); form.title.focus(); return false;}
	else if (!form.msgtext.value){alert("Please enter message."); form.msgtext.focus(); return false;}
	else{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.action=form.action+"&nexturl="+encodeURIComponent(sNexturl);
		
		return true;	
	}
}

function validatePostFastTrack(form) {
	if (!form.subject.value){alert("Please enter subject."); form.subject.focus(); return false;}
	else if (!form.content.value){alert("Please enter content."); form.content.focus(); return false;}
	else if (!form.receiverid.value){alert("Please select assignee."); form.receiverid.focus(); return false;}
	else if (!form.priority.value){alert("Please select priority."); form.priority.focus(); return false;}
	else{
		form.submit.value="Processing...";
		form.submit.disabled=true; 
		var sNexturl = location.href;
		if (sNexturl.indexOf("&popurl")!=-1){
			sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
		}
		form.action=form.action+"&nexturl="+encodeURIComponent(sNexturl);
		
		return true;	
	}
}

function validateUpdateFastTrack(form) {
	form.submit.value="Processing...";
	form.submit.disabled=true; 
	var sNexturl = location.href;
	if (sNexturl.indexOf("&popurl")!=-1){
		sNexturl = sNexturl.substring(0,sNexturl.indexOf("&popurl"));	
	}
	form.action=form.action+"&nexturl="+encodeURIComponent(sNexturl);
	
	return true;	
}

function validateShippingInfo(form){
	if (!document.getElementById("sh_firstname").value){alert("Please enter first name."); document.getElementById("sh_firstname").focus(); return false;}
	else if (!document.getElementById("sh_lastname").value){alert("Please enter last name."); document.getElementById("sh_lastname").focus(); return false;}
	else if (!document.getElementById("sh_street").value){alert("Please enter house number & street."); document.getElementById("sh_street").focus(); return false;}
	else if (!document.getElementById("sh_city").value){alert("Please enter city."); document.getElementById("sh_city").focus(); return false;}
	else if (!document.getElementById("sh_state").value){alert("Please enter state."); document.getElementById("sh_state").focus(); return false;}
	else if (!document.getElementById("sh_zip").value){alert("Please enter zip."); document.getElementById("sh_zip").focus(); return false;}
	else{
		return true;
	}
}

function updateQuantity(sValue){
	try{
		if (null!=document.forms['paypal'])
			document.forms['paypal'].quantity.value = sValue;

		var sAmount = document.getElementById("CardValue").value.replace("USD ","");
		if (null!=document.forms['amazon']){
			document.forms['amazon'].amount.value = "USD " + parseInt(sValue)*parseFloat(sAmount);
			var ipnUrl = document.forms['amazon'].ipnUrl.value;
			var returnUrl = document.forms['amazon'].returnUrl.value;
			ipnUrl = ipnUrl.substring(0,ipnUrl.indexOf("quantity:")+9);
			returnUrl = returnUrl.substring(0,returnUrl.indexOf("quantity:")+9);
			document.forms['amazon'].ipnUrl.value = ipnUrl + sValue;
			document.forms['amazon'].returnUrl.value = returnUrl + sValue;
		}
	}catch(ex){}	
}

function updateSaleSummary(type){
	var sId = getQueryVariable("id");
	var sRange = trim(document.getElementById("rangeA").value);
	var sFr = "";
	var sTo = "";
	if (sRange.indexOf("to")!=-1){
		var sArr = sRange.split("to");	
		sFr = trim(sArr[0]);
		sTo = trim(sArr[1]);
	}else{
		sFr = sRange;	
		sTo = sRange;
	}

	var sSort = document.getElementById("sortname").value;
	var sSale = document.getElementById("saletype")!=null?document.getElementById("saletype").value:"";
	var sVendorId = (document.getElementById("vendorid")!=null&&document.getElementById("vendorid").value!="")?"&vendorid=-"+document.getElementById("vendorid").value:"";
	if (sId.length>0){
		var sUrl = "/prg/index?client=staff&do="+type+"view&type=info&id="+sId+"&fr="+sFr+"&to="+sTo+"&sortname="+sSort+"&saletype="+sSale+"&"+new Date().getTime();
		location.href = sUrl;
	}else{
		var sUrl = "/prg/index?client=staff&do="+type+"list&fr="+sFr+"&to="+sTo+"&sortname="+sSort+"&saletype="+sSale+sVendorId+"&"+new Date().getTime();
		location.href = sUrl;
	}
}

function updateShowList(){
	var type = getQueryVariable("type");
	var sRange = trim(document.getElementById("rangeA").value);
	var sFr = "";
	var sTo = "";
	if (sRange.indexOf("to")!=-1){
		var sArr = sRange.split("to");	
		sFr = trim(sArr[0]);
		sTo = trim(sArr[1]);
	}else{
		sFr = sRange;	
		sTo = sRange;
	}
	var sSort = document.getElementById("sortname").value;
    var sMax = document.getElementById("max").value;    
	var sVendorId = (document.getElementById("vendorid")!=null&&document.getElementById("vendorid").value!="")?"&vendorid="+document.getElementById("vendorid").value:"";
	var sUrl = "/prg/index?client=staff&do=showlist&type="+type+"&fr="+sFr+"&to="+sTo+"&sortname="+sSort+"&saletype="+sVendorId+"&max="+sMax+"&"+new Date().getTime();
	location.href = sUrl;
}

function updateGlobalSetting(){
	var type = getQueryVariable("type");
	var sFieldname = document.getElementById("fieldname").value;
	var sFieldvalue = document.getElementById("fieldvalue").value;
	var sUrl = "/prg/index?client=staff&do=showlist&type="+type+"&opt=globalsetting&fieldname="+sFieldname+"&fieldvalue="+sFieldvalue+"&"+new Date().getTime();
	location.href = sUrl;
}


function updateOrderList(){
	var type = getQueryVariable("type");
	var sRange = trim(document.getElementById("rangeA").value);
	var sFr = "";
	var sTo = "";
	if (sRange.indexOf("to")!=-1){
		var sArr = sRange.split("to");	
		sFr = trim(sArr[0]);
		sTo = trim(sArr[1]);
	}else{
		sFr = sRange;	
		sTo = sRange;
	}
	var sSort = document.getElementById("sortname").value;
	var sMax = document.getElementById("max").value;
	var sVendorId = (document.getElementById("vendorid")!=null&&document.getElementById("vendorid").value!="")?"&vendorid="+document.getElementById("vendorid").value:"";
	var sUrl = "/prg/index?client=staff&do=orderlist&type="+type+"&fr="+sFr+"&to="+sTo+"&sortname="+sSort+"&saletype="+sVendorId+"&max="+sMax+"&"+new Date().getTime();
	location.href = sUrl;
}

function updateCustomerList(){
	var type = getQueryVariable("type");
	var client = getQueryVariable("client"); 
    var sRange = trim(document.getElementById("rangeA").value);
    var sFr = "";
    var sTo = "";
    if (sRange.indexOf("to")!=-1){
        var sArr = sRange.split("to");
        sFr = trim(sArr[0]);
        sTo = trim(sArr[1]);
    }else{
        sFr = sRange;
        sTo = sRange;
    }
	var sSort = document.getElementById("sortname").value;
	var sMax = document.getElementById("max").value; 
	var sUrl = "/prg/index?client="+client+"&do=customerlist&type="+type+"&fr="+sFr+"&to="+sTo+"&sortname="+sSort+"&max="+sMax+"&"+new Date().getTime();
	location.href = sUrl;
}

function updateChaserList(){
	var type = getQueryVariable("type");
	var client = getQueryVariable("client"); 	
	var sPrefix = document.getElementById("prefix").value;
	var sMax = document.getElementById("max").value;
	var sUrl = "/prg/index?client="+client+"&do=customerlist&type="+type+"&prefix="+sPrefix+"&max="+sMax+"&"+new Date().getTime();
	location.href = sUrl;
}

function updateCodeList(){
	var type = getQueryVariable("type");
	var sRange = trim(document.getElementById("rangeA").value);
	var sFr = "";
	var sTo = "";
	if (sRange.indexOf("to")!=-1){
		var sArr = sRange.split("to");	
		sFr = trim(sArr[0]);
		sTo = trim(sArr[1]);
	}else{
		sFr = sRange;	
		sTo = sRange;
	}
	var sSort = document.getElementById("sortname").value;
	var sMax = document.getElementById("max").value;
	var sCardId = (document.getElementById("cardid")!=null&&document.getElementById("cardid").value!="")?"&cardid="+document.getElementById("cardid").value:"";
	var sUrl = "/prg/index?client=staff&do=cardcodelist&type="+type+"&fr="+sFr+"&to="+sTo+"&sortname="+sSort+"&saletype="+sCardId+"&max="+sMax+"&"+new Date().getTime();
	location.href = sUrl;
}

function updateInstantCashback(obj){
	var sValue = obj.value;
	var client = getQueryVariable("client");
	var url = "/prg/index?client="+getQueryVariable("client")+"&do=shoppingcart&type=list&query="+getQueryVariable("query")+"&"+new Date().getTime();
	if ("0"==sValue){
		location.href = url + "&icb=0";
	}else{
		location.href = url + "&icb=0";
	}
}

function updateQuery(form){
    var sClient = getQueryVariable("client");
    if (sClient.length==0){sClient = "customer";}
    var sCallerId = form.area.value + form.phone1.value + form.phone2.value;
    var bIsLogin = getFileContent("/prg/index?do=ajax&ty=islogin&callerid="+sCallerId+"&"+new Date().getTime());

    if (bIsLogin=="true")
    {
        form.action = "/prg/index?client="+sClient+"&opt=go";
        form.query.value = sCallerId;
        setCookie('ibc.callerid', sCallerId);
        return true;
    }
    else
    {
        var sPopUrl = "/prg/index?client="+sClient+"&do=login&type=form_customer&"+new Date().getTime();
        $.get(sPopUrl, function(data) { $.facebox(data) });
        return false;
    }
}

function updateCallerId(){
	var sCallerId = getCookie('ibc.callerid'); //alert(sCallerId);
	var form = document.forms['form_winner'];
	if (null!=form){
		if (null!=sCallerId && sCallerId.length>0){
			form.area.value = sCallerId.substring(0,3);
			form.phone1.value = sCallerId.substring(3,6);
			form.phone2.value = sCallerId.substring(6,10);
		}else{
			form.area.value = "";
			form.phone1.value = "";
			form.phone2.value = "";
		}
	}
}

function initLogin(form){
	try{
		var cookieName = "";
		if (form.name == "form_login_customer"  || form.name == "form_checkout_login" ){
			cookieName = "ibc.customer";
		}else if (form.name == "form_login"){
			cookieName = "ibc.staff";
		}
		if (null!=document.getElementById("radioNewCustomer"))
			document.getElementById("radioNewCustomer").click();
		
		var username = getCookie(cookieName);
		if (username){
			if (null!=form.email){
				form.email.value = username;
				if (form.name == "form_checkout_login"){
					if (username.length>0)
						document.getElementById("radioCurrentCustomer").click();	
					else
						document.getElementById("radioNewCustomer").click();
				}
			}
			if (null!=form.remember)
				form.remember.checked = true;
		}
	}catch (ex) {}
}

function createDynamicLink(){
	var sContent = getFileContent("/prg/index?do=ajax&ty=dynlink&"+new Date().getTime());
	document.write(sContent);
}

////////////////////////////////////////////////////////

function formatTime(timeInSeconds){
	var seconds = Math.floor(timeInSeconds)%60;
	var minutes = Math.floor(timeInSeconds / 60.0);
	var hours = Math.floor(minutes / 60.0);
	minutes = minutes%60;
	var sTime;
	if (hours<10)
		sTime = "0"+hours + ":";
	else
		sTime = ""+hours + ":";
		
	if (minutes<10)
		sTime += '0' + minutes + ":";
	else
		sTime += minutes + ":";
		
	if (seconds<10)
		sTime += '0' + seconds;
	else
		sTime += seconds;
	return sTime;
}

function checkFieldEmpty(objField){
	var sValue = trim(objField.value);
	return sValue.length==0;
}

function isEmail(email)
{
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
	var returnval=emailfilter.test(email)
	if (returnval==false)
    {
		alert("Please enter a valid email address.")
	}
	return returnval;
}

function setFocus(objInput){
	objInput.focus();
	objInput.select();
}

function trim(str)
{
	var nStart = 0;
	var nEnd = str.length;//-1;
	if (nEnd<0)
		return str;
	
	for (var i=0; i<=nEnd; i++)
	{
		if (str.charCodeAt(i)!=32)
			break;
		nStart = i+1;
	}
	
	if (nStart>=nEnd)
		return "";
	
	for (var i=nEnd; i>=0; i--)
	{
		if (str.charCodeAt(i)!=32)
			break;
		nEnd = i-1;
	}
	nEnd++;
	str = str.substring(nStart, nEnd);
	return str;
}

function createTableOpen(){
	document.write("<table CELLSPACING='0' CELLPADDING='0' BORDER='0' align='center'><tr><td COLSPAN='2' HEIGHT='7' ROWSPAN='2'><img height='7' src='/images/corner1.gif' width='7'></td><td STYLE='border-top: 1px solid #BBBBBB;'><img height='1' src='/images/clearpixel.gif' width='1' BORDER='0'></td><td COLSPAN='2' HEIGHT='7' ROWSPAN='2'><img height='7' src='/images/corner2.gif' width='7'></td></tr><tr VALIGN='top'><td><img height='5' src='/images/clearpixel.gif' width='1' BORDER='0'></td></tr><tr VALIGN='top'><td WIDTH='1' STYLE='border-left: 1px solid #BBBBBB;'><img height='1' src='/images/clearpixel.gif' width='1' BORDER='0'></td><td WIDTH='5'><img height='1' src='/images/clearpixel.gif' width='5' BORDER='0'></td><td BGCOLOR='#FFFFFF' VALIGN='top'>");
}
function createTableClose(){
	document.write("</td><td WIDTH='5'><img height='1' src='/images/clearpixel.gif' width='5' BORDER='0'></td><td WIDTH='1' STYLE='border-right: 1px solid #BBBBBB;'><img height='1' src='/images/clearpixel.gif' width='1' BORDER='0'></td></tr><tr VALIGN='bottom'><td COLSPAN='2' HEIGHT='7' ROWSPAN='2'><img height='7' src='/images/corner3.gif' width='7'></td><td STYLE='border-bottom: 1px solid #BBBBBB;'><img height='1' src='/images/clearpixel.gif' width='1' BORDER='0'></td><td COLSPAN='2' HEIGHT='7' ROWSPAN='2'><img height='7' src='/images/corner4.gif' width='7'></td></tr></table>");
}

function createLeftButton(){
	document.write("<table BORDER='0' CELLSPACING='0' CELLPADDING='0' HEIGHT='22'><tr><td WIDTH='10' HEIGHT='22'ALIGN='left' VALIGN='middle'><img src='/staticfile/images/btt_left.gif' width='10' height='22'></td><td BGCOLOR='#0C2E82' HEIGHT='22'>");
}
function createRightButton(){
	document.write("</td><td WIDTH='10' ALIGN='left' VALIGN='middle'><img src='/staticfile/images/btt_right.gif' width='10' height='22'></td></tr></table>");
}

function showHide(method,section){
	if (eval("document.all."+section)!=null){if (method == "open" ){eval( section + ".style.display = 'inline'" );}else if (method == "close"){eval( section + ".style.display = 'none'" );}}
}

function toggleShow(name){
  if (eval("document.getElementById('"+name+"').style.display")=="none")
     showHide("open", name);
  else
     showHide("close",name);
}

function dump_props(obj, obj_name) {
   var result = "";
   for (var i in obj) {
      result += obj_name + "." + i + " = " + obj[i] + "<br>";
   }
   result += "<HR>";
   return result;
}

function checkDateFormat(strValue,strFormat)
{
  var msg = getAlertMsg(3)+strFormat;
  if (strValue.length != strFormat.length)
  {
    alert(msg);
    return false;
  }
  else
  {
    if (strFormat == "MM/DD/YYYY")
    {
      if (strValue.substr(2,1)!="/"||strValue.substr(5,1)!="/"||strValue.substr(0,2)>'12'||strValue.substr(3,2)>'31'||strValue.substr(6,4)>'3000'){
        alert(msg);return false;}
    }
    else if (strFormat == "MM/YYYY")
    {
      if (strValue.substr(2,1)!="/"||strValue.substr(0,2)>'12'||strValue.substr(3,4)>'3000')
      {
        alert(msg);
        return false;
      }
    }
  }
  return true;
}

function autoFormat(obj,type)
{
    var len = obj.value.length;
    var val = obj.value.charAt(len-1);
    var preVal = obj.value.charAt(len-2);
    var maxLen = obj.getAttribute("maxlength");

    if(type=="N"||type=="n") {
      if(!('0' <= val && val <= '9')) obj.value = obj.value.substr(0,len-1);
      if(len > maxLen) obj.value = obj.value.substr(0,len+1);
    }
    else if(type == "D") {
      if('0' <= val && val <= '9'){
        if(len == '1' && val > '1') obj.value = "0" + obj.value + "/";
        else if((len == '5' && preVal == '0' && val != '0') || (len == '2' && val < '3' && preVal != '0') || (len == '2' && preVal == '0' && val != '0') || (len == '5' && preVal < '3' && preVal > '0') || (len == '5' && val < '2' && preVal == '3')) obj.value = obj.value + "/";
        else if((len == '2' && val >= '3' && preVal == '1') || (len == '2' && preVal == '0') || (len == '5' && preVal == '0') || (len == '5' && val > '1' && preVal >= '3')) obj.value = obj.value.substr(0,len-1);
        else if(len == '4' && val > '3') obj.value = obj.value.substr(0,len-1) + "0" + val + "/";
      }
      else if( val == '/') {
        if(len == '2' && preVal == '1') obj.value = "0" + preVal + "/";
        else if(len == '1' && preVal == "") obj.value = "";
        else if((len == '2' && preVal == '0') || len == '4' || (len == '5' && preVal <= '3') || (len == '5' && preVal == '0') || (len < '11' && len >= '7')) obj.value = obj.value.substr(0,len-1);
      }
      else obj.value = obj.value.substr(0,len-1);
    }
    else if(type == 'd') {
      if('0' <= val && val <= '9'){
        if(len == '1' && val > '1') obj.value = "0" + obj.value + "/";
        else if((len == '2' && val < '3' && preVal != '0') || (len == '2' && preVal == '0' && val != '0')) obj.value = obj.value + "/";
        else if((len == '2' && preVal == '0') || (len == '2' && val >= '3' && preVal == '1')) obj.value = obj.value.substr(0,len-1);
      }
      else if( val == '/') {
        if(len == '2' && preVal == '1') obj.value = "0" + preVal + "/";
        else if(len == '1' && preVal == "") obj.value = "";
        else if((len == '2' && preVal == '0') || len == '4' || (len == '5' && preVal <= '3') || (len == '5' && preVal == '0') || (len < '8' && len >= '4')) obj.value = obj.value.substr(0,len-1);
      }
      else obj.value = obj.value.substr(0,len-1);
    }
    else if(type=='F') {
      if(!(('0' <= val && val <= '9') || val == '.'))
        obj.value = obj.value.substr(0,len-1);
    }
    else if(type == "S") { //for String it could be anything
            if(!((val >= 'a' && val <= 'z') || (val >= 'A' && val <='Z') || ('0' <= val && val <= '9') || (val == ' ') || (val == '-')))
                    obj.value = obj.value.substr(0,len-1);
            if(len > maxLen) obj.value = obj.value.substr(0,len+1);
    }
}

var w3c=(document.getElementById)?true:false;
var ie=(document.all)?true:false;
var N=-1;
function createBar(w,h,bgc,brdW,brdC,blkC,speed,blocks,count,action)
{
    if(ie||w3c){
    var t='<DIV id="_xpbar'+(++N)+'" style="visibility:visible; position:relative; overflow:hidden; width:'+w+'px; height:'+h+'px; background-color:'+bgc+'; border-color:'+brdC+'; border-width:'+brdW+'px; border-style:solid; font-size:1px;">';
    t+='<SPAN id="blocks'+N+'" style="left:-'+(h*2+1)+'px; position:absolute; font-size:1px">';
    for(i=0;i<blocks;i++){
            t+='<SPAN style="background-color:'+blkC+'; left:-'+((h*i)+i)+'px; font-size:1px; position:absolute; width:'+h+'px; height:'+h+'px; '
            t+=(ie)?'filter:alpha(opacity='+(100-i*(100/blocks))+')':'-Moz-opacity:'+((100-i*(100/blocks))/100);
            t+='"></SPAN>';
    }
    t+='</SPAN></DIV>';
    document.write(t);
    var bA=(ie)?document.all['blocks'+N]:document.getElementById('blocks'+N);
    bA.bar=(ie)?document.all['_xpbar'+N]:document.getElementById('_xpbar'+N);
    bA.blocks=blocks; bA.N=N; bA.w=w; bA.h=h; bA.speed=speed; bA.ctr=0; bA.count=count;
    bA.action=action;
    bA.showBar=function(){this.bar.style.visibility="visible";}
    bA.hideBar=function(){this.bar.style.visibility="hidden";}
    bA.tid=setInterval('startBar('+N+')',speed);
    return bA;
    }
}

function startBar(bn)
{
  var t=(ie)?document.all['blocks'+bn]:document.getElementById('blocks'+bn);
  if(parseInt(t.style.left)+t.h+1-(t.blocks*t.h+t.blocks)>t.w){
    t.style.left=-(t.h*2+1)+'px'; t.ctr++;
    if(t.ctr>=t.count){eval(t.action);t.ctr=0;}
  }else t.style.left=(parseInt(t.style.left)+t.h+1)+'px';
}

function getFormQuery(form){
    var sRequest = "";
    for(i=0; i<form.elements.length; i++)
    {
      var e = form.elements[i];
      if (e.type=='checkbox'||e.type=='radio')
      {
        if (e.checked)
           sRequest += '&' + e.name + '=' +  encodeURIComponent(e.value);
      }
      else
        sRequest += '&' + e.name + '=' +  encodeURIComponent(e.value);
   }

   return sRequest;
}

function getFileContent(sUrl){
	try{
		var objHttp;
		if(navigator.appName == "Microsoft Internet Explorer")
			objHttp = new ActiveXObject("Microsoft.XMLHTTP");
		else
			objHttp = new XMLHttpRequest();
		objHttp.open("GET", sUrl, false);
		objHttp.send(null);
		
		var strDoc = objHttp.responseText;
		return strDoc;
	}catch(ex){return "";}
}
function sendFileContent(fileContent,sUrl){
	try{
		if( navigator.appName == "Microsoft Internet Explorer")
			objHttp = new ActiveXObject("Microsoft.XMLHTTP");
		else
			objHttp = new XMLHttpRequest();
			
		objHttp.open("Post",sUrl,false);
		objHttp.send(fileContent);
		var strDoc = objHttp.responseText;
		return strDoc;
	}catch(ex){return "";}
}

function getQueryVariable(variable) {
	try{
		var query = new String(window.location.search).replace("?","&");
		var vars = query.split("&");
		for (var i=0;i<vars.length;i++) {
			var pair = vars[i].split("=");
			if (pair[0] == variable) {
				var sVal = pair[1];
				sVal = sVal.replace(/\+/gi," ");
				//alert(query+"\n\n"+vars + "\n\n" +variable + " ::::: "+unescape(sVal)); 
				return unescape(sVal);
			}
		} 
		return "";
	}catch(ex){return "";}
}

function Set_Cookie_full(name,value,expires,path,domain,secure) {
  document.cookie = 
    name + '=' + escape(value) +
    ( (expires) ? ';expires=' + expires.toGMTString() : '') +
    ( (path) ? ';path=' + path : '') + 
    ( (domain) ? ';domain=' + domain : '') +
    ( (secure) ? ';secure' : '');
}

function Delete_Cookie_full(name,path,domain) {
  if (getCookie(name))
    document.cookie =
      name + '=' +
      ( (path) ? ';path=' + path : '') +
      ( (domain) ? ';domain=' + domain : '') +
      ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

function getCookie(name){
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(name,value){
	document.cookie = name + "=" + escape(value) + ";expires=Thu, 01-Jan-2010 00:00:01 GMT; path=/";
}

function getHeight(){if (window.innerWidth){w = window.innerWidth; h= window.innerHeight;}else if (document.all){w = document.body.clientWidth; h = document.body.clientHeight;}return h;}
function getWidth(){if (window.innerWidth){w = window.innerWidth; h= window.innerHeight;}else if (document.all){w = document.body.clientWidth; h = document.body.clientHeight;}return w;}
function showContent(target,content){try{var showContentObj = document.getElementById(target);if (null!=showContentObj){ /*&&null!=showContentObj.innerHTML*/if(showContentObj.innerHTML!=content){showContentObj.innerHTML = content;}else{showContentObj.innerHTML = "";}}}catch(ex){}}

function showStatusText(id,sContent){
	try{
		document.getElementById(id).innerHTML = sContent;
	}catch(ex){}
}

function getValue(sValue){
	if (sValue!=null) {return trim(sValue);}
	else return "";
}

function switchVideo(sUrl){
	document.getElementById("placevideo").src = sUrl;
}


////////////////////////////////////////////////////////
// Live show status in Main page
	
	var nTimeRepeatMainPage = 1000;
	var playvideo = "1";
	var playvideocheck = "0";
	var gVideoId = "u1zgFlCw8Aw";
	var gTimer = "0";
	var gShowStatus = "0";
	function repeatCheckMainPage(){ 
		var objStatus = null;
		var sResponse = getFileContent("/prg/index?do=ajax&ty=get&opt=liveshowmainpage&"+new Date().getTime());
		if (sResponse!=null&&sResponse.length>0)
		{    
			objStatus = eval('('+sResponse+')'); 
			if (null!=objStatus)
				showStatusMainPage(objStatus);
		}
		if (nTimeRepeatMainPage>0)
			setTimeout('repeatCheckMainPage()', nTimeRepeatMainPage);
	}
	
	function showStatusMainPage(objStatus){
		try{
			if (objStatus.ShowOpen == "0"){
				var sPlayerState = new String(window.frames.placevideo.gPlayerState);
				var sVideoFile = new String(window.frames.placevideo.videofile);
				if (sPlayerState == "undefined"){
					playvideocheck = "0";
					showHide("open","tbl_countdown_info");
					showStatusText("CountDown",getValue(objStatus.CountDown));
					showStatusText("showtitle","Last Show");
					showStatusText("showstatus","(Closed)");
					showStatusText("nt_showtitle","Next Show");
					showStatusText("showstatus2","(Will begin on "+getValue(objStatus.nt_ScheduleTime)+ ")");
					showInformation(objStatus,true);
					if (playvideo=="0" && playvideocheck=="0"){
						switchVideo('/video1.html?'+new Date().getTime());
						playvideo = "1";
					}
				}else if (sPlayerState == "0"){
					playvideocheck = "0";
					showHide("open","tbl_countdown_info");
					showStatusText("CountDown",getValue(objStatus.CountDown));
					showStatusText("showtitle","Last Show");
					showStatusText("showstatus","(Closed)");
					showStatusText("nt_showtitle","Next Show");
					showInformation(objStatus,true);
					if (playvideo=="0" && playvideocheck=="0"){
						switchVideo('/video1.html?'+new Date().getTime());
						playvideo = "1";
					}
				}else{
					playvideocheck = "1";
					showHide("close","tbl_countdown_info");
					showStatusText("nt_showtitle","Live Show");
					showStatusText("showstatus2","(Began on "+getValue(objStatus.BeginTime)+ ")");
					showStatusText("showtitle","Next Show");
					showStatusText("showstatus","(Will begin on "+getValue(objStatus.nt_ScheduleTime)+ ")");
					showInformation(objStatus,false);
					var videoId = getValue(objStatus.ShowVideoURL);
					if (playvideo=="1" && playvideocheck!="0" && videoId.length>0){
						switchVideo('/video2.html?&time='+objStatus.ElapseTime+"&videoid="+videoId);
						playvideo = "0";
					}
				}
			}else{	
				playvideocheck = objStatus.ShowOpen;
				showHide("close","tbl_countdown_info");
				showStatusText("nt_showtitle","Live Show");
				showStatusText("showstatus2","(Began on "+getValue(objStatus.BeginTime)+ ")");
				showStatusText("showtitle","Next Show");
				showStatusText("showstatus","(Will begin on "+getValue(objStatus.nt_ScheduleTime)+ ")");
				
				showStatusText("nt_showtitle","Live Show");
				var videoId = getValue(objStatus.ShowVideoURL);
				if (playvideo=="1" && playvideocheck!="0" && videoId.length>0){
					switchVideo('/video2.html?&time='+objStatus.ElapseTime+"&videoid="+videoId);
					playvideo = "0";
				}
				showInformation(objStatus,false);			
			}
		}catch(ex){}
	}	
	
	function showInformation(objStatus,bBottomRight){
		if (bBottomRight){
			// Displaying information
			showStatusText("ShowID",getValue(objStatus.ShowID));		
			showStatusText("ShowName",getValue(objStatus.ShowName));		
			showStatusText("ShowDescription",getValue(objStatus.ShowDescription));		
			showStatusText("GiftCardName",getValue(objStatus.GiftCardName));	
			showStatusText("GiftCardValue","$"+getValue(objStatus.GiftCardValue));
			if (getValue(objStatus.GiftCardImageURL).length>0)
				showStatusText("GiftCardImageURL","<img src='"+getValue(objStatus.GiftCardImageURL)+"' width='200' BORDER='0'>");
			if ("-1.0"==getValue(objStatus.BonusValue)){
				showStatusText("BonusValue","To be determined in the show");
			}else{
				showStatusText("BonusValue","$"+getValue(objStatus.BonusValue));
			}
			
			showStatusText("nt_ShowID",getValue(objStatus.nt_ShowId));		
			showStatusText("nt_ShowName",getValue(objStatus.nt_ShowName));		
			showStatusText("nt_ShowDescription",getValue(objStatus.nt_ShowDescription));		
			showStatusText("nt_GiftCardValue","$"+getValue(objStatus.nt_CardValue));		
			showStatusText("nt_GiftCardName",getValue(objStatus.nt_CardName));
			if (getValue(objStatus.nt_ImageURL).length>0){
				showStatusText("nt_GiftCardImageURL","<img src='"+getValue(objStatus.nt_ImageURL)+"' width='200' BORDER='0'>");			
			}else{
				showStatusText("nt_GiftCardImageURL","");				
			}
			
			if ("-1.0"==getValue(objStatus.nt_BonusValue)){
				showStatusText("nt_BonusValue","To be determined in the show");
			}else{
				showStatusText("nt_BonusValue","$"+getValue(objStatus.nt_BonusValue));
			}
		}else{
			// Displaying Information
			showStatusText("nt_ShowID",getValue(objStatus.ShowID));		
			showStatusText("nt_ShowName",getValue(objStatus.ShowName));		
			showStatusText("nt_ShowDescription",getValue(objStatus.ShowDescription));		
			showStatusText("nt_GiftCardName",getValue(objStatus.GiftCardName));	
			showStatusText("nt_GiftCardValue","$"+getValue(objStatus.GiftCardValue));
			if (getValue(objStatus.GiftCardImageURL).length>0){
				showStatusText("nt_GiftCardImageURL","<img src='"+getValue(objStatus.GiftCardImageURL)+"' width='200' BORDER='0'>");
			}else{
				showStatusText("nt_GiftCardImageURL","");				
			}

			if ("-1.0"==getValue(objStatus.BonusValue)){
				showStatusText("nt_BonusValue","To be determined in the show");
			}else{
				showStatusText("nt_BonusValue","$"+getValue(objStatus.BonusValue));
			}
			
			showStatusText("ShowID",getValue(objStatus.nt_ShowId));		
			showStatusText("ShowName",getValue(objStatus.nt_ShowName));		
			showStatusText("ShowDescription",getValue(objStatus.nt_ShowDescription));		
			showStatusText("GiftCardValue","$"+getValue(objStatus.nt_CardValue));		
			showStatusText("GiftCardName",getValue(objStatus.nt_CardName));
			if (getValue(objStatus.nt_ImageURL).length>0)
				showStatusText("GiftCardImageURL","<img src='"+getValue(objStatus.nt_ImageURL)+"' width='200' BORDER='0'>");			
			if ("-1.0"==getValue(objStatus.nt_BonusValue)){
				showStatusText("BonusValue","To be determined in the show");
			}else{
				showStatusText("BonusValue","$"+getValue(objStatus.nt_BonusValue));
			}	
		}
			
	}
	
////////////////////////////////////////////////////////
// Live show status

	function repeatCheck(){ 
		var objStatus = null;
		var sResponse = getFileContent("/prg/index?do=ajax&ty=get&opt=liveshow&"+new Date().getTime());
		if (sResponse!=null&&sResponse.length>0)
		{      
			objStatus = eval('('+sResponse+')'); 
			if (null!=objStatus)
				showStatus(objStatus);
		}
		setTimeout('repeatCheck()', 3000);
	}
	
	function showStatus(objStatus){
		try{
			if (objStatus.ElapseTime == "0")
			{
				showStatusText("showstatus","(Closed)");// - next show will be on " +objStatus.nt_ScheduleTime+ ")"); //old code: objStatus.ScheduleTime
			
				/* This is next show information
				showStatusText("ElapseTime","");
				showStatusText("BusyLines","");
				showStatusText("IdleLines","");
				showStatusText("WinnerNumber","");
				showStatusText("RemainingNumber","");
				showStatusText("TotalCallers","");
				showStatusText("BonusValue","");
				
				showStatusText("ShowID",getValue(objStatus.nt_ShowId));		
				showStatusText("ShowName",getValue(objStatus.nt_ShowName));		
				showStatusText("ShowDescription",getValue(objStatus.nt_ShowDescription));		
				showStatusText("MaxCards",getValue(objStatus.nt_MaxCardNumber));
				showStatusText("GiftCardName",getValue(objStatus.nt_CardName));	
				showStatusText("GiftCardValue","$"+getValue(objStatus.nt_CardValue));		
				showStatusText("ScheduleTime",getValue(objStatus.nt_ScheduleTime));		
				showStatusText("WelcomeMessage",getValue(objStatus.nt_WelcomeMessage));		
				showStatusText("MessageForNoCallerID",getValue(objStatus.nt_MessageForNoCallerID));		
				showStatusText("ThankYouMessage",getValue(objStatus.nt_ThankYouMessage));		
				showStatusText("InputRetries",getValue(objStatus.nt_InputRetries));		
				showStatusText("TerminationString",getValue(objStatus.nt_TerminationString));
				showStatusText("CallBackMessage",getValue(objStatus.nt_CallBackMessage));
				showStatusText("CallBackNo",getValue(objStatus.nt_CallBackNo));
				*/
				
				showStatusText("ElapseTime",formatTime(objStatus.ElapseTime));
				showStatusText("BusyLines",getValue(objStatus.BusyLines));
				showStatusText("IdleLines",getValue(objStatus.IdleLines));
				showStatusText("WinnerNumber",getValue(objStatus.TotalCallers));
				showStatusText("RemainingNumber",getValue(objStatus.RemainingNumber));
				showStatusText("TotalCallers",getValue(objStatus.TotalCallers));
				
				showStatusText("ShowID",getValue(objStatus.ShowID));		
				showStatusText("ShowName",getValue(objStatus.ShowName));		
				showStatusText("ShowDescription",getValue(objStatus.ShowDescription));		
				showStatusText("MaxCards",getValue(objStatus.MaxCards));
				showStatusText("GiftCardName",getValue(objStatus.GiftCardName));	
				showStatusText("GiftCardValue","$"+getValue(objStatus.GiftCardValue));		
				showStatusText("ScheduleTime",getValue(objStatus.ScheduleTime));		
				showStatusText("WelcomeMessage",getValue(objStatus.WelcomeMessage));		
				showStatusText("MessageForNoCallerID",getValue(objStatus.MessageForNoCallerID));		
				showStatusText("ThankYouMessage",getValue(objStatus.ThankYouMessage));		
				showStatusText("InputRetries",getValue(objStatus.InputRetries));		
				showStatusText("TerminationString",getValue(objStatus.TerminationString));
				showStatusText("BonusValue","<SPAN style='color:green'>$"+getValue(objStatus.BonusValue)+"</SPAN>");
				showStatusText("CallBackMessage",getValue(objStatus.CallBackMessage));
				showStatusText("CallBackNo",getValue(objStatus.CallBackNo));				
			}
			else
			{
				showStatusText("showstatus","(Began at "+getValue(objStatus.BeginTime)+")");
	
				showStatusText("ElapseTime",formatTime(objStatus.ElapseTime));
				showStatusText("BusyLines",getValue(objStatus.BusyLines));
				showStatusText("IdleLines",getValue(objStatus.IdleLines));
				showStatusText("WinnerNumber",getValue(objStatus.TotalCallers));
				showStatusText("RemainingNumber",getValue(objStatus.RemainingNumber));
				showStatusText("TotalCallers",getValue(objStatus.TotalCallers));
				
				showStatusText("ShowID",getValue(objStatus.ShowID));		
				showStatusText("ShowName",getValue(objStatus.ShowName));		
				showStatusText("ShowDescription",getValue(objStatus.ShowDescription));		
				showStatusText("MaxCards",getValue(objStatus.MaxCards));
				showStatusText("GiftCardName",getValue(objStatus.GiftCardName));	
				showStatusText("GiftCardValue","$"+getValue(objStatus.GiftCardValue));		
				showStatusText("ScheduleTime",getValue(objStatus.ScheduleTime));		
				showStatusText("WelcomeMessage",getValue(objStatus.WelcomeMessage));		
				showStatusText("MessageForNoCallerID",getValue(objStatus.MessageForNoCallerID));		
				showStatusText("ThankYouMessage",getValue(objStatus.ThankYouMessage));		
				showStatusText("InputRetries",getValue(objStatus.InputRetries));		
				showStatusText("TerminationString",getValue(objStatus.TerminationString));
				showStatusText("BonusValue","$"+getValue(objStatus.BonusValue));
				showStatusText("CallBackMessage",getValue(objStatus.CallBackMessage));
				showStatusText("CallBackNo",getValue(objStatus.CallBackNo));
			}
		}catch(ex){}
	}	
	
	
	
////////////////////////////////////////////////////////
// Order Call status

	var g_OrderId = "";
	function makeCall(callerid,orderid){
		var objStatus = null;
		var sResponse = getFileContent("/prg/index?do=ajax&ty=get&opt=ordercall&callerid="+callerid+"&id="+orderid+"&"+new Date().getTime());		
		if (sResponse!=null&&sResponse.length>0)
		{      
			objStatus = eval('('+sResponse+')');     
			if (null!=objStatus)
				showCallStatus(objStatus);
		}
	}
	
	function repeatCallCheck(orderid){ 
		try{
			var objStatus = null;
			var sResponse = getFileContent("/prg/index?do=ajax&ty=get&opt=orderstatus&id="+orderid+"&"+new Date().getTime());
			if (sResponse!=null&&sResponse.length>0)
			{      
				objStatus = eval('('+sResponse+')');  
				if (null!=objStatus)
					showCallStatus(objStatus);
			}
			if (null!=objStatus && objStatus.CloseFlag == "0")
			{
				setTimeout('repeatCallCheck("'+orderid+'")', 1000);
			}
		}catch(ex){}
	}
	
	function showCallStatus(objStatus){
		try{
			showStatusText("StatusMessage",getValue(objStatus.StatusMessage));
		}catch(ex){}
	}	
	
	
///////////////////////////////////////////////////////////////
// FastTrack Table 

function updateFTSort(){
	try{
		var sOpt = getQueryVariable("opt");	
		var sVal = getQueryVariable("val");
		document.getElementById(sOpt).value = sVal;
	}catch(ex){}
}

function updateFTOption(obj){
	try{
		var sOption = "&opt="+obj.name+"&val="+obj.value;
		var sUrl = location.href;
		var nIndex = sUrl.indexOf("&do=fasttracklist");
		if (nIndex!=-1)
			sUrl = sUrl.substring(0,nIndex)+"&do=fasttracklist"+sOption+"&"+new Date().getTime();
		else
			sUrl += "&do=fasttracklist"+sOption+"&"+new Date().getTime();
		location.href = (sUrl);
	}catch(ex){}
}

function buildFastTrackList(arrRow){
	//try{
		var strData = "<table id='tbl_propertylist' WIDTH='100%' BORDER='0' align='center' CELLPADDING='1' CELLSPACING='1' class='banner'>";
			strData += "<tr VALIGN='middle' class='top_nav_color'> ";
			strData += "<td class='top_nav_color_bottom_line' ALIGN='left' WIDTH='15' HEIGHT='23'>&nbsp;</td>";
			strData += "<td class='top_nav_color_bottom_line' ALIGN='left' WIDTH='345' HEIGHT='23'><FONT class='subbold'>Subject</FONT></td>";
			strData += "<td class='top_nav_color_bottom_line' ALIGN='left' WIDTH='50'><FONT class='subbold'>Priority</FONT></td>";
			strData += "<td class='top_nav_color_bottom_line' ALIGN='left' WIDTH='50'><FONT class='subbold'>Status</FONT></td>";
			strData += "<td class='top_nav_color_bottom_line' ALIGN='left' WIDTH='65'><FONT class='subbold'>Sender</FONT></td>";
			strData += "<td class='top_nav_color_bottom_line' ALIGN='left' WIDTH='65'><FONT class='subbold'>Receiver</FONT></td>";
			strData += "<td class='top_nav_color_bottom_line' ALIGN='left' WIDTH='170'><FONT class='subbold'>Date</FONT></td>";
			strData += "</tr>";
		
		for (var i=0; i<arrRow.length;i++){
			if (i%2==0)
				strData += "<TR align='left'>";
			else
				strData += "<TR class='line_format' align='left'>";
		
			//var onClickString = "return submitReport(document.forms[0]);";
			//http://dev.ibc.tv/prg/index?client=staff&do=quicklinkdelete&qlid=80&1248255180195
			var temp = new String(arrRow[i]);
			var arrCol = temp.split("|");	
			var strURLEdit = "/prg/index?client=staff&do=fasttrackview&type=edit&id="+arrCol[0]+"&"+new Date().getTime();
			var strURLDelete = "/prg/index?client=staff&do=fasttrackdelete&ftid="+arrCol[0]+"&"+new Date().getTime();
			for (var j=0;j<arrCol.length;j++){
				if (j==0){
					strData += "<TD><A class='reportoptions' align='center' href='"+strURLDelete+"' onclick='if(confirm(\"Are you sure to delete this item?\")){attachNextUrl(this);return true;}else{return false;}'><img BORDER='0' src='/images/trashcan.gif' width='12' height='12' align='absmiddle' TITLE='Delete Item'></A></TD>";				
				}else if (j==1){
					strData += "<td><a class='reportoptions' REL='facebox' ALIGN='left' href='"+strURLEdit+"'>"+arrCol[j]+"</a></td>";				
				}else{
					strData += "<td HEIGHT='23'>"+arrCol[j]+"</td>";
				}
			}
			strData += "</tr>";
		}
		strData += "</table>";
		document.getElementById("div_fasttracklist").innerHTML = strData;
	//}catch(ex){}
}


/*

function popInvoice(urlpop){
	var popcurrentTime = new Date().getTime();
	urlpop += "&="+new Date().getTime();
	var w = 760; var h = 600;LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
	settings = 'help:0;resizable:0;dialogWidth:'+w+'px;dialogHeight:'+h+'px';
	invoiceWIN = showModelessDialog(urlpop,"Invoice",settings); 
}

*/