function LTrim(pStringToProcess){var WhiteSpc=new String(" \t\n\r"); var ProcessStr=new String(pStringToProcess); if(WhiteSpc.indexOf(ProcessStr.charAt(0))!= -1){ var Cnt1=0,Cnt2=ProcessStr.length; while(Cnt1<Cnt2 && WhiteSpc.indexOf(ProcessStr.charAt(Cnt1))!=-1) Cnt1++; ProcessStr=ProcessStr.substring(Cnt1,Cnt2);} return ProcessStr;}
function RTrim(pStringToProcess){var WhiteSpc=new String(" \t\n\r"); var ProcessStr=new String(pStringToProcess); if (WhiteSpc.indexOf(ProcessStr.charAt(ProcessStr.length-1))!= -1){ var Cnt2=(ProcessStr.length-1); while(Cnt2>=0 && WhiteSpc.indexOf(ProcessStr.charAt(Cnt2))!= -1) Cnt2--;    ProcessStr=ProcessStr.substring(0,(Cnt2+1));} return ProcessStr;}
function Trim(pStringToProcess){var _Trimmed=RTrim(LTrim(pStringToProcess)); return _Trimmed;}
function isNull(pVal2Check){return(pVal2Check==null);} 
function isBlank(pVal2Check){if(isNull(pVal2Check)||Trim(pVal2Check)=='') return true; return false;}  
function checkEmail(objThis){ if(isBlank(objThis.value)) return true; var tmpRegExpr = /^[0-9A-Za-z]+(([\.\_]+)?[0-9A-Z-a-z]+)*([\@]{1})(([0-9A-Z-a-z]+)([\.]{1})([0-9A-Za-z]+))+$/; var retVal = processChecking(objThis,tmpRegExpr,'Email ID is not proper, please correct the Email ID.',checkEmail.arguments); return retVal;}
function processChecking(objThis,pRegExpr,pMessage,funcArguments){hndEvent=window.event; var SetFocus=(funcArguments[1])?funcArguments[1]:false; var ShowAlert=(funcArguments[2])?funcArguments[2]:false; var tmpRegExpr=pRegExpr; var ActualRegExpr=new RegExp(tmpRegExpr); var Val2Check=objThis.value; var NoError=true; if (!Val2Check.match(ActualRegExpr)) NoError=false; if(!NoError){ if(ShowAlert){alert(pMessage);} if(SetFocus){hndEvent.returnValue=false; objThis.focus();} } return NoError;}
function fnCheckValidations()
{
    var hndFRM = document.frmLogin;
    if(isBlank(Trim(hndFRM.txtMemberUsername.value))) {
        alert("Please enter username to login");
        hndFRM.txtMemberUsername.focus();
        return false;
    }
    if(isBlank(Trim(hndFRM.txtMemberPassword.value))) {
        alert("Please enter password to login");
        hndFRM.txtMemberPassword.focus();
        return false;
    }    
    return true;
}
function fnPriceType()
{
    var price_type= document.frmProduct.price_type.value;
    if(price_type == 2) {
       document.frmProduct.vary_price.disabled=false;
       document.frmProduct.formula.disabled=false;
       document.frmProduct.price.disabled=true;
    }
    else {
       document.frmProduct.vary_price.disabled=true;
       document.frmProduct.formula.disabled=true;
       document.frmProduct.price.disabled=false;
    }
}
function fnVaryPrice()
{
     var vary_price= document.frmProduct.vary_price.value;   
     switch(vary_price) {         
        case '1':  
                 document.getElementById("div_vary_price").innerHTML="Note: You need to $GOLD variable in price formula to evaluate product price"; 
                 break;
        case '2':  
                 document.getElementById("div_vary_price").innerHTML="Note: You need to $SILVER variable in price formula to evaluate product price";  
                 break;
        case '3':  
                 document.getElementById("div_vary_price").innerHTML="Note: You need to $PLATINUM variable in price formula to evaluate product price";
                 break;    
        case '4':  
                 document.getElementById("div_vary_price").innerHTML="Note: You need to $PALLADIUM variable in price formula to evaluate product price";  
                 break;  
        default: document.getElementById("div_vary_price").innerHTML="";
     }
}
var xmlHttp
function GetXmlHttpObject()
{
    var xmlHttp=null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}
