var ns4 = (document.layers)? true:false;
var ie4 = (document.all)? true:false;
var ie5 = (document.getElementById)? true : false;
var ua = navigator.userAgent.toLowerCase();
var isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1));
var ieVersion = parseFloat(ua.substring(ua.indexOf('msie ') + 5));
var isGecko = (ua.indexOf("gecko") != -1);
var isSafari = (ua.indexOf("safari") != -1);
var isFirefox = (ua.indexOf("firefox") != -1);
var GB_ROOT_DIR = "greybox/";

/* ------Tab Navigation----- */
$(document).ready(function(){
 $('.tab').click(function () {
	closeDiv('flybox');

  $('#tabsF > .tabs > li > a')
	  .removeClass('active');
	  

  $(this).addClass('active');

  $('.tab_contents_container > div.tab_contents_active')
	  .removeClass('tab_contents_active');

  $(this.rel).addClass('tab_contents_active');

 });
});
/* -----End of Tab Navigation----- */

/* -----Main menu---------------*/
navHover = function() {
	if(document.getElementById('navmenu-h') != null)
	{	
		var lis = document.getElementById("navmenu-h").getElementsByTagName("LI");
		for (var i=0; i<lis.length; i++) {
			lis[i].onmouseover=function() {
				this.className+=" iehover";
			}
			lis[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" iehover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);
/* -----End of Main menu---------------*/

/* -----Popup Box (Home page)----- */
var previd = "";
function showhideDiv(id,ancpos,f,l,c)
{
	if(previd!="")
		$('#'+previd).hide();
	previd = id;
	var anc = $('#'+ancpos);
	var offset = anc.offset();
	var divid = $('#'+id);
	divid.css({position:"absolute",color:"#000",left:offset.left-18 ,top:offset.top+12});
	for (i=f;i<=l;i++)
	{
		if (i==c)
		{
			$('#category'+i).show();
		}
		else
		{
			$('#category'+i).hide();
		}
	}
	divid.show();
}
function showhideDiv1(id,ancpos,x,y)
{
	if ($.browser.msie) {
		$(".midcont").find(".selectbox2").css({visibility:"hidden"});
	}
	if(previd!="")
		$('#'+previd).hide();
	previd = id;
	var anc = $('#'+ancpos);
	var offset = anc.offset();
	//alert(offset.top + ":::::" + offset.left);
	var divid = $('#'+id);
	divid.css({top:offset.top+y,left:offset.left+x});
	divid.show();
}
function SlideShow(ancpos,img_path,img_desc)
{
	if(previd!="")
		$('#'+previd).hide();
	previd = '#slide_show';
	var anc = $('#'+ancpos);
	var offset = anc.offset();
	var divid = $('#slide_show');
	$('#big_img').attr({src:'images/'+img_path});
	$('#big_img').css({border:'1px solid #000000'});
	$('#desc').text(img_desc);
	if ( !(jQuery.browser.msie)) 
	{
		divid.css({top:offset.top-111,left:offset.left});
	}
	else
	{
		divid.css({top:offset.top,left:offset.left});
	}
	divid.show();
}
function SlideShow1(ancpos,img_path1,img_path2)
{
	if(previd!="")
		$('#'+previd).hide();
	previd = '#Product';
	var anc = $('#'+ancpos);
	var offset = anc.offset();
	var divid = $('#Product');
	$('#f_img').attr({src:'images/'+img_path1});
	$('#f_img').css({border:'1px solid #000000'});
	$('#b_img').attr({src:'images/'+img_path2});
	$('#b_img').css({border:'1px solid #000000'});

	if ( !(jQuery.browser.msie)) 
	{
		divid.css({top:offset.top,left:offset.left-150});
	}
	else
	{
		divid.css({top:offset.top,left:offset.left-150});
	}
	divid.show();
}
function closeDiv(id)
{
	if ($.browser.msie) {
		$(".midcont").find(".selectbox2").css({visibility:"visible"});
	}
	var divid = $('#'+id);
	divid.hide();
}
function closeDiv2(id1,id2)
{
	if ($.browser.msie) {
		$(".midcont").find(".selectbox2").css({visibility:"visible"});
	}
	var divid1 = $('#'+id1);
	var divid2 = $('#'+id2);
	divid1.hide();
	divid2.hide();
}
/* -----End of Popup Box (Home page) ----- */

function isEmpty(eltObj)
{
	//return $.trim(eltObj.value) == "";
	var strValue	=	trimAll(eltObj.value);
    
	if(strValue.length > 0)
	{
		return false;
    }
	return true;
}
function isEmail(obj)
{	
	str = obj.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (!filter.test(str))
	{
		return false;
	}
	return true;
}
function trimAll(strValue)
{
   var objRegExp = /^(\s*)$/;

   //check for all spaces
   if(objRegExp.test(strValue)) 
   {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
   }
    
   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) 
   {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
   }
   return strValue;
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	if (isNaN(key)) return true;
	keychar = String.fromCharCode(key);
	if (key == 8 || isCtrl)
	{
		return true;
	}
	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' : false;
	return isFirstN || reg.test(keychar);
}
function validate_forgot(frm)
{
	if (isEmpty(frm.txtEmail))
	{
		alert('Please enter Email ID');
		frm.txtEmail.focus();
		return false;
	}
	if(!isEmail(frm.txtEmail))
	{ 
		alert("Please enter valid Email ID");
		frm.txtEmail.focus();
		return false; 
	}
	return true;
}

function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	if (isNaN(key)) return true;
	keychar = String.fromCharCode(key);
	if (key == 8 || isCtrl)
	{
		return true;
	}
	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' : false;
	return isFirstN || reg.test(keychar);
}

function validate_product_profile(frm)
{
    if (isEmpty(frm.txtAccountEmail))
    {
		    alert('Please enter Email ID');
		    frm.txtAccountEmail.focus();
		    return false;
    }
    if(!isEmail(document.getElementById("txtAccountEmail")))
    { 
		    alert("Please enter valid Email ID");
		    frm.txtAccountEmail.focus();
		    return false; 
    }
    if(validate_securityquestion(frm) == false) return false;
}


function validate_shipping_info(frm)
{

var newdate = new Date();
var Exp_month = newdate.getMonth()+1;
var Exp_year =  newdate.getFullYear();

if(isEmpty(frm.txtFname))
{
    alert('First Name of the customer is required and it should not contain any special characters,please enter it');
    frm.txtFname.focus();
    return false;
}
var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?"; 
for (var i = 0; i < frm.txtFname.value.length; i++)
{ 
     if(iChars.indexOf(frm.txtFname.value.charAt(i)) != -1) 
     {
        alert ('First Name of the customer is required and it should not contain any special characters,please enter it'); 
        return false; 
     } 
 } 
if(isEmpty(frm.txtLname))
{
alert('Last Name of the customer is required and it should not contain any special characters,please enter it');
frm.txtLname.focus();
return false;
}

for (var i = 0; i < frm.txtLname.value.length; i++)
{ 
     if(iChars.indexOf(frm.txtLname.value.charAt(i)) != -1) 
     {
        alert ('Last Name of the customer is required and it should not contain any special characters,please enter it'); 
        return false; 
     } 
 }

if(isEmpty(frm.txtAddress))
{
alert('Address 1 of customers is required,please enter it');
frm.txtAddress.focus();
return false;
}
if(isEmpty(frm.txtCity))
{
alert('City is required,must be alphanumeric & should not exceed 50 characters,please enter it');
frm.txtCity.focus();
return false;
}
if(isEmpty(frm.txtPhonenum))
{
alert('Phone Number is required,must be numeric & should not contain special characters');
frm.txtPhonenum.focus();
return false;
}
if(isEmpty(frm.txtZip))
{
alert('Zipcode is required,must be numeric,should not contain special characters & maximum of 20 characters are allowed');
frm.txtZip.focus();
return false;
}
if(frm.ddlCountrys.value =="0")
{
        alert('Please select your Country');
		frm.ddlCountrys.focus();
		return false;
}

if(frm.ddlStates.value =="0")
{
        alert('Please select your state');
		frm.ddlStates.focus();
		return false;
}
if(document.getElementById("txtEmailAddress")!= null)
{
if (isEmpty(frm.txtEmailAddress))
{
		alert('Please enter Email ID');
		frm.txtEmailAddress.focus();
		return false;
}

if(!isEmail(document.getElementById("txtEmailAddress")))
{ 
		alert("Please enter valid Email ID");
		frm.txtEmailAddress.focus();
		return false; 
}
}

if(validate_securityquestion(frm) == false) return false;

if(eval(frm.ddlValiduptoYear)){
if (((frm.ddlValiduptoYear.value*1) < (Exp_month) && (20+frm.ddlValiduptoYear.value) <= (1*Exp_year))||((20+frm.ddlValiduptoYear.value) < (1*Exp_year)) )
{
alert('valid upto date cannot be prior to the current date');
frm.ddlValiduptoYear.focus();
return false;
}
}
return true;
}

function validate_securityquestion(frm){
    if(eval(frm.ddlSecurityQuestion)){
        if(frm.ddlSecurityQuestion.value =="-1")
        {
            alert('Please select a security question');
	        frm.ddlSecurityQuestion.focus();
	        return false;
        } 
        if(frm.ddlSecurityQuestion.value =="CustomQ" && isEmpty(frm.txtSecurityQuestion))
        { 
            alert('Please enter your custom security question');
	        frm.txtSecurityQuestion.focus();
	        return false;
        }
        if(isEmpty(frm.txtSecurityAns))
        { 
            alert('Please enter your security answer.');
	        frm.txtSecurityAns.focus();
	        return false;
        }
    }
    return true;
}

function validate_newuser(frm)
{
    frm.txtPassword.value = $.trim(frm.txtPassword.value)
    frm.txtConformPassword.value = $.trim(frm.txtConformPassword.value)
	if (isEmpty(frm.txtEmail))
	{
		alert('Please enter Email ID');
		frm.txtEmail.focus();
		return false;
	}
	if(!isEmail(frm.txtEmail))
	{ 
		alert("Please enter valid Email ID");
		frm.txtEmail.focus();
		return false; 
	}
	if (isEmpty(frm.txtConfirmEmail))
	{
		alert('Please enter Confirm Email ID');
		frm.txtConfirmEmail.focus();
		return false;
	}
	if(!isEmail(frm.txtConfirmEmail))
	{ 
		alert("Please enter valid Confirm Email ID");
		frm.txtConfirmEmail.focus();
		return false; 
	}
	if (frm.txtConfirmEmail.value!=frm.txtEmail.value)
	{
		alert('Email addresses do not match');
		frm.txtConfirmEmail.focus();
		return false;
	}
	if (isEmpty(frm.txtPassword))
	{
		alert('Please enter Password');
		frm.txtPassword.focus();
		return false;
	}
	if (isEmpty(frm.txtConformPassword))
	{
		alert('Please enter Confirm Password');
		frm.txtConformPassword.focus();
		return false;
	}
	if (frm.txtPassword.value!=frm.txtConformPassword.value)
	{
		//alert('The entered password and confirm password fields are not matching,please re-enter both the fields');
		alert('Passwords do not match');
		frm.txtConformPassword.value = "";
		frm.txtPassword.value = "";
		frm.hdnPwd.value = "";
		frm.txtPassword.focus();
		return false;
	}
	frm.hdnPwd.value = frm.txtPassword.value;
	if(validate_securityquestion(frm) == false) return false;
	
	/*if (isEmpty(frm.txtFirstname))
	{
		alert('Please enter First Name');
		frm.txtFirstname.focus();
		return false;
	}
	if (isEmpty(frm.txtLastname))
	{
		alert('Please enter Last Name');
		frm.txtLastname.focus();
		return false;
	}
	if (isEmpty(frm.txtStreet))
	{
		alert('Please enter Street');
		frm.txtStreet.focus();
		return false;
	}
	if (isEmpty(frm.txtCity))
	{
		alert('Please enter City');
		frm.txtCity.focus();
		return false;
	}
//	if (isEmpty(frm.state))
//	{
//		alert('Please select State');
//		frm.state.focus();
//		return false;
//	}
	if (isEmpty(frm.txtZipcode))
	{
		alert('Please enter Zip Code');
		frm.txtZipcode.focus();
		return false;
	}
	if (isEmpty(frm.txtPhone))
	{
		alert('Please enter Phone Number');
		frm.txtPhone.focus();
		return false;
	}
	if (isEmpty(frm.txtCell))
	{
		alert('Please enter Cell Number');
		frm.txtCell.focus();
		return false;
	}
	if (isEmpty(frm.txtFax))
	{
		alert('Please enter Fax Number');
		frm.txtFax.focus();
		return false;
	}
	if (isEmpty(frm.txtWebsite))
	{
		alert('Please enter Website Name');
		frm.txtWebsite.focus();
		return false;
	}*/
	return true;
}

$(function() {
	var offsetX = 20;
	var offsetY = -20;
	var alertTimerId = 0;

	$('#atr-menu > ul > li > input, #atr-menu > ul > li > textarea').hover(function(e) {
		var tit = $(this).parent().attr('class');
		 var h = $('#tooltips').height();
		$('#tooltips')
		.css('top', e.pageY + offsetY - h)
		.css('left', e.pageX + offsetX);
		$('#tooltips').text(tit);
		$('#tooltips').show();
		alertTimerId = setTimeout ( "$('#tooltips').hide();", 3000 );
	}, function() {
		$('#tooltips').hide();
		clearTimeout ( alertTimerId );
	});
	
	$('#atr-menu > ul > li > input, #atr-menu > ul > li > textarea').mousemove(function(e) {
		var h = $('#tooltips').height();
		$('#tooltips').css('top', e.pageY + offsetY - h).css('left', e.pageX + offsetX);
	});

	$('#atr-menu > ul > li > input, #atr-menu > ul > li > textarea').click(function () { 
		$('#tooltips').hide();
		clearTimeout ( alertTimerId );
	});

	$('.img_temp img').hover(function(e) {
		var imgpath = $(this).attr('src');
		imgpath = imgpath.replace(".jpg", '_big.jpg');
		$('#imgtips img').attr({src:imgpath});
		$('#imgtips').css('top', e.pageY + offsetY + 50).css('left', e.pageX + offsetX - 220);
		$('#imgtips').show();
	}, function() {
		$('#imgtips').hide();
	});
	
	$('.img_temp img').mousemove(function(e) {
		$('#imgtips').css('top', e.pageY + offsetY + 50).css('left', e.pageX + offsetX - 220);
	});
});

var isShipBeforeSubmit = false;
function validate_checkout(frm)
{
	if (isEmpty(frm.txtFirstName))
	{
		alert('Please enter First Name');
		frm.txtFirstName.focus();
		return false;
	}
	if (isEmpty(frm.txtLastName))
	{
		alert('Please enter Last Name');
		frm.txtLastName.focus();
		return false;
	}
	if (isEmpty(frm.txtAddress1))
	{
		alert('Please enter Address');
		frm.txtAddress1.focus();
		return false;
	}
	
	//if(!CheckPOBox(frm.txtAddress1)){return false;}
	//if(!CheckPOBox(frm.txtAddress2)){return false;}
	
	if (isEmpty(frm.txtCity))
	{
		alert('Please enter City');
		frm.txtCity.focus();
		return false;
	}
	if (frm.cboCountry.value=='-1')
	{
		alert('Please select Country');
		frm.cboCountry.focus();
		return false;
	}
	if (frm.cboState.value=='-1')
	{
		alert('Please select State');
		frm.cboState.focus();
		return false;
	}
	if (isEmpty(frm.txtZip))
	{
		alert('Please enter Zip Code');
		frm.txtZip.focus();
		return false;
	}
	if (frm.txtZip.value.length < 5)
	{
		alert('Please enter five digit Zip Code');
		frm.txtZip.focus();
		return false;
	}
	if (isEmpty(frm.txtPhone))
	{
		alert('Please enter Phone Number');
		frm.txtPhone.focus();
		return false;
	}
	/*---------------*/
	if (isEmpty(frm.txtBillFirstName))
	{
		alert('Please enter First Name');
		frm.txtBillFirstName.focus();
		return false;
	}
	if (isEmpty(frm.txtBillLastName))
	{
		alert('Please enter Last Name');
		frm.txtBillLastName.focus();
		return false;
	}
	if (isEmpty(frm.txtBillAddress1))
	{
		alert('Please enter Address');
		frm.txtBillAddress1.focus();
		return false;
	}
	if (isEmpty(frm.txtBillCity))
	{
		alert('Please enter City');
		frm.txtBillCity.focus();
		return false;
	}
	if (frm.cboBillCountry.value=='-1')
	{
		alert('Please select Country');
		frm.cboBillCountry.focus();
		return false;
	}
	if (frm.cboBillState.value=='-1')
	{
		alert('Please select State');
		frm.cboBillState.focus();
		return false;
	}
	if (isEmpty(frm.txtBillZipCode))
	{
		alert('Please enter Zip Code');
		frm.txtBillZipCode.focus();
		return false;
	}
	if (frm.txtBillZipCode.value.length < 5)
	{
		alert('Please enter five digit Zip Code');
		frm.txtBillZipCode.focus();
		return false;
	}
	if (isEmpty(frm.txtBillPhone))
	{
		alert('Please enter Phone Number');
		frm.txtBillPhone.focus();
		return false;
	}
	isShipBeforeSubmit = true;
	shipping_info(frm);
	hasPOBoxInTextFld = false;
	if(!CheckPOBox(frm.txtAddress1)){return false;}
	if(!CheckPOBox(frm.txtAddress2)){return false;}
	if(hasPOBoxInTextFld){
		frm.txtIsUSPSOrder.value = "True";	
	}else{
		frm.txtIsUSPSOrder.value = "False";
	}
	
	return true;
}

function validate_password(frm){
    frm.txtPassword.value = $.trim(frm.txtPassword.value);
    frm.txtConformPassword.value = $.trim(frm.txtConformPassword.value);
    if (isEmpty(frm.txtPassword))
	{
		alert('Please enter Password');
		frm.txtPassword.focus();
		return false;
	}
	if (isEmpty(frm.txtConformPassword))
	{
		alert('Please enter Confirm Password');
		frm.txtConformPassword.focus();
		return false;
	}
	if (frm.txtPassword.value!=frm.txtConformPassword.value)
	{
		alert('Passwords do not match');
		frm.txtConformPassword.focus();
		return false;
	}
	return true;
}

function shipping_info(frm)
{
	//var frm = document.frm_checkout;
	if(frm.chkBilling.checked)
	{
		frm.txtBillFirstName.value	=frm.txtFirstName.value;
		frm.txtBillLastName.value	=frm.txtLastName.value;
		frm.txtBillTitle.value		=frm.txtTitle.value;
		frm.txtBillCompanyName.value=frm.txtCompanyName.value;
		frm.txtBillAddress1.value	=frm.txtAddress1.value;
		frm.txtBillAddress2.value	=frm.txtAddress2.value;
		frm.txtBillCity.value		=frm.txtCity.value;
		frm.cboBillCountry.value	=frm.cboCountry.value;
		frm.cboBillState.value		=frm.cboState.value;
		frm.txtBillZipCode.value	=frm.txtZip.value;
		frm.txtBillPhone.value		=frm.txtPhone.value;
	}
	else if(isShipBeforeSubmit == false)
	{
		frm.txtBillFirstName.value	=frm.txtHbillFirstName.value;
		frm.txtBillLastName.value	=frm.txtHbillLastName.value;
		frm.txtBillTitle.value		=frm.txtHbillTitle.value;
		frm.txtBillCompanyName.value=frm.txtHbillCompanyName.value;
		frm.txtBillAddress1.value	=frm.txtHbillAddress1.value;
		frm.txtBillAddress2.value	=frm.txtHbillAddress2.value;
		frm.txtBillCity.value		=frm.txtHbillCity.value;
		frm.cboBillCountry.value	=frm.txtHbillCountry.value;
		frm.cboBillState.value		=frm.txtHbillState.value;
		frm.txtBillZipCode.value	=frm.txtHbillZipCode.value;
		frm.txtBillPhone.value		=frm.txtHbillPhone.value;
	}
}

function ValidateCoupon(frm){
    if (isEmpty(frm.txtCouponCode))
	{
		alert('Please enter Coupon Code');
		frm.txtCouponCode.focus();
		return false;
	}
	return true;                                                                     
}

function CheckValidDate(frm)
{
	/**/
	if(eval(document.getElementById('lbtnPayment')) != null && 
	    eval(document.getElementById('lbtnPayment')) != undefined)
	{
	    if(document.getElementById('lbtnPayment').disabled)
	        return false;
	}
	if (frm.chkAdditionalFee.checked && frm.cboAddlFee.value=='-1')
    {
        alert('Please select additional fee type.');
        frm.cboAddlFee.focus();
        return false;
    }    
	if (isEmpty(frm.txtCardName))
	{
		alert('Please enter Card-Name');
		frm.txtCardName.focus();
		return false;
	}  		
	if (frm.cboTypes.value=='-1')
	{
		alert('Please select Credit Card type');
		frm.cboTypes.focus();
		return false;
	}
	if (isEmpty(frm.txtCardNumber))
	{
		alert('Please enter Card-Number');
		frm.txtCardNumber.focus();
		return false;
	}	
	
	if (frm.cboTypes.value==637)
	{	
		if ((!(frm.txtCardNumber.value.substring(0,2) == 34) && !(frm.txtCardNumber.value.substring(0,2) == 37)) )
		{
		    alert("Invalid Credit Card Number");
		    return false;
		}
	}

	if (frm.cboTypes.value==267)
	{	
		if (!((frm.txtCardNumber.value.substring(0,2) > 50) && (frm.txtCardNumber.value.substring(0,2) < 56)))
		{
		    alert("Invalid Credit Card Number");
		    return false;
		}
	}

	if (frm.cboTypes.value==268)
	{	
		if (!(frm.txtCardNumber.value.substring(0,1) == 4))
		{alert("Invalid Credit Card Number");
		return false;
		}
	}
    /* For Expiry Date validation by Satish Begin*/
	var newdate = new Date();
	var Exp_month = newdate.getMonth()+1;
	var Exp_year =  newdate.getFullYear();
	if (((frm.cc_exp_month.value*1) < (Exp_month) && (20+frm.cc_exp_year.value) <= (1*Exp_year))||((20+frm.cc_exp_year.value) < (1*Exp_year)) )
	{
		alert('Expiration Date cannot be prior to current date');
		frm.cc_exp_month.focus();
		return false;
	} 
	/*For Expiry Date validation by Satish End*/	
	
	BlockUserInterface();
	return true;
}

var hasPOBoxInTextFld = false;
function CheckPOBox(txtfld){
	if(hasPOBoxInTextFld) return true;
    var arrPoBox = new Array("po box", "p o box", "p.o. box", "po. box", "p.o box",
							"pobox", "p obox", "p.o.box", "po.box", "p.obox");
		
	var addrLine = txtfld.value;				
	addrLine = addrLine.toLowerCase();
	var isPOOk = true;
	for(iPo=0; iPo < arrPoBox.length; iPo++){
		if(addrLine.indexOf(arrPoBox[iPo])==0){
			//if(!confirm("Please note that our shipper UPS, does not ship to PO Boxes. If you cannot provide a regular address, we will ship your package by United States Postal Service. We cannot guarantee that your package will arrive within the time provided. We also do not provide any tracking numbers for Shipments to PO Boxes. This is not applicable to Direct Mail orders. Please confirm.")){
			/*if(!confirm("This order will be shipped by USPS since the address is a post box.")){
				txtfld.focus();
				isPOOk = false
			}else{
				hasPOBoxInTextFld = true;
			}*/
			alert("We do not ship to PO Boxes. Please enter a valid residential or a commercial / office address.");
			txtfld.focus();
			isPOOk = false
			break;
		}
	}
	return isPOOk;	
}


function ValidateCustomer(){
    document.getElementById("txtPassword").value = $.trim(document.getElementById("txtPassword").value);
    if (isEmpty(document.getElementById("txtUserName")) ||
        document.getElementById("txtUserName").value == "Username")
	{
		alert('Please enter Username ');
		document.getElementById("txtUserName").focus();
		return false;
	}
	if(!isEmail(document.getElementById("txtUserName")))
	{ 
		alert("Please enter valid Email ID");
		document.getElementById("txtUserName").focus();
		return false; 
	}
	if (isEmpty(document.getElementById("txtPassword")))
	{
		alert('Please enter Password');
		document.getElementById("txtPassword").focus();
		return false;
	}   
	
	window.frames['ifrmUserStatus'].window.document.frmUserStatus.txtUser.value = document.getElementById("txtUserName").value;
	window.frames['ifrmUserStatus'].window.document.frmUserStatus.txtPasswod.value = document.getElementById("txtPassword").value;
	window.frames['ifrmUserStatus'].window.document.frmUserStatus.txtAuthenticate.value = "Authenticate";
	window.frames['ifrmUserStatus'].window.document.frmUserStatus.submit();
	
}

function validate_login(){
    document.getElementById("txtPassword").value = $.trim(document.getElementById("txtPassword").value);
    document.getElementById("txtUserName").value = $.trim(document.getElementById("txtUserName").value);
    if (isEmpty(document.getElementById("txtUserName")) ||
        document.getElementById("txtUserName").value == "Username")
	{
		alert('Please enter Username ');
		document.getElementById("txtUserName").focus();
		return false;
	}
	if(!isEmail(document.getElementById("txtUserName")))
	{ 
		alert("Please enter valid Email ID");
		document.getElementById("txtUserName").focus();
		return false; 
	}
	if (isEmpty(document.getElementById("txtPassword")))
	{
		alert('Please enter Password');
		document.getElementById("txtPassword").focus();
		return false;
	}  
	return true; 
}

function LogoutCustomer(){
    try
    {
        if(eval(window.frames['ifrmUserStatus'].window.document.frmUserStatus.txtAuthenticate)){
            window.frames['ifrmUserStatus'].window.document.frmUserStatus.txtAuthenticate.value = "Logout";
	        window.frames['ifrmUserStatus'].window.document.frmUserStatus.submit();
	    }else{	   	    
            window.location.href = BPB_APPROOT + "Account/EndSession.aspx";
	    }
	} catch(e){	    
	    window.location.href = BPB_APPROOT + "Account/EndSession.aspx";
	}
}

function InvalidUser(){
    alert("Incorrect username or password. Please verify your username and password and attempt to login again");
    document.getElementById("txtPassword").value = "Password";   
    document.getElementById("txtUserName").focus();
}

var isUserLogged = false;
var lastEventClicked = "";

var gbunmane ="";
var gbpsq =0;
var gbccount=0;
var gbccost = 0.0;
var gbsdcount=0;
var gbccissmb = false;
var gbismcaccount = false;
var proofs = 0;

function SetGBLogin(userName, psq, cartcount, cartcost, isSmb, sdcount, ismcaccount,ishasProofs)
{
    GB_hide();
    gbunmane = userName;
    gbpsq = psq;
    gbccount = cartcount;
    gbsdcount = sdcount;
    gbccost = cartcost;
    gbccissmb = isSmb;
    gbismcaccount = ismcaccount;
    proofs = ishasProofs;
    
    var userHtml = "<dl><dt><div class=\"loader\"><img src=\"" + BPB_IMAGE_ROOT + "loading8.gif\" alt=''/></div></dt></dl>";
    document.getElementById("divUserLogin").innerHTML = userHtml;
    
    
    tid = setTimeout("SetLoginData();", 2000);       
}

function SetLoginData(){
    //alert(gbccount + "::::" + gbccost + ":::" + gbsdcount);
    
       
    SetLoggedInUser(gbunmane, gbpsq, gbccissmb, false, gbismcaccount,proofs);
    SetCartInfo(gbccount, gbccost, gbsdcount); 
    
    if(gbpsq==0 && lastEventClicked != ""){
        var lce = lastEventClicked.split("#^#");
        //alert(lce[0] + "::::" + lce[1])
        if(lce[0] == "SaveDesign"){            
            SaveChanges(lce[1]);
        }
        lastEventClicked = "";
        gbunmane ="";
        gbpsq =0;
        gbccount=0;
        gbccost = 0.0;
    }
    
}

function SetLoggedInUser(userName,psq, isSMBUser, isAdmin, isMCA,hasProofs){
    //document.getElementById("divUserLogin").style.display="none";
    //document.getElementById("divLoggedUser").style.display="block";
    isUserLogged = true;
    var mcaHtml = "";
    if(eval(isMCA)){
        mcaHtml = "<br><span style=\"padding:0px 65px 0px 0px;\"><a id=\"anchMCAAcc\" href=\"javascript:void(0)\" onmouseover=\"javascript:showhideDiv1('mcaAccountNote','anchMCAAcc',-253,13);\" onmouseout=\"javascript:closeDiv('mcaAccountNote');;\" class=\"a1\">Designated MCA Account</a></span>";
        //alert(mcaHtml)
    }
    
    var userHtml = "<dl><dt><div class=\"user\">Welcome " + 
        unescape(userName) + "! | <a href=\"javascript:void(0)\" onclick=\"LogoutCustomer();\">Logout</a>"+mcaHtml+"</div></dt></dl>";
        
    document.getElementById("divUserLogin").innerHTML = userHtml;
    document.getElementById("mnuMyAccount").style.display = "block";
    //alert(isSMBUser);
    HideMenusforSMB(isSMBUser);
    
    if(psq == 1){
        
        var newDate = new Date();
        var timeStampLink = newDate.getMonth()+""+newDate.getDate()+""+newDate.getYear()
            +""+newDate.getHours()+""+newDate.getMinutes()+""+newDate.getSeconds()+""+newDate.getMilliseconds();
               
        var url = "../Account/security-question-and-answer.aspx?ts=" + timeStampLink;
        //alert(url);
        GB_showCenter("Account Security Update",url,275,650)        
    }
    if(eval(hasProofs))
    {    
    var url = "../Account/CustomerComments.aspx?navifrom=Common";
    GB_showCenter("View Proofs",url,87,380) 
    }
    //alert(isAdmin);
    if(eval(isAdmin)){
        if(isAdmin == true){
            document.getElementById("divMenuCartLinks").style.display = "none";
            document.getElementById("mnuProducts").style.display = "none";
            document.getElementById("mnuServices").style.display = "none";
            document.getElementById("footerGeneric").style.display = "none";
            document.getElementById("footerSMBProducts").style.display = "none";
            document.getElementById("footerProducts").style.display = "none";
        }
    }    
}

function RestUser(urlroot){
    //DisplayUserLogin();
    //alert(BPB_APPROOT + "index.htm");
    window.location.href = urlroot + "index.htm";
}



function SetCartInfo(items, cartprice, sdcount){
    var cartInfo = "";
    var reprintInfo = "";
    var savedesignInfo = "";
    
    var BPBAPPROOT = BPB_APPROOT;
    if(window.location.protocol == "https:"){
        if(paymentpagebase != "")
            BPBAPPROOT = paymentpagebase;
    }
    
    if(isUserLogged){
        cartInfo = "<p><a onclick=\"return ConfirmNav();\" href=\""+BPBAPPROOT+"Cart/Shopping-Cart.aspx\"><b>Your Cart</b></a>: "+items+" items $ " + cartprice+"</p>";
        reprintInfo = "<a onclick=\"return ConfirmNav();\" href=\""+BPBAPPROOT+"Account/order-reprints.aspx\"><b>Order Reprints</b></a>"
        savedesignInfo = "<a onclick=\"return ConfirmNav();\" href=\""+BPBAPPROOT+"Account/my-saved-designs.aspx\"><b>Saved Designs</b></a>: "+sdcount+" items"
    }else{
        cartInfo = "<p><a href=\"javascript:void(0);\" onclick=\"alert('Please login to access your shopping cart.');\"><b>Your Cart</b></a>: "+items+" items $ " + cartprice+"</p>";
        reprintInfo = "<a href=\"javascript:void(0);\" onclick=\"alert('Please login to access order reprints.');\"><b>Order Reprints</b></a>"
        savedesignInfo = "<a href=\"javascript:void(0);\" onclick=\"alert('Please login to access your saved designs.');\"><b>Saved Designs</b></a>: "+sdcount+" items"
    }
    document.getElementById("mnuCartInfo").innerHTML = cartInfo;    
    document.getElementById("mnuOrderReprint").innerHTML = reprintInfo;
    document.getElementById("mnuSaveDesign").innerHTML = savedesignInfo;
    
    setGeotrustSeal();
}

function setGeotrustSeal() {
    if (window.location.hostname.indexOf("bestprintbuy.com") == -1) { return; }
    //divIfrmGeotrust
    if (eval(document.getElementById("divIfrmGeotrust"))) {
        var iframeGroTrst = document.createElement('iframe');
        iframeGroTrst.frameBorder = 0;
        iframeGroTrst.scrolling = "no";
        iframeGroTrst.width = "115px";
        iframeGroTrst.height = "55px";
        iframeGroTrst.id = "ifrmGeoTrust";
        iframeGroTrst.src = window.location.protocol + "//" + window.location.hostname.toLowerCase() + "/geotrustseal.html";
        document.getElementById("divIfrmGeotrust").appendChild(iframeGroTrst);
    }

}

function ShowPCThumbToolTip(imgurl)
{
	Tip('<table cellpadding=1 cellspacing=0 border=0 bgcolor=#333333 width="536"><tr><td><img width="536" height="416" src="'+imgurl+'"></td></tr></table>', 
	    WIDTH, 540, HEIGHT, 408, PADDING, 5, BGCOLOR, '#ffffff', BORDERCOLOR, '#333333');		
}

function ShowBCThumbToolTip(imgurl)
{
	Tip('<table cellpadding=1 cellspacing=0 border=0 bgcolor=#333333 width="348"><tr><td><img width="348" height="204" src="'+imgurl+'"></td></tr></table>', 
	    WIDTH, 350, HEIGHT, 196, PADDING, 5, BGCOLOR, '#ffffff', BORDERCOLOR, '#333333');		
}
function ShowDHThumbToolTip(imgurl)
{
	Tip('<table cellpadding=1 cellspacing=0 border=0 bgcolor=#333333 width="396"><tr><td><img width="396" height="1068" src="'+imgurl+'"></td></tr></table>', 
	    WIDTH, 398, HEIGHT, 1078, PADDING, 5, BGCOLOR, '#ffffff', BORDERCOLOR, '#333333');		
}
function ShowBKThumbToolTip(imgurl)
{
	Tip('<table cellpadding=1 cellspacing=0 border=0 bgcolor=#333333 width="240"><tr><td><img width="240" height="828" src="'+imgurl+'"></td></tr></table>', 
	    WIDTH, 242, HEIGHT, 838, PADDING, 5, BGCOLOR, '#ffffff', BORDERCOLOR, '#333333');		
}
function ShowThumbToolTip(imgurl,producttype,sizekey)
{
    var borderwidth = 0;
    var borderheight = 0;
    var width = 0;
    var height = 0; 
    var imgTipTableBG = "#333333";   
    if(producttype == 243 || producttype == 631 || producttype == 844)
    {
        width = 348;
        height = 204;
        borderwidth = 350;
        borderheight = 196;
    }
    else if(producttype == 244 || producttype == 722 || producttype == 723 || producttype == 853)
    {
        if(sizekey == 32)
        {
            width = 414;
            height = 269;
            borderwidth = 416;
            borderheight = 263; 
        }
        else
        {
            width = 536;
            height = 416;
            borderwidth = 540;
            borderheight = 408;
        }
    }
    else if(producttype == 839)
    {
        //width = 396;
        //height = 1068;
        //borderwidth = 398;
        //borderheight = 1078;
        
        width = 198;
        height = 535;
        borderwidth = 200;
        borderheight = 537;
    }
    else if(producttype == 846)
    {
        width = 138;
        height = 414;
        borderwidth = 140;
        borderheight = 416;
    }
    else if(producttype == 871)
    {
        width = 336;
        height = 192;
        borderwidth = 338;
        borderheight = 184;
        imgTipTableBG = "#ffffff"
    }
    else if(producttype == 852)
    {
        width = 348;
        height = 780;
        borderwidth = 350;
        borderheight = 790;
    }
    else if(producttype == 851)
    {
         width = 348;
         height = 828;
         borderwidth = 350;
         borderheight = 838;
        /*if(sizekey == 182)
        {
            width = 348;
            height = 780;
            borderwidth = 350;
            borderheight = 790; 
        }
        else
        {
            width = 348;
            height = 540;
            borderwidth = 350;
            borderheight = 550;
        }*/
        
    }
    else if(producttype == 249)
    {
        width = 414;
        height = 534;
        borderwidth = 416;
        borderheight = 544;
    }
    else if(producttype == 250)
    {
        width = 466;
        height = 206;
        borderwidth = 466;
        borderheight = 216;
    }
    var cw = tt_GetClientW();
    var ch = tt_GetClientH();
    
    var tipx = (cw - borderwidth)/2;
    var tipy = (ch - borderheight)/2;
    
    var scrollx = tt_GetScrollX();
    var scrolly = tt_GetScrollY();
    tipy = tipy + scrolly;
    
    Tip('<table cellpadding=1 cellspacing=0 border=0 bgcolor="'+imgTipTableBG+'"><tr><td><img width="'+width+'" height="'+height+'" src="'+imgurl+'"></td></tr></table>', 
	    WIDTH, '"'+borderwidth+'"', HEIGHT, '"'+borderheight+'"', PADDING, 5, BGCOLOR, '#ffffff', BORDERCOLOR, '#333333');	
	    
	/*Tip('<table cellpadding=1 cellspacing=0 border=0 bgcolor=#333333 width="240"><tr><td><img width="'+width+'" height="'+height+'" src="'+imgurl+'"></td></tr></table>', 
	    WIDTH, '"'+borderwidth+'"', HEIGHT, '"'+borderheight+'"', PADDING, 5, BGCOLOR, '#ffffff', BORDERCOLOR, '#333333',FIX, [tipx, tipy]);*/		
}

function MouseoverImgOff(elmntName, imgsrc){
//    if(document.getElementById(elmntName).src.indexOf("btn_on") >-1){
//        return;
//    }
    document.getElementById(elmntName).src = imgsrc;
}

function MouseoverImgON(elmntName, imgsrc){
//    if(document.getElementById(elmntName).src.indexOf("btn_on") >-1){
//        return;
//    }
    document.getElementById(elmntName).src = imgsrc;
}

/*For customer login page added by satish Begin*/
function ValidateLoginCustomer(){
    
    if (isEmpty(document.getElementById("txtUserName")) ||
        document.getElementById("txtUserName").value == "Username")
	{
		alert('Please enter Username ');
		document.getElementById("txtUserName").focus();
		return false;
	}
	if(!isEmail(document.getElementById("txtUserName")))
	{ 
		alert("Please enter valid Email ID");
		document.getElementById("txtUserName").focus();
		return false; 
	}
	if (isEmpty(document.getElementById("txtPassword")))
	{
		alert('Please enter Password');
		document.getElementById("txtPassword").focus();
		return false;
	}   
	
	document.getElementById("txtAuthenticate").value = "Authenticate";
	return true;
	
}

function RestDirectUser(){        
    parent.parent.location.href="../Cart/Shopping-Cart.aspx";
    CloseGreyBox();
    
}
function RedirectUserToURL(url){
    
               
    parent.parent.location.href=url;
    CloseGreyBox();
    
    BlockUserInterface(); 
    
}
/*For customer login page added by satish End*/

/* My account script functions */

function validate(frm)
{
	if(frm.txtFname.value==""){
		alert("Please enter your first name");
		frm.txtFname.focus();
		return false;
	}

	if(frm.txtLname.value==""){
		alert("Please enter your last name");
		frm.txtLname.focus();
		return false;
	}
	
	if(frm.txtAddress.value==""){
		alert("Please enter your address");
		frm.txtAddress.focus();
		return false;
	}

	if(frm.txtCity.value==""){
		alert("Please enter your city");
		frm.txtCity.focus();
		return false;
	}

	if(frm.ddlCountrys.value ==""){
		alert("Please select your country");
		frm.ddlCountrys.focus();
		return false;
	}

	if(frm.ddlStates.value ==""){
		alert("Please select your state");
		frm.ddlStates.focus();
		return false;
	}

	if(frm.txtZip.value==""){
		alert("Please enter your zipcode");
		frm.txtZip.focus();
		return false;
	}

	if(frm.txtPhonenum.value==""){
		alert("Please enter your phone number");
		frm.txtPhonenum.focus();
		return false;
	}

	if(frm.txtEmailAddress.value==""){
		alert("Please enter your e-mail id");
		frm.txtEmailAddress.focus();
		return false;
	}
	else{
		if(!isEmail(frm.txtEmailAddress.value)){
			alert("Please enter a valid e-mail id")
			frm.txtEmailAddress.focus();
			return false;
		}
	}

	function isEmail (s)
	{   
		var i = 1;
		var sLength = s.length;

		while ((i < sLength) && (s.charAt(i) != "@"))
		{ i++
		}
		if ((i >= sLength) || (s.charAt(i) != "@")) return false;
		else i += 2;
		while ((i < sLength) && (s.charAt(i) != "."))
		{ i++
		}
		if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
		else return true;
	}


}


function validateshipping(frm)
{
	if(frm.fname.value==""){
		alert("Please enter your first name");
		frm.fname.focus();
		return false;
	}

	if(frm.lname.value==""){
		alert("Please enter your last name");
		frm.lname.focus();
		return false;
	}
	
	if(frm.address.value==""){
		alert("Please enter your address");
		frm.address.focus();
		return false;
	}

	if(frm.citys.value==""){
		alert("Please enter your city");
		frm.citys.focus();
		return false;
	}

	if(frm.countrys.value ==""){
		alert("Please select your country");
		frm.countrys.focus();
		return false;
	}

	if(frm.states.value ==""){
		alert("Please select your state");
		frm.states.focus();
		return false;
	}

	if(frm.zipc.value==""){
		alert("Please enter your zipcode");
		frm.zipc.focus();
		return false;
	}

	if(frm.phonenum.value==""){
		alert("Please enter your phone number");
		frm.phonenum.focus();
		return false;
	}

}

function validatebilling(frm)
{
	if(frm.fname.value==""){
		alert("Please enter your first name");
		frm.fname.focus();
		return false;
	}

	if(frm.lname.value==""){
		alert("Please enter your last name");
		frm.lname.focus();
		return false;
	}
	
	if(frm.address.value==""){
		alert("Please enter your address");
		frm.address.focus();
		return false;
	}

	if(frm.citys.value==""){
		alert("Please enter your city");
		frm.citys.focus();
		return false;
	}

	if(frm.countrys.value ==""){
		alert("Please select your country");
		frm.countrys.focus();
		return false;
	}

	if(frm.states.value ==""){
		alert("Please select your state");
		frm.states.focus();
		return false;
	}

	if(frm.zipc.value==""){
		alert("Please enter your zipcode");
		frm.zipc.focus();
		return false;
	}

	if(frm.phonenum.value==""){
		alert("Please enter your phone number");
		frm.phonenum.focus();
		return false;
	}

}

function validatepassword(frm)
{
     /*if(frm.txtOldPassword.value==""){
		alert("Please enter your old password");
		frm.txtOldPassword.focus();
		return false;
	}*/

	if(frm.txtnewPassword.value==""){
		alert("Please enter your new password");
		frm.txtnewPassword.focus();
		return false;
	}
	if(frm.txtnewPassword.value.length< 4){
		alert("New password is required,it should contain minimum of four characters and should not contain special characters,please enter");
		frm.txtnewPassword.focus();
		return false;
	}
	if(frm.txtConfirmPassword.value.length< 4){
		alert("Re-type password is required,it should contain minimum of four characters and should not contain special characters,please enter");
		frm.txtConfirmPassword.focus();
		return false;
		}
	
	if(frm.txtConfirmPassword.value==""){
		alert("Please enter confirm password ");
		frm.txtConfirmPassword.focus();
		return false;
		}
		if(frm.txtConfirmPassword.value!=frm.txtnewPassword.value)
		{
		alert("Passwords do not match ");
		frm.txtnewPassword.value = "";
		frm.txtConfirmPassword.value = "";		
		frm.txtnewPassword.focus();
		return false;
		}
		
	}
	


function validateaddress(frm)
{
    if(frm.txtFirstName.value==""){
		alert("Please enter your first name");
		frm.txtFirstName.focus();
		return false;
	}

	if(frm.txtLastName.value==""){
		alert("Please enter your last name");
		frm.txtLastName.focus();
		return false;
	}
	
	if(frm.txtStreet.value==""){
		alert("Please enter your street address ");
		frm.txtStreet.focus();
		return false;
	}

	if(frm.txtCity.value==""){
		alert("Please enter your city ");
		frm.txtCity.focus();
		return false;
	}

	if(frm.txtZip.value==""){
		alert("Please enter your zip code ");
		frm.txtZip.focus();
		return false;
	}
	
	/*if(frm.cboGroup.value==""){
		alert("Please select group ");
		frm.cboGroup.focus();
		return false;
	}
	
	if(frm.cboLists.value==""){
		alert("Please select list ");
		frm.cboLists.focus();
		return false;
	}*/
}

function validateuploadfile(frm)
{
	if(frm.uploadImgFile.value==""){
		alert("Please select a file of .csv Type to Upload");
		frm.uploadImgFile.focus();
		return false;
	}

}

/* My account script functions */

/* ListOf Holidays */
function CheckHoliday(fld)
{
    var dt = new Date(fld.value);
    var weekday = dt.getDay()
    if(weekday == 0 || weekday == 6 ){
	    alert("This day is a weekend. Mailing cannot be scheduled on weekends.");
	    return false;
    }

    //Thursday, January 1 New Year's Day <BR>Monday, May 25 Memorial Day <BR>Friday, 
    //July 3** Independence Day <BR>Monday, September 7 Labor Day <BR>Thursday, 
    //November 26 Thanksgiving Day <BR>Friday, December 25 Christmas Day 

	var holidays = new Array(new Array("01/01/2012","New Year Eve"),		
		new Array("05/28/2012","Memorial Day"),
		new Array("07/03/2012","Independence Day"),
		new Array("09/05/2012","Labor Day"),
		new Array("11/24/2011","Thanksgiving Day"),
		new Array("12/26/2011","Christmas"),
		new Array("12/31/2011","New Year Eve"));
	
	//05/23/2013, 05/26/2014,05/25/2015 

	for(i=0;i<holidays.length;i++)
	{
		if(fld.value == holidays[i][0]){
			alert("This day is a holiday. Mailing cannot be scheduled on holidays.");
			fld.focus();
			fld.select();	
			return false;
		}
	}
	return true;
}


/* Added By satish For Date Validation*/

function checkDate(fld) {    
    var mo, day, yr;
    var entry = fld;    
    var reLong = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/;
    var reShort= /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{2}\b/;    
    var valid = (reLong.test(entry)) || (reShort.test(entry));    
    if (valid) {
        var delimChar = (entry.indexOf("/") != -1) ? "/" : "-";
        var delim1 = entry.indexOf(delimChar);
        var delim2 = entry.lastIndexOf(delimChar);
        mo = parseInt(entry.substring(0, delim1), 10);
        day = parseInt(entry.substring(delim1+1, delim2), 10);
        yr = parseInt(entry.substring(delim2+1), 10);
        // handle two-digit year
        if (yr < 100) {
            var today = new Date();
            // get current century floor (e.g., 2000)
            var currCent = parseInt(today.getFullYear() / 100) * 100;
            // two digits up to this year + 15 expands to current century
            var threshold = (today.getFullYear() + 15) - currCent;
            if (yr > threshold) {
                yr += currCent - 100;
            } else {
                yr += currCent;
            }
        }
        var testDate = new Date(yr, mo-1, day);
        if (testDate.getDate() == day) {
            if (testDate.getMonth() + 1 == mo) {
                if (testDate.getFullYear() == yr) {
                    // fill field with database-friendly format
                    fld.value = mo + "/" + day + "/" + yr;
                    return true;
                } else {
                    alert("There is a problem with the year entry. Enter as mm/dd/yyyy.");
                }
            } else {
                alert("There is a problem with the month entry. Enter as mm/dd/yyyy.");
            }
        } else {
            alert("There is a problem with the date entry. Enter as mm/dd/yyyy.");
        }
    } else {
        alert("Incorrect date format. Enter as mm/dd/yyyy.");
    }
    return false;
}
/*End of function for  Date validation*/

/* The below code is included in order to support the htms given by the cliend */
var flag = true;
function view_all(id)
{
	if (flag==true)
	{
		for (i=1;i<=id;i++)
		{
			cobj	=	document.getElementById("ans"+i);
			cobj.style.display = "block";
		}
		flag = false;
	}
	else
	{
		for (i=1;i<=id;i++)
		{
			cobj	=	document.getElementById("ans"+i);
			cobj.style.display = "none";
		}
		flag = true;
	}
}

function controlDiv(id, noOfItems)
{
	for(i=1;i<=noOfItems;i++)
	{
		iobj	=	document.getElementById("pl_min"+i);
		cobj	=	document.getElementById("ans"+i);
		
		if(id != i)
		{
			cobj.style.display = "none";
			//iobj.src = "images/expand.gif";
		}
	}

	iobj	=	document.getElementById("pl_min"+id);
	cobj	=	document.getElementById("ans"+id);

	if(cobj.style.display == "block")
	{
		cobj.style.display = "none";
		//iobj.src = "images/expand.gif";
	}
	else
	{
		cobj.style.display = "block";
		//iobj.src = "images/collapse.gif";
	}
}


function ShowHideCustomQuestion(qVal){
    if(qVal == "CustomQ"){
        document.getElementById("trCustomQuestion").style.visibility = "visible";
        if(isFirefox || isSafari)
            document.getElementById("trCustomQuestion").style.display = "table-row";
        else
            document.getElementById("trCustomQuestion").style.display = "block";
    }else{
        document.getElementById("trCustomQuestion").style.visibility = "hidden";
        document.getElementById("trCustomQuestion").style.display = "none";
    }
} 

// Time out in milli seconds
var sessionTimeOut = 6600000; //110 * 60 * 1000  = 110 minutes 6600000 ms,  This value needs to be less than that of session time out value
var timerId =  setTimeout("KeepSessionAlive();", sessionTimeOut);
function KeepSessionAlive()
{
    var newDate = new Date();
    var TimeStampLink = newDate.getMonth()+""+newDate.getDate()+""+newDate.getYear()+""+newDate.getHours()+""+newDate.getMinutes()+""+newDate.getSeconds()+""+newDate.getMilliseconds();
    timerId = setTimeout("KeepSessionAlive();", sessionTimeOut);
    
    //alert(BPB_APPROOT);
    
    $.get(BPB_APPROOT + "Account/KeepSessionAlive.aspx?", {timestamp:TimeStampLink},
        function(data){
            //alert(data);
    });
}

function GBProductProfile(url){    
    
    GB_showCenter("Product Profile", url, 600,667);
}

function validate_Catalog(frm)
{  
	
	
	if (isEmpty(frm.txtFirstname))
	{
		alert('Please enter First Name');
		frm.txtFirstname.focus();
		return false;
	}
	if (isEmpty(frm.txtLastname))
	{
		alert('Please enter Last Name');
		frm.txtLastname.focus();
		return false;
	}
	if (isEmpty(frm.txtEmail))
	{
		alert('Please enter Email ID');
		frm.txtEmail.focus();
		return false;
	}
	if(!isEmail(frm.txtEmail))
	{ 
		alert("Please enter valid Email ID");
		frm.txtEmail.focus();
		return false; 
	}
	if (isEmpty(frm.txtStreet))
	{
		alert('Please enter Street');
		frm.txtStreet.focus();
		return false;
	}
	if (isEmpty(frm.txtCity))
	{
		alert('Please enter City');
		frm.txtCity.focus();
		return false;
	}
//	if (isEmpty(frm.state))
//	{
//		alert('Please select State');
//		frm.state.focus();
//		return false;
//	}
    if(frm.ddlStates.value =="-1")
    {
            alert('Please select your State');
		    frm.ddlStates.focus();
		    return false;
    }
	if (isEmpty(frm.txtZipcode))
	{
		alert('Please enter Zip  Code');
		frm.txtZipcode.focus();
		return false;
	}
	if (isEmpty(frm.txtNoOfAgents))
	{
		alert('Please enter No of agents');
		frm.txtNoOfAgents.focus();
		return false;
	}
	if (isEmpty(frm.txtContactPerson))
	{
		alert('Please enter Contact Person');
		frm.txtContactPerson.focus();
		return false;
	}
	if (isEmpty(frm.txtPhone))
	{
		alert('Please enter Phone Number');
		frm.txtPhone.focus();
		return false;
	}
	return true;
}

function validate_referafriend(frm)
{    
	if (isEmpty(frm.txtname))
	{
		alert('Please enter Name');
		frm.txtname.focus();
		return false;
	}
	if (isEmpty(frm.txtemail))
	{
		alert('Please enter Email ID');
		frm.txtemail.focus();
		return false;
	}
	if(!isEmail(frm.txtemail))
	{ 
		alert("Please enter valid Email ID");
		frm.txtemail.focus();
		return false; 
	}
	if (isEmpty(frm.txtfriendsname))
	{
		alert('Please enter Friend Name');
		frm.txtfriendsname.focus();
		return false;
	}
	if (isEmpty(frm.txtfriendsemail))
	{
		alert('Please enter Friend Email ID');
		frm.txtfriendsemail.focus();
		return false;
	}
	if(!isEmail(frm.txtfriendsemail))
	{ 
		alert("Please enter valid Friend Email ID");
		frm.txtfriendsemail.focus();
		return false; 
	}				
	return true;
}