function showHint(str)
{   
    xmlHttp=GetXmlHttpObject();      
    var url="getProducts.php";
    url=url+"?q="+str;          
    xmlHttp.onreadystatechange=displayHint;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function displayHint() 
{
    if (xmlHttp.readyState==4){         
        ShowDiv("autocomplete");
        document.getElementById("autocomplete").innerHTML ='<div onclick="javascript:setSearch(this.innerHTML);" style="CURSOR: url(custom.cur), pointer;">Early Release 2007-W</div><br><div onclick="javascript:setSearch(this.innerHTML);" style="CURSOR: url(custom.cur), pointer;">3pc Gold Set MS/PF69</div>';
    }
}
function showHintPackage(str)
{   
    xmlHttp=GetXmlHttpObject();      
    var url="getProducts.php";
    url=url+"?q="+str;          
    xmlHttp.onreadystatechange=displayHintPackage;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function displayHintPackage() 
{ 
    if (xmlHttp.readyState==4) {         
        ShowDiv("autocomplete");
        document.getElementById("autocomplete").innerHTML ='<div onclick="javascript:setSearch(this.innerHTML);" style="CURSOR: url(custom.cur), pointer;">Early Release 2007-W</div><br><div onclick="javascript:setSearch(this.innerHTML);" style="CURSOR: url(custom.cur), pointer;">3pc Gold Set MS/PF69</div><br><div onclick="javascript:setSearch(this.innerHTML);" style="CURSOR: url(custom.cur), pointer;">Gold Eagles</div><br><div onclick="javascript:setSearch(this.innerHTML);" style="CURSOR: url(custom.cur), pointer;">Silver Eagles</div>';
    }
}
function setSearch(value) {    
    document.getElementById('product').value = value;
    document.getElementById('autocomplete').innerHTML = '';
    document.getElementById('autocomplete').style.visibility="hidden";     
}
function ShowDiv(divid)
{
   if (document.layers) document.layers[divid].visibility="show";
   else document.getElementById(divid).style.visibility="visible";
}
function HideDiv(divid)
{
   if (document.layers) document.layers[divid].visibility="hide";
   else document.getElementById(divid).style.visibility="hidden";
}
function showEdit()
{
    document.frmProduct.quantity.value=1;
    document.frmProduct.product.value="Early Release 2007-W Silver Eagle MS69 NGC";
    document.frmProduct.addproduct.value="Edit";       
}
function showEdit2(id)
{
    if(id==1) {
        document.frmProduct.quantity.value=10;
        document.frmProduct.product.value="Early Release 2007-W Silver Eagle MS69 NGC";
        document.frmProduct.addproduct.value="Edit";       
    }
    else {
        document.frmProduct.quantity.value=15;
        document.frmProduct.product.value="Certified 2006 20th Anniversary 3pc Gold Set MS/PF69";
        document.frmProduct.addproduct.value="Edit";
    }
}
function showEditOrder(id)
{
    if(id==1) {
        document.frmProduct.quantity.value=2; 
        document.frmProduct.rate.value=50;
        document.frmProduct.product.value="Early Release 2007-W Silver Eagle MS69 NGC";
    }
    else {
        document.frmProduct.quantity.value=4; 
        document.frmProduct.rate.value=20;
        document.frmProduct.product.value="Certified 2006 20th Anniversary 3pc Gold Set MS/PF69";
    }    
    document.frmProduct.addproduct.value="Edit";
}
function showDelete()
{
    document.frmProduct.quantity.value="";
    document.frmProduct.product.value="";
    document.frmProduct.addproduct.value="Add";
    document.getElementById('productlist').style.visibility='hidden';
    document.getElementById('tid').style.visibility='hidden';
}
function showDeleteOrder()
{
    document.frmProduct.quantity.value="";
    document.frmProduct.rate.value="";
    document.frmProduct.product.value="";
    document.frmProduct.addproduct.value="Add";
    document.getElementById('productlist').style.visibility='hidden';
    document.getElementById('trid').style.display='none'; 
}
function showCreditFields(payment)
{
    if(payment==5) {
         document.frmProduct.credit_expire_year.disabled=false;
         document.frmProduct.credit_expire_month.disabled=false;
         document.frmProduct.card_type.disabled=false;
         document.frmProduct.credit_num.disabled=false;
    }
    else {
         document.frmProduct.credit_expire_year.disabled=true;
         document.frmProduct.credit_expire_month.disabled=true;
         document.frmProduct.card_type.disabled=true;
         document.frmProduct.credit_num.disabled=true;
    }
}
function ShowuspsId(id)
{
    if(id==4) {    
        document.frmProduct.uspsid.disabled=false; 
    }
    else {
        document.frmProduct.uspsid.disabled=true; 
    }
}
function ShowTrackId(id)
{
    if(id==4) {    
        document.frmSearch.trackid.disabled=false; 
    }
    else {
        document.frmSearch.trackid.disabled=true; 
    }
}
function fnsubscribe(subscribe)
{
    if(subscribe==1) {
       document.getElementById('sbAddress1').disabled=true;
       document.getElementById('sbAddress2').disabled=true;
       document.getElementById('sbCity1').disabled=true;
       document.getElementById('sbState1').disabled=true;
       document.getElementById('sbZip1').disabled=true;
    
       document.getElementById('addressDiv').style.display='none';
       document.getElementById('address2Div').style.display='none';
       document.getElementById('cityDiv').style.display='none';
       document.getElementById('stateDiv').style.display='none';
       document.getElementById('zipDiv').style.display='none';
    }
    else {
       document.getElementById('sbAddress1').disabled=false;
       document.getElementById('sbAddress2').disabled=false;
       document.getElementById('sbCity1').disabled=false;
       document.getElementById('sbState1').disabled=false;
       document.getElementById('sbZip1').disabled=false;
    
       document.getElementById('addressDiv').style.display='';
       document.getElementById('address2Div').style.display='';
       document.getElementById('cityDiv').style.display='';
       document.getElementById('stateDiv').style.display='';
       document.getElementById('zipDiv').style.display='';
    }
}
function fnCreateAccount()
{
    var frm=document.getElementById('frmAccount');
    if(isBlank(frm.txtFirstname.value)) {
        alert("Please Enter First Name.");
        frm.txtFirstname.focus();
        return false;
    }
    if(isBlank(frm.txtLastname.value)) {
        alert("Please Enter Last Name.");
        frm.txtLastname.focus();
        return false;
    }
    if(isBlank(frm.txtEmailId.value)) {
        alert("Please Enter Email Id.");
        frm.txtEmailId.focus();
        return false;
    }
    if(checkEmail(frm.txtEmailId)==false) {
        alert("Please Enter Valid Email Id.");
        frm.txtEmailId.focus();
        return false;
    }
    if(isBlank(frm.txtPassword1.value)) {
        alert("Please Enter Password.");
        frm.txtPassword1.focus();
        return false;
    }
    if((frm.txtPassword1.value.length < 6) ||  (frm.txtPassword1.value.length > 10)) {
        alert("Password must be minimum 6 and maximum 10 characters long.");
        frm.txtPassword1.focus();
        return false;
    }
    if(isBlank(frm.txtPassword2.value)) {
        alert("Please Re-Type Password.");
        frm.txtPassword2.focus();
        return false;
    }
    if((frm.txtPassword2.value.length < 6) ||  (frm.txtPassword2.value.length > 10)) {
        alert("Password must be minimum 6 and maximum 10 characters long.");
        frm.txtPassword2.focus();
        return false;
    }
    if(frm.txtPassword1.value != frm.txtPassword2.value) {
        alert("Password and Re-typed password does not match.");
        frm.txtPassword1.focus();
        return false;
    }
    if(isBlank(frm.txtPhone.value)) {
        alert("Please Enter Phone Number.");
        frm.txtPhone.focus();
        return false;
    }
    if(isBlank(frm.txtAddress.value)) {
        alert("Please Enter Address.");
        frm.txtAddress.focus();
        return false;
    }
    if(isBlank(frm.txtCity.value)) {
        alert("Please Enter City.");
        frm.txtCity.focus();
        return false;
    }
    if(isBlank(frm.intState.value)) {
        alert("Please Select State.");
        frm.intState.focus();
        return false;
    }
    if(isBlank(frm.txtZip.value)) {
        alert("Please Enter Zip Code.");
        frm.txtZip.focus();
        return false;
    } 
    if(frm.intAgreementCheck.checked==false) {
        alert("You must agree to terms and conditions.");    
        return false;    
    }
}
function fnGetStates(country)
{   
    xmlHttp=GetXmlHttpObject();      
    var url="getStates.php";
    url=url+"?c="+country;          
    xmlHttp.onreadystatechange=displayStates;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function displayStates() 
{   
    if (xmlHttp.readyState==4) {   
        document.getElementById("divState").innerHTML=xmlHttp.responseText;        
    }
}

function fnSubscribeFor()
{
    var frm=document.getElementById("frmSubscribe");
    if(isBlank(frm.firstname.value)) {
        alert("Please Enter First Name.");
        frm.firstname.focus();
        return false;
    }
    if(isBlank(frm.lastname.value)) {
        alert("Please Enter Last Name.");
        frm.lastname.focus();
        return false;
    }
    if(isBlank(frm.emailid.value)) {
        alert("Please Enter Email Id.");
        frm.emailid.focus();
        return false;
    }
    if(checkEmail(frm.emailid)==false) {
        alert("Please Enter Valid Email Id.");
        frm.emailid.focus();
        return false;
    }
    if((frm.subscribefor.value == 2) || (frm.subscribefor.value == 3)) {
        if(isBlank(frm.address.value)) {
            alert("Please Enter Address.");
            frm.address.focus();
            return false;
        }
        if(isBlank(frm.city.value)) {
            alert("Please Enter City.");
            frm.city.focus();
            return false;
        }
        if(isBlank(frm.state.value)) {
            alert("Please Select State.");
            frm.state.focus();
            return false;
        }
        if(isBlank(frm.zip.value)) {
            alert("Please Enter Zip.");
            frm.zip.focus();
            return false;
        }
    }  
}
function fnUnSubscribeFor()
{
    var frm=document.getElementById("frmSubscribe");
    if(isBlank(frm.emailid.value)) {
        alert("Please Enter Email Id.");
        frm.emailid.focus();
        return false;
    }
    if(checkEmail(frm.emailid)==false) {
        alert("Please Enter Valid Email Id.");
        frm.emailid.focus();
        return false;
    } 
}

/**************************************
* - Used For Checkout Step #1 Validation 
* - Created By Komal Patel 
* - On Date 16-09-2008 
***************************************/				  
function fnvalidate()
{
    var frm = document.getElementById('frmCheckout1');
    e =  document.getElementById('detailsdiv');
    var srtMsg = "";
	if (e.style.display == "block")	{
        alert("Plese Click on Use This Address Link or Click Hide Link.");
        return false;
	}
	else {
        return true;	
	}			
}

function fnDeleteItem()
{
    var frm=document.getElementById('frmCart');  
    var checkedOptions=new Array();
    var j=0; 
    for (var i=0;i<frm.elements.length;i++) {
        var e = frm.elements[i];
        if (e.type=='checkbox') {
            if (e.checked) {    
                checkedOptions[j]=e.value;
                j++;
            }  
        }
    } 
    if(checkedOptions.length==0) {
        alert("You need to select atleast one item.");
        return false;
    }
    else {
        if (confirm("Are you sure you want to delete")) {
            var passOptions=checkedOptions.join("_");
            frm.selProducts.value=passOptions;
        }
    }     
}

/********************************
* - Used For New Style Check out  
* -  delete Items 
* - Created By Komal Patel 
* - On Date 09-04-2008 
********************************/
function fnDeleteItem1(intId)
{
    var frm=document.getElementById('frmCart');  
    var checkedOptions=new Array();
    var j=0; 
    checkedOptions[j]=intId;
    if(checkedOptions.length==0) {
        alert("You need to select atleast one item.");
        return false;
    }
    else {
		if (confirm("Are you sure you want to delete")) {
            var passOptions=checkedOptions.join("_");
            frm.selProducts.value=passOptions;
		}
        else
            return false;
    }
}

/** Used For Pagination
* - Created By Komal Patel 
* - On Date 08-04-2008 
**/
function fnPagination(form_name,form_action)
{
    document.getElementById(form_name).action=form_action;
    document.getElementById(form_name).submit();   
}

/******************************
* - Used For Recommend Page 
* - Created By Komal Patel 
* - On Date 09-04-2008 
******************************/
function fnValidateRecommend()
{
	var frm = document.getElementById("frmRecommend");
    if(isBlank(frm.txtYname.value)) {
        alert("Please Enter Your Name.");
        frm.txtYname.focus();
        return false;
    }
    if(isBlank(frm.txtYEmail.value)) {
        alert("Please Enter Your Email.");
        frm.txtYEmail.focus();
        return false;
    }
    if(checkEmail(frm.txtYEmail)==false) {
         alert("Your Email Id is not valid.\n\rPlease Enter Valid Email Id.");
         frm.txtYEmail.focus();
         return false;
    }
    if(isBlank(frm.txtFname.value)) {
        alert("Please Enter Your Friend's Name.");
        frm.txtFname.focus();
        return false;
    }
    if(isBlank(frm.txtFEmail.value)) {
        alert("Please Enter Your Friend's Email.");
        frm.txtFEmail.focus();
        return false;
    }
    if(checkEmail(frm.txtFEmail)==false) {
         alert("Friend's Email Id is not valid.\n\rPlease Enter Valid Email Id.");
         frm.txtFEmail.focus();
         return false;
    }  
}
function fnResetText()
{
    var frm = document.getElementById("frmSearchBox");     
    frm.productName.value="";     
}
function fnSearchText(val)
{
   var frm = document.getElementById("frmSearchBox");     
   if(frm.productName.value=='')
        frm.productName.value=val;  
}

/******************************
* - Used For Pagination Class
* - Created By Komal Patel 
* - On Date 14-04-2008
******************************/
function redirect(var1)
{
    var str1 = var1.split('?');        		
    var str = var1.split('=');    
    frmName = str1[0];
    document.getElementById("currentPage").value=str[1];
    document.getElementById(frmName).submit();
}//end function redirect()

/******************************
* - Used For Add to Cart PopUp Window
* - Created By Komal Patel - On Date 15-04-2008 
* - Updated by Aadesh Gharpure on 23 March 2009
* - Purpose: Updates in shopping cart process. For inventoty products site was allowing user to add invalid quatity to cart
******************************/
function fnAddToCart(ProductId,Price,MaxAvail,Inventory)
{
    var intqty = document.getElementById('qty-'+ProductId).value;
    var strHostName = window.location.hostname;
    //when we use window.location it's not return string so please use
    //var url =""+window.location;
    //added by aadesh on 22 Dec 2008
    //purpose: to allow complete numbers only
    var isValid = false;
    var numbersCheckRegExp = /[^\d]/;
    isValid = !numbersCheckRegExp.test(intqty);
    if(intqty == "") {
        alert('Please enter Product Quantity.');
        return false;
    }
    if(intqty <= 0) {
	    alert("Product Quqantity should be a positive numeric value.");
    }
    else if(!isValid) {
	    alert("Please Enter Valid Product Quantity value.");
	    return false;	
    }
    else if (!isNaN(intqty) ) {		
        if ((eval(intqty) > eval(MaxAvail)) && (MaxAvail != 0 || MaxAvail != '0') ) {              
            alert("We currently have " + MaxAvail + " of this item in stock.");
	    }	
        else if (MaxAvail == 0 && Inventory=="1") {
            alert("You already have selected maximum possible quantity of this item");
        }
        else {		   
            if(Price!="") {	
	            showPopWin('http://'+strHostName+'/addtocart.php?ProductID='+ProductId+'&Price='+Price+'&Qty='+intqty+'&Inventory='+Inventory, 400, 150, null);
            }
            else {
	            var type = document.getElementById('ptype').value;
	            showPopWin('http://'+strHostName+'/addtocart.php?ProductID='+ProductId+'&Qty='+intqty+'&ptype='+type+'&Inventory='+Inventory, 400, 150, null);
            }
        } 
    }
}//end function fnAddToCart()

/******************************
* - Used to validate update quantity in checkout process
* - Created By Aadesh Gharpure 
* - On Date 22 Dec 2008
******************************/
function fnUpdateQuantity(ProductId)
{
	var intqty = document.getElementById('qty-'+ProductId).value;
	var isValid = false;
	var numbersCheckRegExp = /[^\d]/;
	isValid = !numbersCheckRegExp.test(intqty);
    if(isBlank(intqty)) {
        alert("Please Enter Product Quantity");
        return false;
    }
    if(intqty != "" && (!isValid)) {
			alert("Please Enter Valid Product Quantity value.");
			return false;	
	}
	if(intqty != "" && intqty <= 0) {
			alert("Product Quqantity should be a positive numeric value.");
			return false;
	}
}//fnUpdateQuantity

/******************************
* - Used For Redirect page from
*   the Check out Light Box
* - Created By Komal Patel 
* - On Date 15-04-2008
******************************/
function fnRedirectpage(strUrl,ProductId,QTY,Price,Type,Inventory)
{		
    fnUpdateCartBox(strUrl,ProductId,QTY,Price,Type,Inventory);
}

/***********************************
* - Used For Updating the right Top
*	Light Box.
* - Created By Komal Patel 
* - On Date 16-04-2008 
************************************/ 
function fnUpdateCartBox(strUrl,ProductId,QTY,Price,Type,Inventory)
{
	var strHostName = window.location.hostname;
    xmlHttp=GetXmlHttpObject();
    var url=window.location.protocol+"//"+strHostName+"/updCart.php";
    if(xmlHttp) {
        url=url+"?id="+ProductId+"&qty-"+ProductId+"="+QTY+"&price="+Price+"&ptype="+Type;  	 	 
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange = function() //function to be called on every state change event
		{
    		if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
				var strResult = xmlHttp.responseText;   		
   				document.getElementById("cart").innerHTML=strResult;  
   				if(strUrl == 'http://'+strHostName+'/updCart.php' ) {
   				    window.parent.hidePopWin(false);
                    if(Inventory=="1") {
                        var tempVal=window.parent.document.getElementById('inventoryQty-'+ProductId).value-QTY;
                        window.parent.document.getElementById('inventoryQty-'+ProductId).value=tempVal;
                    }
   				}
   				else if(strUrl == 'https://'+strHostName+'/shoppingcart.php') {	
                    var Url = strUrl+"?id="+ProductId+"&qty-"+ProductId+"="+QTY;
					location.replace(Url);
				}
			}//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )
		}//end  xmlHttp.onreadystatechange = function()
		xmlHttp.send(null);
	}//end  if(xmlHttp)   
}//end function fnUpdateCartBox(strUrl,ProductId,QTY,Price)

//Java Script of Member user's
function fnValCreditCard(intMethod)
{
    var dateObj=new Date();
    var currentMonth = dateObj.getMonth(); 
    var currentYear = dateObj.getFullYear();
    var frm=document.getElementById("frmCheckout2");

	 if(intMethod != 6 ) {
        if(isBlank(frm.credit_num.value)) {
            alert("Please Enter Credit Card Number.");
            return false;
        }
        if (checkCreditCard(frm.credit_num.value,frm.card_type.value)==false) {
            alert(ccErrors[ccErrorNo]);
            return false;
        }
        if(frm.expireyear.value < currentYear) {
	        alert("This card has already expired."); 
	        return false;
        }
        else if(frm.expireyear.value==currentYear) {
	        if(frm.expiremonth.value < currentMonth) {
		        alert("This card has already expired.");
		        return false;
	        }
        }
        //Added by komal Patel Date: 07-July-2008
        if(isBlank(frm.card_code.value)) {
            alert("Please Enter Security Code.");
            return false;
        }
	 } //End if(intMethod == 5 )
	 else {
		 if(isBlank(frm.Paypal_UserName.value)) { 
			alert("Please Enter Paypal User ID.");     
			return false;
		 }
	 }
}
function fnNewAddress()
{
    var hndFRM = document.getElementById('frmAddress'); 
    for (var i = 0; i < hndFRM.address.length; i++) {
        if (hndFRM.address[i].checked == true) {
            addressval = hndFRM.address[i].value;
            break;
        }
    }
    if(addressval=='add') {
        if(isBlank(hndFRM.txtAddress.value)) {
              alert("Please enter address.");
              hndFRM.txtAddress.focus();
              return false;
        }
        if(isBlank(hndFRM.txtCity.value)) {
              alert("Please enter city.");
              hndFRM.txtCity.focus();
              return false;
        }
        if(isBlank(hndFRM.intState.value)) {
              alert("Please enter state.");
              hndFRM.intState.focus();
              return false;
        }
        if(isBlank(hndFRM.txtZip.value)) {
              alert("Please enter zip code.");
              hndFRM.txtZip.focus();
              return false;
        }
    }
}
function submitForm()
{
    document.getElementById('frmSub').submit();
}
function fnForgotPassword()
{
    var frm=document.getElementById("frmForgot");
    if(isBlank(frm.txtFEmail.value)) {
        alert("Please Enter Email Id.");
        frm.txtFEmail.focus();
        return false;
    }
    if(checkEmail(frm.txtFEmail)==false) {
        alert("Please Enter Valid Email Id.");
        frm.txtFEmail.focus();
        return false;
    }
}
function fnChangePassword()
{
   var frm=document.getElementById('frmChgPass');
   if(isBlank(frm.txtOldPassword.value)) {
        alert("Enter Old Password");
        frm.txtOldPassword.focus();
        return false;
   }
   if(isBlank(frm.txtPassword1.value)) {
        alert("Enter New Password");   
        frm.txtPassword1.focus();
        return false;
   }
   if(frm.txtPassword1.value.length<6 || frm.txtPassword1.value.length>10) {
        alert("Password should be minimum 6 or maximum 10 characters.");
        frm.txtPassword1.focus();
        return false;
   }
   if(isBlank(frm.txtPassword2.value)) {
        alert("Re Enter New Password");
        frm.txtPassword2.focus();
        return false;
   }
   if(frm.txtPassword2.value.length<6 || frm.txtPassword2.value.length>10) {
        alert("Password should be minimum 6 or maximum 10 characters.");
        frm.txtPassword2.focus();
        return false;
   }
   if(frm.txtPassword1.value != frm.txtPassword2.value) {
       alert("New Password Does Not Match Re Typed Password.");
       frm.txtPassword2.focus();
       return false;
   }
}
function fnMemberAddress()
{
    var hndFRM = document.getElementById('frmAddress'); 
    if(isBlank(hndFRM.txtAddress.value)) {
        alert("Please enter address.");
        hndFRM.txtAddress.focus();
        return false;
    }
    if(isBlank(hndFRM.txtCity.value)) {
        alert("Please enter city.");
        hndFRM.txtCity.focus();
        return false;
    }
    if(isBlank(hndFRM.txtZip.value)) {
        alert("Please enter zip code.");
        hndFRM.txtZip.focus();
        return false;
    }
}
function fnMemberProfile()
{
    var hndFRM = document.getElementById('frmProfile');
    if(isBlank(Trim(hndFRM.firstname.value))) {
        alert("Please enter firstname");
        hndFRM.firstname.focus();
        return false;
    }
    if(isBlank(Trim(hndFRM.lastname.value))) {
        alert("Please enter lastname");
        hndFRM.lastname.focus();
        return false;
    }
}
function fnValidateTestimonial()
{
    var hdnfRM = document.getElementById('frmTestimonial');
    if(isBlank(Trim(hdnfRM.txtName.value))) {
        alert("Please enter first & last name");
        hdnfRM.txtName.focus();
        return false;
    }
    if(isBlank(Trim(hdnfRM.txtTown.value))) {
        alert("Please enter Hometown");
        hdnfRM.txtTown.focus();
        return false;
    }
    if(isBlank(Trim(hdnfRM.txtMail.value))) {
        alert("Please enter Email ID");
        hdnfRM.txtMail.focus();
        return false;
    }
    if(checkEmail(hdnfRM.txtMail)==false) {
        alert("Your Email Id is not valid.\n\rPlease Enter Valid Email Id.");
        hdnfRM.txtMail.focus();
        return false;
    }
    if(isBlank(hdnfRM.code.value)) {
        alert("Please Enter Code.");
        hdnfRM.code.focus();
        return false;
    }
}

/***********************************
* - Used For Prosuct Search Category 
	List Box.
* - Created By Komal Patel 
* - On Date 02-07-2008 
***********************************/ 
function fnGetSubCat(intVal)
{
    var strHostName = window.location.hostname;
    var intHidParent = document.getElementById('IntParentID').value;
    var intSelectedVal =  document.getElementById('IntSelectedCat').value;
    if(intHidParent != intVal) {			
	    intParentCate = document.getElementById('Category')[0].value;			
	    document.getElementById('IntParentID').value = intParentCate;	
    }
    xmlHttp=GetXmlHttpObject();
    var url=window.location.protocol+"//"+strHostName+"/getProductSubCategory.php";
    if(xmlHttp) {
        url=url+"?catId="+intVal;
        if(intSelectedVal!= "") {	
            url=url+"&subcat="+intSelectedVal; 
        }
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange = function() //function to be called on every state change event
        {
            if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
		        var strResult = xmlHttp.responseText;   		
		        if(strResult != "")
   			          document.getElementById("srcCategory").innerHTML=strResult;  
	        }//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )   	
        }//end  xmlHttp.onreadystatechange = function()
        xmlHttp.send(null);
    }//end  if(xmlHttp)
}//end function fnGetSubCat()

/***********************************
* - Used For on-off Next Arrow Image
  - in form pages
* - Created By Komal Patel 
* - On Date 23-08-2008 
***********************************/ 
function fnShowImg(intId)
{
    var list = document.getElementsByTagName("input");	
    for (var i = 1; i < (list.length)+2; i++) { 	
	    if(document.getElementById('cont_img'+[i])) {
			    document.getElementById('cont_img'+[i]).style.visibility = 'hidden'; 
		 	    document.getElementById('cont_img'+[i]).style.marginLeft = "0px";
	    }
    }//end fir	
    document.getElementById(intId).style.visibility = 'visible';
    document.getElementById(intId).style.marginLeft = '12px';
}//end function fnShowImg(intId)

/*************************************
* - Used For  Static Pages Validation
* - Created By Komal Patel 
* - On Date 08-08-2008 
**************************************/
function fnValidateContent()
{
    var frm=document.getElementById("frmContent");
    if(isBlank(frm.txtContentTitle.value)) {
        alert("Please Content Title.")
        frm.txtContentTitle.focus()
        return false;
    }
	tinyMCE.execCommand("mceCleanup");
	tinyMCE.triggerSave();
	if (tinyMCE.getContent() == "" || tinyMCE.getContent() == null)	{
		alert("Please Enter Content.")
        return false;
	}
	if(isBlank(frm.selDispAt.value)) {
        alert("Where you want to display Content?")
        frm.selDispAt.focus()
        return false;
     }  
}//end function fnValidateMail(frm)

/***********************************
* - Used For Track order 
  - Validation form
* - Created By Komal Patel 
* - On Date 25-08-2008 
***********************************/
function fnValidateOrder()
{
    var frm = document.frmTrackOrder;
    if(isBlank(Trim(frm.ordernumber.value))) {
        alert("Please Enter Order Number.");
        frm.ordernumber.focus();
        return false;
    }
} //End function fnValidateOrder()

/**************************************
* - Used For Reset Product search form
* - Created By Komal Patel 
* - On Date 25-08-2008 
***************************************/	
function fnreserform()
{
    var frm = document.productsearch;
    frm.productName.value = "";
    frm.coinDate.value = "";
    frm.priceFrom.value = "";
    frm.priceTo.value = "";
    frm.coinType.value = "";
    frm.Category.value = "";
    fnGetSubCat('ALL');
}

/***********************************
* - Used For Product Search 
  - Validation form
* - Created By Komal Patel 
* - On Date 28-07-2008 
***********************************/
function fnValidatePSearch()
{
    var frm = document.getElementById('productsearch'); var returnFlag=0;
    if(isBlank(Trim(frm.productName.value)) && isBlank(Trim(frm.coinDate.value)) && isBlank(Trim(frm.priceFrom.value)) && isBlank(Trim(frm.priceTo.value)) && isBlank(Trim(frm.coinType.value)) && isBlank(Trim(frm.Category.value))) {
        returnFlag = 1;
    }
    if(returnFlag == 1) {
        alert("You need to select atleast one item.");
        return false;
    }
    else {
        return true;
    }
}//end function fnValidatePSearch(frm)

/**************************************
* - Used For allow only numerix value 
* - into Add to cart.
* - Created By Komal Patel 
* - On Date 11-09-2008 
***************************************/
function numbersonly(e){
    var unicode=e.charCode? e.charCode : e.keyCode
    if (unicode!=8 && unicode!=13 && unicode!=46  ){ //if the key isn't the backspace key  or Enter Key (which we should allow)
        if ( unicode<48 || unicode>57 || unicode==46) //if not a number
            return false //disable key press
    }
}

/**************************************
* - Used For Checkout Step #1 Validation 
* - Created By Komal Patel 
* - On Date 16-09-2008 
***************************************/				  
function fnvalidate()
{
    var frm = document.getElementById('frmCheckout1');
    e =  document.getElementById('detailsdiv');
    var srtMsg = "";
	if (e.style.display == "block")	{
        if(isBlank(frm.txtShipName.value)) {
	        alert('Enter Shipping Name.');
	        frm.txtShipName.focus();
	        return false;
        }
        if(isBlank(frm.txtShipAddress.value)) {
	        alert('Enter Shipping Addrress.');
	        frm.txtShipAddress.focus();
	        return false;
        }
        if(isBlank(frm.txtShipCity.value)) {
	        alert('Enter Shipping City.');
	        frm.txtShipCity.focus();
	        return false;
        }
        if(isBlank(document.getElementById('txtShipState').value)) {
	        alert('Enter Shipping State.');	
	        document.getElementById('txtShipState').focus();
	        return false;
        }
        if(isBlank(frm.txtShipZip.value)) {
	        alert('Enter Shipping Zipcode.');
	        frm.txtShipZip.focus();
	        return false;
        }
        return true;
	}
}
function showhide(CurrentId, DisplayId)
{
    document.getElementById(CurrentId).style.visibility="hidden";    
    document.getElementById(DisplayId).style.visibility="visible";    
}
function fnshowDiv(CurrentId, DisplayId)
{
    document.getElementById(CurrentId).style.display="none";    
    document.getElementById(DisplayId).style.display="block";    
    return false;
}

/**************************************
* - Used For ListView Category detail 
* - Create Cart Array
* - Created By Komal Patel 
* - On Date 23-09-2008 
***************************************/		
function fnListViewCart(e,ProductId,MaxAvail)
{	
    var unicode=e.charCode? e.charCode : e.keyCode		
    if (unicode!=8 && unicode!=13 && unicode!=46  ) { //if the key isn't the backspace key  or Enter Key (which we should allow)
        if ( unicode<48 || unicode>57 || unicode==46) { //if not a number
	        return false //disable key press
        }
        else {
            var intqty = document.getElementById('qty-'+ProductId).value;					
            if(unicode<=48) {
	            alert("Product Quantity should be a positive numeric value.");
	            document.getElementById('qty-'+ProductId).value = "";
	            return false;
            }// End if(intqty <= 0)
            else if (!isNaN(intqty) )  {
	            if (intqty > MaxAvail && (MaxAvail != 0 || MaxAvail != '0') ) {
			            alert("We currently have " + MaxAvail + " of this item in stock.");
			            document.getElementById('qty-'+ProductId).value = "";
			            return false;
		        }
            } // End else if (!isNaN(intqty) )
        }	//End else
    } //End if ( unicode<48 || unicode>57 || unicode==46) //if not a number
}//End function fnupdCart(e,ID,price,MaxAvail)

/**************************************
* - Used For ListView Category detail 
* - add to cart
* - Created By Komal Patel 
* - On Date 23-09-2008 
***************************************/		
function fnListViewAddToCart()
{
	var strVal= "";
	var strHostName = window.location.hostname;
	var cnt = 0;
	var intHeight = 200;
 	var elem = document.getElementById('frmListCategory').elements;
	for(var i = 0; i < elem.length; i++) {
		if(elem[i].type == 'text') {
			  intVal = elem[i].value;
			  if(intVal != "") {
				 strName = elem[i].name;			
				 intProductID = strName.split("qty-");
				 strVal += intProductID[1]+'**'+intVal+'|';
				 elem[i].value = "";
				 cnt++;
			  }	//End 	if(intVal != "")
		} //End if(elem[i].type == 'text')
	} //End for

    strUrl = 'http://'+strHostName+'/addtocart.php?strQuery='+strVal;
	if(cnt > 5) { intHeight = intHeight + (cnt*5);}
	showPopWin(strUrl, 500, intHeight, null);
	return false;
}

/***********************************
* - Used For Updating the right Top
*	Light Box.
* - Created By Komal Patel 
* - On Date 24-09-2008 
***********************************/ 
function fnUpdateRightCartBox(strUrl,strQuery)
{   
	var strHostName = window.location.hostname;
    xmlHttp=GetXmlHttpObject(); 
    var url=window.location.protocol+"//"+strHostName+"/updCart.php";  
    if(xmlHttp) {
        url=url+"?strQuery="+strQuery; 
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange = function() //function to be called on every state change event
        {
            if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
		        var strResult = xmlHttp.responseText;   		
   		        document.getElementById("cart").innerHTML=strResult;  
   		        if(strUrl == 'http://'+strHostName+'/updCart.php' ) {
   			        window.parent.hidePopWin(false);
   		        }
   		        else if(strUrl == 'https://'+strHostName+'/shoppingcart.php') {	
			        var Url = strUrl;
			        location.replace(Url);
		        }   				    
	        }//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )   	
		}//end  xmlHttp.onreadystatechange = function()
		xmlHttp.send(null);
	}//end  if(xmlHttp)   
}//end function fnUpdateCartBox(strUrl,ProductId,QTY,Price)

/*************************************
* - Used For Updating Select Shipping
* - address at Check Out Process
* - Created By Komal Patel 
* - On Date 24-09-2008 
*************************************/ 
function fnSetShipAddr(OpenDiv,CloseDiv,replaceDIV,intMemberID,intVal)
{
    var strHostName = window.location.hostname;
    xmlHttp=GetXmlHttpObject(); 
    var url="https://"+strHostName+"/member/DisplayShippingAddress.php";  
    if(intVal != " ") { 	   	
        url=url+"?MID="+intMemberID+"&shipID="+intVal; 
    }
    else if(intVal == " ") {
        var frm = document.getElementById('frmCheckout1');
		e =  document.getElementById('detailsdiv');
		var srtMsg = "";
        if (e.style.display == "block") {
            if(isBlank(frm.txtShipName.value)) {
	            alert('Enter Shipping Name.');
	            frm.txtShipName.focus();
	            return false;
            }
            else {
                txtShipName = frm.txtShipName.value;
                frm.txtShipName.value = "";
            }
            if(isBlank(frm.txtShipAddress.value)) {
	            alert('Enter Shipping Addrress.');
	            frm.txtShipAddress.focus();
	            return false;
            }
            else {
                txtShipAddress = frm.txtShipAddress.value;
                txtShipAddress1 = frm.txtShipAddress1.value;
                frm.txtShipAddress.value = "";
                frm.txtShipAddress1.value = "";
            }
            if(isBlank(frm.txtShipCity.value)) {
	            alert('Enter Shipping City.');
	            frm.txtShipCity.focus();
	            return false;
            }
            else {
                txtShipCity = frm.txtShipCity.value;
                frm.txtShipCity.value="";
            }
            if(isBlank(document.getElementById('txtShipState').value)) {
	            alert('Enter Shipping State.');	
	            document.getElementById('txtShipState').focus();
	            return false;
            }
            else {
                txtShipState = document.getElementById('txtShipState').value;
                document.getElementById('txtShipState').value  = "";
            }
            if(isBlank(frm.txtShipZip.value)) {
	            alert('Enter Shipping Zipcode.');
	            frm.txtShipZip.focus();
	            return false;
            }
            else {
              txtShipZip = frm.txtShipZip.value;
              frm.txtShipZip.value = "";
            }
        } //End (e.style.display == "block")
        url+="?MID="+intMemberID+"&SName="+txtShipName+"&SAddr="+txtShipAddress+"&SAddre1="+txtShipAddress1+"&SCity="+txtShipCity+"&State="+txtShipState+"&SZip="+txtShipZip;		
	}//ENd Else
    if(xmlHttp) {
		xmlHttp.open("GET",url,true);
    	xmlHttp.onreadystatechange = function() //function to be called on every state change event
		{
    		if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
                var strResult = xmlHttp.responseText;			  
                document.getElementById(replaceDIV).innerHTML=strResult;  
                document.getElementById(OpenDiv).style.display="none";    
                document.getElementById(CloseDiv).style.display="block";  
                return false;			    
			}//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )   	
		}//end  xmlHttp.onreadystatechange = function()
		xmlHttp.send(null);
    }//end  if(xmlHttp)
}// End function fnSetShipAddr()

/*************************************
* - Used For Shopping cart page Login
* - Created By Komal Patel 
* - On Date 07-10-2008 
*************************************/ 
function frmChkLogin()
{
	var hndFRM = document.getElementById('frmCheckOutLogin');
	var strHostName = window.location.hostname;
	var hostUrl=window.location.protocol+"//"+strHostName+"/";
	var strNew =  hndFRM.rdFlag[0].checked;
	var strOld  = hndFRM.rdFlag[1].checked;
    if(isBlank(Trim(hndFRM.txtMemberUsername.value))) {
        alert("Please enter username to login");
        hndFRM.txtMemberUsername.focus();
        return false;
    }
    if(checkEmail(hndFRM.txtMemberUsername)==false) {
        alert("Please Enter Valid Email Id.");
        hndFRM.txtMemberUsername.focus();
        return false;
    }
	if(strOld) {
        if(isBlank(Trim(hndFRM.txtMemberPassword.value))) {
            alert("Please enter password to login");
            hndFRM.txtMemberPassword.focus();
            return false;
        }  
        else {
            hndFRM.action=hostUrl+'member/login.php?goto=1';
            hndFRM.submit();   
        }
	}
	if(strNew) {
        hndFRM.action=hostUrl+'signup.php';
        hndFRM.submit();  
	}     
} // End function frmChkLogin()

/**
* - Used For Contact Us Page 
* - Created By Komal Patel 
* - On Date 08-04-2008 
**/
function fnValidateContact()
{
	var frm = document.getElementById("frmContact");
    if(isBlank(frm.firstname.value)) {
        alert("Please Enter First Name.");
        frm.firstname.focus();
        return false;
    }
    if(isBlank(frm.lastname.value)) {
        alert("Please Enter Last Name.");
        frm.lastname.focus();
        return false;
    }
    if(isBlank(frm.txtEmailId.value)) {
        alert("Please Enter Email Id.");
        frm.txtEmailId.focus();
        return false;
    }
    if(checkEmail(frm.txtEmailId)==false) {
        alert("Please Enter Valid Email Id.");
        frm.txtEmailId.focus();
        return false;
    }
    if(isBlank(frm.phone.value)) {
        alert("Please Phone Number.");
        frm.phone.focus();
        return false;
    }
    if(isBlank(frm.address.value)) {
        alert("Please Enter Address.");
        frm.address.focus();
        return false;
    }
    if(isBlank(frm.city.value)) {
        alert("Please Enter City.");
        frm.city.focus();
        return false;
    }
    if(isBlank(frm.intState.value)) {
        alert("Please Select State.");
        frm.intState.focus();
        return false;
    }
    if(isBlank(frm.zip.value)) {
        alert("Please Enter zip Code.");
        frm.zip.focus();
        return false;
    }
    if(isBlank(frm.contact.value)) {
        alert("Please Enter Your Question or Suggestions.");
        frm.contact.focus();
        return false;
    }
}
function fnOpenBox()
{
    showPopWin('http://www.goldeneaglecoin.com/testPage.php', 600, 150, null);
}
function frmPaymentValidate()
{
    var dateObj=new Date();
    var currentMonth = dateObj.getMonth();
    var currentYear = dateObj.getFullYear();
    var frm= window.frames["popupFrame"].document.getElementById('frmPayment');
    if(isBlank(frm.payment.value)) {		
        alert("Please Select Payment Method.");
        frm.payment.focus();
        return false;
    }
    if(frm.payment.value!='6') {
        if(isBlank(frm.credit_num.value)) {
            alert("Please Enter Credit Card Number.");
            frm.credit_num.focus();
            return false;
        }
        if (checkCreditCard(frm.credit_num.value,frm.card_type.value)==false) {
            alert(ccErrors[ccErrorNo]);
            return false;
        }
        if(isBlank(frm.credit_expire_year.value)) {
            alert("Please Enter Credit Card Expiration Year.");
            frm.credit_expire_year.focus();
            return false;
        }
        if(isNaN(frm.credit_expire_year.value)) {
            alert("Invalid Credit Card Expiration Year."); 
            frm.credit_expire_year.focus();
            return false;
        }
        if(frm.credit_expire_year.value < currentYear) {
            alert("This card has already expired."); 
            frm.credit_expire_year.focus();
            return false;
        }
        else if(frm.credit_expire_year.value==currentYear) {
            if(frm.credit_expire_month.value < currentMonth) {
                alert("This card has already expired."); 
                frm.credit_expire_year.focus();
                return false; 
            }
        }
        if(isBlank(frm.CC_CODE.value)) {
            alert("Please Enter CVV code.");
            frm.CC_CODE.focus();
            return false;
        }
	}
	return true;
}

/*************************************
Created By Aadesh Gharpure
Date 16 Dec 2008
Purpose: This is common function and will be used to open a pop up window
*************************************/ 
function popitup(url,name,height,width,top,left)
{
	newwindow=window.open(url,name,'height='+height+',width='+width+',top='+top+',left='+left+',scrollbars=1');
	if (window.focus) {newwindow.focus()}
	return false;
}

/***********************************
* - function fnUpdateMetalChart()
* - Created By Aadesh Gharpure
* - On Date 30 Dec 2008
* - Used For displaying historical metal charts
***********************************/ 
function fnUpdateMetalChart(val1,val2,val3)
{
    var strUrl="Xignite_chart.php?metaltype="+val1+"&duration="+val2;
	xmlHttp=GetXmlHttpObject();
    if(xmlHttp) {
		xmlHttp.open("GET",strUrl,true);
    	xmlHttp.onreadystatechange = function() //function to be called on every state change event
		{
    		if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
				var strResult = xmlHttp.responseText;   		
   				document.getElementById(val3).innerHTML=strResult;  
			}//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )
		}//end  xmlHttp.onreadystatechange = function()
		xmlHttp.send(null);
	}//end  if(xmlHttp)
}//end function fnUpdateMetalChart(strUrl)

/***********************************
* - Used in visitor section - category details page to change product image
* - Created By Aadesh Gharpure
* - On Date 02-Dec-2008
***********************************/
function fnChangeProductImage(path,filename,idname,larheimagepath,title,totalimages,productid,activeid)
{
    var htmlcode="";
    htmlcode = '<a href="'+larheimagepath+filename+'" class="MagicThumb" title="'+title+'"><img src="'+path+filename+'" alt="'+filename+'" title="'+filename+'"/></a>';
    document.getElementById(idname).innerHTML = htmlcode;
    MagicThumb.refresh();
    //change class for the thumbs
    for(var i=0;i<totalimages;i++) {
        if(i==activeid) {
          document.getElementById(productid+'_'+i).style.border="1px solid #000000";
        }
        else {
          document.getElementById(productid+'_'+i).style.border="1px solid #CCCCCC";
        }
    }
}

/***********************************
* - Used in member section - price reached preference spage to validate the form
* - Created By Aadesh Gharpure
* - On Date 16-Dec-2008
***********************************/
function fnCheckPricePreferences()
{
	var hndFRM = document.getElementById("frmPreferences");
	var isValid = false;
	var numbersCheckRegExp = /[^\d.]/;
	isValid = !numbersCheckRegExp.test(hndFRM.txtPrice.value);
	if(isBlank(Trim(hndFRM.txtPrice.value))) {
        alert("Please enter price for the alert");
        hndFRM.txtPrice.focus();
        return false;
    }
	if(!isValid) {
        alert("Please Enter Valid Price value.");
        return false;
    }
	hndFRM.submit();
}

/***********************************
* - Used for openging a modal pop up
* - Created By Aadesh Gharpure
* - On Date 19-Dec-2009
***********************************/
function fnOpenModalWindow(url,height,width)
{
    showPopWin(url, width, height, null);
    return false;
}

/***********************************
* - Used in track order function in members account
* - Created By Aadesh Gharpure
* - On Date 20-Jan-2009
***********************************/ 
function fnGetOrderStatus(orderId)
{
    var strHostName = window.location.hostname;
    xmlHttp=GetXmlHttpObject(); 
    var url=window.location.protocol+"//"+strHostName+"/trackorder_popup_ajax.php?ordernumber="+orderId;
	if(isBlank(Trim(orderId))) {
        alert("Please Enter Order Number.");
        return false;
    }
	if(xmlHttp) {
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange = function() //function to be called on every state change event
		{
    		if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
				var strResult = xmlHttp.responseText;   		
				if(strResult != "")
   				   	 document.getElementById("orderstatus").innerHTML=strResult;  
			}//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )
		}//end  xmlHttp.onreadystatechange = function()
		xmlHttp.send(null);
	}//end  if(xmlHttp)
}//end function fnGetOrderStatus()

/***********************************
* - Used for openging a modal pop up in member navigation
* - Created By Aadesh Gharpure
* - On Date 22-Jan-2009
***********************************/
function fnOpenModalWindowForMemberNavigation(url,height,width,top)
{
    showPopWinForMemberNavigation(url, width, height, null,top);
    return false;
}

/***********************************
* - Used for member profile form validation and then updating user info using ajax script
* - Created By Aadesh Gharpure
* - On Date 22-Jan-2009
***********************************/
function fnMemberProfileUpdate()
{
    var hndFRM = document.getElementById('frmProfile');
    if(isBlank(Trim(hndFRM.firstname.value))) {
          alert("Please enter firstname");
          hndFRM.firstname.focus();
          return false;
    }
    if(isBlank(Trim(hndFRM.lastname.value))) {
          alert("Please enter lastname");
          hndFRM.lastname.focus();
          return false;
    }
	//call controller page using ajax script
	var strHostName = window.location.hostname;	
    xmlHttp=GetXmlHttpObject(); 
    var url=window.location.protocol+"//"+strHostName+"/member/editprofile_popup_controller.php";
	//add form values
	url=url+"?firstname="+hndFRM.firstname.value+"&lastname="+hndFRM.lastname.value+"&phone="+hndFRM.phone.value+"&companyname="+hndFRM.companyname.value+"&siteurl="+hndFRM.siteurl.value;	
	if(xmlHttp) {
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange = function() //function to be called on every state change event
		{
    		if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
				var strResult = xmlHttp.responseText;   		
				if(strResult != "")
   				   	 window.parent.hidePopWin(false);

				window.parent.location.href="myaccount_new.php?currentTab=0";
			}//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )   	
		}//end  xmlHttp.onreadystatechange = function()
		xmlHttp.send(null);
	}//end  if(xmlHttp)	
}

/***********************************
* - Used for updating password for member account using ajax script
* - Created By Aadesh Gharpure
* - On Date 22-Jan-2009
***********************************/
function fnChangePasswordUpdate()
{
   var frm=document.getElementById('frmChgPass');  
   if(isBlank(frm.txtOldPassword.value)) {
        alert("Enter Old Password");
        frm.txtOldPassword.focus();
        return false;
   }
   if(isBlank(frm.txtPassword1.value)) {
        alert("Enter New Password");   
        frm.txtPassword1.focus();
        return false;
   }
   if(frm.txtPassword1.value.length<6 || frm.txtPassword1.value.length>10) {
        alert("Password should be minimum 6 or maximum 10 characters.");
        frm.txtPassword1.focus();
        return false;
   }
   if(isBlank(frm.txtPassword2.value)) {
        alert("Re Enter New Password");
        frm.txtPassword2.focus();
        return false;
   }
   if(frm.txtPassword2.value.length<6 || frm.txtPassword2.value.length>10) {
        alert("Password should be minimum 6 or maximum 10 characters.");
        frm.txtPassword2.focus();
        return false;
   }
   if(frm.txtPassword1.value != frm.txtPassword2.value) {
       alert("New Password Does Not Match Re Typed Password.");
       frm.txtPassword2.focus();
       return false;
   }
   
    //call controller page using ajax script
    var strHostName = window.location.hostname;	
    xmlHttp=GetXmlHttpObject(); 
    var url=window.location.protocol+"//"+strHostName+"/member/changepassword_popup_controller.php";
    //add form values
    url=url+"?txtOldPassword="+frm.txtOldPassword.value+"&txtPassword1="+frm.txtPassword1.value+"&txtPassword2="+frm.txtPassword2.value;	
	if(xmlHttp) {
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange = function() //function to be called on every state change event
		{
    		if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
				var strResult = xmlHttp.responseText;
				if(strResult!="")
                    alert(strResult);
		   		 
				window.parent.hidePopWin(false);
			}//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )   	
		}//end  xmlHttp.onreadystatechange = function()
		xmlHttp.send(null);
	}//end  if(xmlHttp)	   
}

function fnMemberAddressUpdate()
{
    var hndFRM = document.getElementById('frmAddress'); 
    if(isBlank(hndFRM.txtAddress.value)) {
          alert("Please enter address.");
          hndFRM.txtAddress.focus();
          return false;
    }
    if(isBlank(hndFRM.txtCity.value)) {
          alert("Please enter city.");
          hndFRM.txtCity.focus();
          return false;
    }
    if(isBlank(hndFRM.intState.value)) {
          alert("Please enter state.");
          hndFRM.intState.focus();
          return false;
    }
    if(isBlank(hndFRM.txtZip.value)) {
          alert("Please enter zip code.");
          hndFRM.txtZip.focus();
          return false;
    }
	//call controller page using ajax script
	var strHostName = window.location.hostname;	
    xmlHttp=GetXmlHttpObject(); 
    var url=window.location.protocol+"//"+strHostName+"/member/editaddress_popup_controller.php";
	//add form values
	url=url+"?id="+hndFRM.id.value+"&txtAddress="+hndFRM.txtAddress.value+"&txtAddress2="+hndFRM.txtAddress2.value+"&txtCity="+hndFRM.txtCity.value;
	url=url+"&intState="+hndFRM.intState.value+"&txtZip="+hndFRM.txtZip.value+"&shopping="+hndFRM.shopping.value;
	
	if(xmlHttp) {
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange = function() //function to be called on every state change event
		{
    		if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
				var strResult = xmlHttp.responseText;
				if(strResult!="") {
					alert(strResult);
				}
				window.parent.hidePopWin(false);
				if(strResult=="") {
					window.parent.location.href="myaccount_new.php?currentTab=1";
				}
			}//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )
		}//end  xmlHttp.onreadystatechange = function()
		xmlHttp.send(null);
	}//end  if(xmlHttp)
}

function fnMemberAddressAdd()
{
    var hndFRM = document.getElementById('frmAddress'); 
    if(isBlank(hndFRM.txtAddress.value)) {
          alert("Please enter address.");
          hndFRM.txtAddress.focus();
          return false;
    }
    if(isBlank(hndFRM.txtCity.value)) {
          alert("Please enter city.");
          hndFRM.txtCity.focus();
          return false;
    }
    if(isBlank(hndFRM.intState.value)) {
          alert("Please enter state.");
          hndFRM.intState.focus();
          return false;
    }
    if(isBlank(hndFRM.txtZip.value)) {
          alert("Please enter zip code.");
          hndFRM.txtZip.focus();
          return false;
    }
	//call controller page using ajax script
	var strHostName = window.location.hostname;	
    xmlHttp=GetXmlHttpObject(); 
    var url=window.location.protocol+"//"+strHostName+"/member/addnewaddress_popup_controller.php";
	//add form values
	url=url+"?txtAddress="+hndFRM.txtAddress.value+"&txtAddress2="+hndFRM.txtAddress2.value+"&txtCity="+hndFRM.txtCity.value;
	url=url+"&intState="+hndFRM.intState.value+"&txtZip="+hndFRM.txtZip.value;
	if(xmlHttp) {
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange = function() //function to be called on every state change event
		{
    		if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
				var strResult = xmlHttp.responseText;
				if(strResult!="") {
					 alert(strResult);
				 }		   		 	 
				window.parent.hidePopWin(false);
				if(strResult=="") {
					window.parent.location.href="myaccount_new.php?currentTab=1";
				}
			}//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )   	
		}//end  xmlHttp.onreadystatechange = function()
		xmlHttp.send(null);
	}//end  if(xmlHttp)
}

/*************************************
Created By Aadesh Gharpure
Date 24 Mar 2009
Purpose: This function will be used to open a pop up window in check out process step 2
*************************************/
function popupWhat(url,name,height,width,top,left)
{
    window.open(url,"_blank","toolbar=no, location=yes, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width="+width+", height="+height+", top="+top+", left="+left);
    return false;
}

/***********************************
* - Used in track order function in members account. This order will be from Golden Eagle site
* - Created By Aadesh Gharpure
* - On Date 07-May-2009
***********************************/ 
function fnGetOrderStatusGolden(orderId)
{
    var strHostName = window.location.hostname;
    xmlHttp=GetXmlHttpObject(); 
    var url=window.location.protocol+"//"+strHostName+"/trackorder_popup_ajax_golden.php?ordernumber="+orderId;
    if(isBlank(Trim(orderId))) {
        alert("Please Enter Order Number.");
        return false;
    }
    if(xmlHttp) {
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange = function() //function to be called on every state change event
        {
            if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
                var strResult = xmlHttp.responseText;           
                if(strResult != "")
                           document.getElementById("orderstatus").innerHTML=strResult;
            }//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )
        }//end  xmlHttp.onreadystatechange = function()
        xmlHttp.send(null);
    }//end  if(xmlHttp)
}//end function fnGetOrderStatusGolden()

/***********************************
* - Used in track order function in members account. This order will be from American Silver Eagle site
* - Created By Aadesh Gharpure
* - On Date 07-May-2009
***********************************/ 
function fnGetOrderStatusAmerica(orderId)
{
    var strHostName = window.location.hostname;
    xmlHttp=GetXmlHttpObject(); 
    var url=window.location.protocol+"//"+strHostName+"/trackorder_popup_ajax_america.php?ordernumber="+orderId;
    if(isBlank(Trim(orderId))) {
        alert("Please Enter Order Number.");
        return false;
    }
    if(xmlHttp) {
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange = function() //function to be called on every state change event
        {
            if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
                var strResult = xmlHttp.responseText;           
                if(strResult != "")
                    document.getElementById("orderstatus").innerHTML=strResult;  
            }//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )       
        }//end  xmlHttp.onreadystatechange = function()
        xmlHttp.send(null);
    }//end  if(xmlHttp)    
}//end function fnGetOrderStatusAmerica()

/*************************************
Created By Aadesh Gharpure
Date 08 Apr 2009
Purpose: This function will be used to open a pop up for adding email id in list. These are customers who want tu buy a product,
but it's out of stock. So using cron email will be fired to the email ids when product is available
*************************************/ 
function fnAddOutOfStockList(productId,emailid,qty)
{
    var strHostName = window.location.hostname;
    xmlHttp=GetXmlHttpObject(); 
    var isValid = false;
    var numbersCheckRegExp = /[^\d]/;
    isValid = !numbersCheckRegExp.test(qty);
    if(emailid == "") {
        alert('Please enter Email Id.');
        return false;
    }
    if(checkEmailNew(emailid)==false) {
        alert("Please Enter Valid Email Id.");
        return false;
    }
    if(qty == "") {
        alert('Please enter Product Quantity.');
        return false;
    }
    if(qty <= 0) {
        alert("Product Quqantity should be a positive numeric value.");
        return false;
    }
    else if(!isValid) {
            alert("Please Enter Valid Product Quantity value.");
            return false;    
    }
    if(xmlHttp) {
        var strHostName = window.location.hostname;
        var url=window.location.protocol+"//"+strHostName+"/addToOutOfStockList.php";
        //add form values
        url=url+"?id="+productId+"&emailID="+emailid+"&qty="+qty;
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange = function() //function to be called on every state change event
        {
            if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
                var strResult = xmlHttp.responseText;
                if(strResult!="") {
                    alert(strResult);
                }
                window.parent.hidePopWin(false);
            }//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )       
        }//end  xmlHttp.onreadystatechange = function()
        xmlHttp.send(null);
    }//end  if(xmlHttp)
}//end function fnAddOutOfStockList()

/******************************
Created By Aadesh Gharpure
Date 08 Apr 2009
Purpose: Used For displaying product out of stock pop up. Using the form provided in pop up user can add his email id,
         so that he can get an email when that product is available
******************************/
function fnDisplayOutOfStockPopup(ProductId)
{
    var strHostName = window.location.hostname;
    showPopWin(window.location.protocol+'//'+strHostName+'/notifyOutOfStock.php?ProductID='+ProductId, 410, 250, null);
}//end function fnDisplayOutOfStockPopup()

/******************************
Following 2 functions are Created By Aadesh Gharpure
Date 08 Apr 2009
Purpose: These are for email validations. Takes object value as parameter (and not an object as parameter)
******************************/
function checkEmailNew(objThis){ if(isBlank(objThis)) return true; var tmpRegExpr = /^[0-9A-Za-z]+([\.\_]?[0-9A-Z-a-z]+)*([\@]{1})(([0-9A-Z-a-z]+)([\.]{1})([0-9A-Za-z]+))+$/; var retVal = processCheckingNew(objThis,tmpRegExpr,'Email ID is not proper, please correct the Email ID.',checkEmailNew.arguments); return retVal;}
function processCheckingNew(objThis,pRegExpr,pMessage,funcArguments){hndEvent=window.event; var SetFocus=(funcArguments[1])?funcArguments[1]:false; var ShowAlert=(funcArguments[2])?funcArguments[2]:false; var tmpRegExpr=pRegExpr; var ActualRegExpr=new RegExp(tmpRegExpr); var Val2Check=objThis; var NoError=true; if (!Val2Check.match(ActualRegExpr)) NoError=false; if(!NoError){ if(ShowAlert){alert(pMessage);} if(SetFocus){hndEvent.returnValue=false; } } return NoError;}

/***********************************
* - Used in product details section, in order to update the rating for the product
* - Created By Aadesh Gharpure
* - On Date 11-May-2009
***********************************/ 
function fnUpdateProductRating(rating,pId)
{
    var strHostName = window.location.hostname;
    xmlHttp=GetXmlHttpObject(); 
    var url=window.location.protocol+"//"+strHostName+"/updateProductRating.php?id="+pId+"&rating="+rating;
    if(xmlHttp) {
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange = function() //function to be called on every state change event
        {
            if(xmlHttp.readyState==4 && xmlHttp.status==200 ) {
                window.location.reload();
            }//end  if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200 )       
        }//end  xmlHttp.onreadystatechange = function()
        xmlHttp.send(null);
    }//end  if(xmlHttp)    
}//end function fnUpdateProductRating()

/*************************************
Created By Aadesh Gharpure
Date 07 Jul 2009
Purpose: This is common function and will be used to open a pop up window for pritner friendly version of product details page.
*************************************/ 
function printProductInfo(url,name,height,width,top,left)
{
    newwindow=window.open(url,name,'height='+height+',width='+width+',top='+top+',left='+left+',scrollbars=1');
    if (window.focus) {newwindow.focus()}
    return false;
}

/*************************************
Function Name:	clearText()
Created By:		Aadesh Gharpure
Created On:		06 Jan 2010
Purpose:		This function will be used to clear the defalut value of any text field/area when user cliks on that control.
*************************************/ 
function clearText(elementId,defaultText)
{
	var element = document.getElementById(elementId);
	if(element.value==defaultText) {
		element.value = "";
	}
}
