function header()
{
	document.write('<tr><td><table border="0" cellpadding="0" cellspacing="0" width="100%" background="http://kashmirmart.com/shopping/images/shopping/shopstrip.jpg">');
	document.write('<tr><td width="190"><img border="0" src="http://kashmirmart.com/shopping/images/shopping/shop1.jpg" width="190" height="87"></td>');
	document.write('<td width="589" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="35%" height="64"></td>');
	document.write('<td width="65%" align=right valign=bottom><a href=http://kashmirmart.com/shopping/viewCart.php><img src=http://kashmirmart.com/shopping/images/shopping/cart.gif border=0 width="150" height="55"></a></td></tr><tr><td width="36%"></td><td width="64%"><table border="0" cellpadding="0" cellspacing="0" width="100%">');
	document.write('<tr><td width="36"><img border="0" src="http://kashmirmart.com/shopping/images/shopping/shoplink1.gif" width="36" height="23"></td>');
	document.write('<td width="15" background="http://kashmirmart.com/shopping/images/shopping/shoplinkstrip.jpg"><a href=http://kashmirmart.com/shopping/index.html class=links>Home</a></td>');
	document.write('<td width="30"><img border="0" src="http://kashmirmart.com/shopping/images/shopping/shoplink.jpg" width="30" height="23"></td>');
	document.write('<td width="60" background="http://kashmirmart.com/shopping/images/shopping/shoplinkstrip.jpg"><a href=http://kashmirmart.com/shopping/about.html class=links>About us</a></td>');
	document.write('<td width="30"><img border="0" src="http://kashmirmart.com/shopping/images/shopping/shoplink.jpg" width="30" height="23"></td>');
	document.write('<td background="http://kashmirmart.com/shopping/images/shopping/shoplinkstrip.jpg"><a href=http://kashmirmart.com/shopping/disclamer.html class=links>Disclaimer</a></td>');
	document.write('<td width="30"><img border="0" src="http://kashmirmart.com/shopping/images/shopping/shoplink.jpg" width="30" height="23"></td>');
	document.write('<td background="http://kashmirmart.com/shopping/images/shopping/shoplinkstrip.jpg" width="70"><a href=http://kashmirmart.com/shopping/contactus.html class=links>Contact us</a></td>');
	document.write('</tr></table></td></tr></table></td></tr></table></td></tr><tr><form NAME="login_form" ACTION="user/login.php" METHOD=POST onsubmit="return checkLoginForm(this);"><td background="http://kashmirmart.com/shopping/images/shopping/bluestrip.jpg" width="100%" height="25">');
	document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="40%"></td><td width="60%">');
	document.write('<font color="#ffffff" face="Verdana" size="1">User Id</font><font color="#ffffff" face="Arial" size="1">&nbsp;</font><input type="text" name="user_id" size="15" style="font-size: 8pt">&nbsp;&nbsp; <font color="#ffffff" size="1" face="Verdana">Password</font>&nbsp;');
	document.write('<input type="password"  name="password" size="15" style="font-size: 8pt">&nbsp;<input type="submit" value="Go" class=go>&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/user/newLogin.php><font color="#ffffff" face="Arial" size="1">New User Register Here</font></a></td></tr></table></td></form></tr><tr><td width="100%" height="3"></td></tr>');
}
function left()
{
	document.write('<tr><td width="100%"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="181" valign="top">');
	document.write('<table border="0" cellpadding="0" cellspacing="0" width="168"><tr><td width="100%" height="30"><img border="0" src="http://kashmirmart.com/shopping/images/shopping/ourproduct.gif" width="168" height="28"></td>');
	document.write('</tr><tr height=22><td width="100%" height="10"></td></tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td></tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5462.html class=leftlinks>Horoscope &amp; Palmistry</a></td>');
	document.write('</tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td></tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5602.html class=leftlinks>Yoga for Beginners</a></td></tr>');
	document.write('<tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td></tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=details5471.html class=leftlinks>3D Atlas</a></td>');
	document.write('</tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td></tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5502.html class=leftlinks>Feng Shui</a></td>');
	document.write('</tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td></tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5488.html class=leftlinks>12,000 Recipes</a></td>');
	document.write('</tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td></tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5491.html class=leftlinks>18 Languages</a></td>');
	document.write('</tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td></tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5597.html class=leftlinks>1st &amp; 2nd Grade Excelerator</a></td>');
	document.write('</tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td></tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5599.html class=leftlinks>Middle School Math Excelerator&nbsp;</a></td>');
	document.write('</tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td></tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5472.html class=leftlinks>Instant Home Design</a></td></tr><tr>');
	document.write('<td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td></tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5467.html class=leftlinks>Human Body</a></td></tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td>');
	document.write('</tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5603.html class=leftlinks>Webster\'s Gold Encyclopedia</a></td></tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td>');
	document.write('</tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5632.html class=leftlinks>Music Maker</a></td></tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td>');
	document.write('</tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5639.html class=leftlinks>T-Shirt Maker</a></td></tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td>');
	document.write('</tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5709.html class=leftlinks>Best of Gothic Horror</a></td></tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td>');
	document.write('</tr><tr height=22><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5711.html class=leftlinks>A Love of Art</a></td></tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td>');
	document.write('</tr><tr><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5713.html class=leftlinks>Complete U.S. History</a></td></tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td>');
	document.write('</tr><tr><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5714.html class=leftlinks>Travels in Europe</a></td></tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td>');
	document.write('</tr><tr><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5781.html class=leftlinks>Instant Immersion Home Cooking</a></td></tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td>');
	document.write('</tr><tr><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5863.html class=leftlinks>MP3 Maker</a></td>');
	document.write('</tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td></tr><tr><td width="100%" height="22">&nbsp;&nbsp;<a href=http://kashmirmart.com/shopping/details5877.html class=leftlinks>Dance Maker</a></td>');
	document.write('</tr><tr><td width="100%"  background="http://kashmirmart.com/shopping/images/dot1.jpg" height="1"></td></tr></table></td>');
}
function footer()
{
	document.write('<table cellpadding=2 cellspacing=0 border=0 width=779><tr><td width=100%><p align=center><font face="Verdana" size="1" color="#325A3D">© Copyright  </font><a href=http://kashmirmart.com target=_new><font face="Verdana" size="1" color="#325A3D">kashmirmart.com</font></a>&nbsp;&nbsp;&nbsp;<font face="Verdana" size="1" color="#325A3D">Powered By  </font><a href=http://emavens.com target=_new><font face="Verdana" size="1" color="#325A3D">eMaven Solutions</font></a></p></td></tr></table>');
}






/////////////////////////////////////////////////////////////////////////////////////////////////////////////
function accountpanel(username,path){
if(path==null)path="./";
document.writeln('<table width=100% cellpadding=0 cellspacing=1 height=30 border=0><TR><TD BGCOLOR="#E8E8E0">&nbsp;<FONT class=textheading>Welcome <FONT COLOR="red">'+username+'</FONT></FONT></TD><!-- <TD bgcolor="#A8C098" align=center width=80><A HREF="account.php" style="{color:white;}"><B>My Account</A></TD> --><TD colspan=3 bgcolor="#C6C6B0" align=center  width=80><A HREF="logout.php" style="{color:white;}"><B>Logout</B></A></TD></TR></table>');
}





/////////////////////////////////////////////////////////////////////////////////////////////////////
//generic function to add items to a drop down list box.
function addToList(chkObject, newText, newValue) {
var isSelected = false;
var qty=chkObject.form.quantity.value;
var inrprice=chkObject.form.inrprice.value;
var symbol=chkObject.form.currency.value;
var price=0;
var  _lastCurrencySymbol;

 //_lastCurrencySymbol= document.cookie("lastCurrency");

/*if ( (_lastCurrencySymbol.toUpperCase() != symbol.toUpperCase()) &&  _lastCurrencySymbol != ""){
	alert("Different Currency!");
}*/

for (var k=0;k<currencySymbolsAndValues.length;k++){
	//alert(currencySymbolsAndValues[k][0]+ " : " + currencySymbolsAndValues[k][1]);
	if (symbol == currencySymbolsAndValues[k][0]){
		price = roundMore(parseFloat(parseInt(inrprice/currencySymbolsAndValues[k][1]*100)/100));
	}

}


/*_lastCurrencySymbol=symbol;
document.cookie("lastCurrency")=_lastCurrencySymbol;*/


				if (chkObject.checked==true) {
					isSelected=true;
					
				}
		//alert(isSelected);

 		if (isSelected) {
		  var len = document.cart.selProductCodes.length++; 
		  document.cart.selProductCodes.options[len].value = newValue.toUpperCase();
	      document.cart.selProductCodes.options[len].text = newText.toUpperCase()+"  -  "+qty+"   - "+symbol+" "+price;
		  document.cart.selProductCodes.selectedIndex = 0; 
			document.cart.selProductCodes.size++;
		}else{
			removeFromList(chkObject, newText, newValue);
			document.cart.selProductCodes.size--;
		}
document.cart.txiTotalItems.value = document.cart.selProductCodes.length;
}


//generic function to add items to a drop down list box.
function removeFromList(chkObject, newText, newValue) {
var isSelected = false;
var len=document.cart.selProductCodes.length;
var j=0;
var optionsArray=Array();
//alert("Getting all values from cart list!");

	for (var i=0;i<len;i++){
		optionsArray[i]=new Array(document.cart.selProductCodes.options[i].value,document.cart.selProductCodes.options[i].text);
		//optionsArray[i][0]=document.cart.selProductCodes.options[i].value;
		//optionsArray[i][1]=document.cart.selProductCodes.options[i].text;
	}

//alert("Got all products from list!");

//	alert(optionsArray);
//alert("Making cart.selProducts.length = 0");
	document.cart.selProductCodes.length=0;
	
//alert("Travesing all the product codes from optionsArray");	
		//alert("looking for "+newValue);
	for (var i=0;i<optionsArray.length;i++){
		//alert("I =  " +i+ " and writing "+optionsArray[i]);

		if ( optionsArray[i][0] != newValue) {
			//alert("Increasing length of list box");
			document.cart.selProductCodes.length++;	
			//alert("Assigning new value"+optionsArray[i]);
				document.cart.selProductCodes.options[j].value = optionsArray[i][0];
			//alert("Assinging new Text "+optionsArray[i]);

			document.cart.selProductCodes.options[j].text = optionsArray[i][1];
			j++;
		}else{
		//	alert("Found "+newValue);
		}

	}
}






////////////////////////////////////////////////////////////////////////////////////////////////////////
function roundMore(num){
var floor,ceil,fraction;
floor=Math.floor(num);
ceil=Math.ceil(num);
	if (! (ceil-floor) ){
		return num;
	}else{
		fraction= num - floor;

		if ( fraction <=0 ){
			fraction=0;
		}else if (fraction <=.25 && fraction > 0){
			fraction=.25;
		
		}else if (fraction <=.5 && fraction > 0){
			fraction=.5;
		
		}else if (fraction <=.75 && fraction > 0){
			fraction=.75;
		
		}else {
			fraction=1;
		}
		num = floor + fraction;
		return num;
	}
}







////////////////////////////////////////////////////////////////////////////////////////////////////////
function showMoreProductDetails(pcode){
//alert(pcode);
var detailsWindow=window.open("/store/showMoreDetails.php?pcode="+pcode,"moreWindow","Width=400, Height=250, Scrollbars=1, Toolbars=0");
return false;
}









////////////////////////////////////////////////////////////////////////////////////////////////////////
function knowMore(){
//alert(pcode);
var knowmoreWindow=window.open("/user/knowMore.php","knowmoreWindow","Width=400, Height=400, Scrollbars=1, Toolbars=0");
return false;
}









////////////////////////////////////////////////COMMON FUNCTIONS/////////////////////////////////////////////////////////////////////
//THIS FUNTION CHECK FOR A VALID  EMAIL ADDRESS.
function isValidEmail(emailid) {
if (emailid == ""){
	return false; // because  it is not optional 
}
else{
		var eid=emailid;

		if (eid.indexOf(' ')!= -1){
			return false ; // no spaces
		} 
		if (eid.length < 6 ){
			return false ; // at least j.a@in
		}
		at=eid.indexOf('@', 0); //check from first position ---- 
		if ( at == -1 || at == 0){ //should not be at first place
			return false ;
		}else{
				var at1=eid.indexOf('@', (at + 1)); //looking for another at one place ahead
				if ( at1 == -1 ) // ie only one at is there
				{
					var dot=eid.indexOf('.',(at + 1));//looking for just next value
					if(dot == (at + 1)|| dot== -1){ //if dot is not there or in the next place
						return false ;	
						}
					else{
						 if ( (dot + 2 ) < eid.length )
							return true ;
						 else{
							return false ;
						}
					}
				}
				else // two @ are there
				{
					return false;
				}
			}	
	return false ;
	}		
}
//////////////////THIS FUNCTION CHECK ANY GIVEN PHONE NO.
function isValidPhone(phoneid){
var numstr="1234567890+-, ";
var intctr,intLen;
    intLen=phoneid.length;
        for(intCtr=0;intCtr <= intLen && numstr.indexOf(phoneid.charAt(intCtr))>=0 ;intCtr++);
        if(intCtr > intLen)
              return true;
        else
              return false;
      
}

////////THIS FUNCTION TRIMS THE TRAILING WHITE SPACES IN A GIVEN STRING.
function trim(str1){
// This function trims any given field value for blank spaces.
        var intCtr=0
        for(intCtr=0;str1.charAt(intCtr)==" ";intCtr++);
        str1=str1.substring(intCtr,str1.length);
        return str1;    
}
function checkforchar(strdate){
//This function checks for string values
var validdate = ",.abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var strlength = strdate.length;
	for(var i=0; i<=strlength; i++)
	{
		var unitstr = strdate.substr(i,1);
		if (validdate.indexOf(unitstr)==-1)
		{
			return false;
		}
	}
	return true;
}
function isAllNumeric(str1){
//This function checks for numeric values
        var numstr="1234567890 ,-";
        var intctr,intLen;
            intLen=str1.length;
        for(intCtr=0;intCtr <= intLen && numstr.indexOf(str1.charAt(intCtr))>=0 ;intCtr++);
        if(intCtr > intLen)
        {
                return 1;
        }
        else
        {
        return 0;
        }
}

function goBack() { 
history.back();   
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function doSameAs(frm){
	if (window.document.frm.sameAs.checked){
		window.document.frm.selTitle.value	=			window.document.frm.selSenderTitle.value;
		window.document.frm.txiName.value	=			window.document.frm.txiSenderName.value;
		window.document.frm.txiDesignation.value	=		window.document.frm.txiSenderDesignation.value;
		window.document.frm.txiCompany.value	=		window.document.frm.txiSenderCompany.value;
		
		window.document.frm.txaAddress.value	=		window.document.frm.txaSenderAddress.value;
		window.document.frm.txiCity.value	=		window.document.frm.txiSenderCity.value;
		window.document.frm.txiState.value	=		window.document.frm.txiSenderState.value;
		window.document.frm.txiZipcode.value	=		window.document.frm.txiSenderZipcode.value;
		window.document.frm.selCountry.value	=		window.document.frm.selSenderCountry.value;
		window.document.frm.txiPhone.value	=		window.document.frm.txiSenderPhone.value;
		window.document.frm.txiEmail.value	=		window.document.frm.txiSenderEmail.value;
		window.document.frm.txaRemarks.value	=		window.document.frm.txaSenderRemarks.value;
	}else{
		window.document.frm.selTitle.value	= "";
		window.document.frm.txiName.value	= "";
		window.document.frm.txiDesignation.value	= "";
		window.document.frm.txiCompany.value	= "";
		window.document.frm.txaAddress.value	= "";
		window.document.frm.txiCity.value	= "";
		window.document.frm.txiState.value	= "";
		window.document.frm.txiZipcode.value	= "";
		window.document.frm.selCountry.value	= "";
		window.document.frm.txiPhone.value	= "";
		window.document.frm.txiEmail.value	= "";
		window.document.frm.txaRemarks.value	= "";
	}
return true;
}

//////////////////////////////////////////////////shopping cart form validations.///////////////////////////////////////////////////
function checkShoppingCartForm(frm){

//check for name
	if ( trim(frm.txiSenderName.value).length <= 0 ){
			alert("Billing - Name is missing!");
			frm.txiSenderName.focus();
			return false;
	}
//check for address
	if ( trim(frm.txaSenderAddress.value).length <= 0 ){
			alert("Billing  - Address is missing!");
			frm.txaSenderAddress.focus();
			return false;
	}

//check for city
	if ( trim(frm.txiSenderCity.value).length <= 0 ){
			alert("Billing - City is missing!");
			frm.txiSenderCity.focus();
			return false;
	}
//check for state
	if ( trim(frm.txiSenderState.value).length <= 0 ){
			alert("Billing - State is missing!");
			frm.txiSenderState.focus();
			return false;
	}

//check for ZipCOde
	if ( trim(frm.txiSenderZipcode.value).length <= 0 ){
			alert("Billing - Zip code is missing!");
			frm.txiSenderZipcode.focus();
			return false;
	}

//check for country
	if ( trim(frm.selSenderCountry.value).toUpperCase() == "NA" ){
			alert("Billing - Country is missing!");
			frm.selSenderCountry.focus();
			return false;
	}

//check for phone
	if ( trim(frm.txiSenderPhone.value).length <= 0 ){
			alert("Billing - Phone is missing!");
			frm.txiSenderPhone.focus();
			return false;
	}
//check for phone validity.
	if ( !isValidPhone(trim(frm.txiSenderPhone.value)) ) {
			alert("Billing - Phone no is not correct!");
			frm.txiSenderPhone.focus();
			return false;
	}


//check for email
	if ( trim(frm.txiSenderEmail.value).length <= 0 ){
			alert("Billing -  Email is missing!");
			frm.txiSenderEmail.focus();
			return false;
	}

//check for email validity.
	if ( !isValidEmail(trim(frm.txiSenderEmail.value)) ) {
			alert("Billing - Email is not correct!");
			frm.txiSenderEmail.focus();
			return false;
	}


//////////////////////////////////////////////////delivery address validations.///////////////////////////////////////////////////
//check for name
	if ( trim(frm.txiName.value).length <= 0 ){
			alert("Delivery - Name is missing!");
			frm.txiName.focus();
			return false;
	}
//check for address
	if ( trim(frm.txaAddress.value).length <= 0 ){
			alert("Delivery  - Address is missing!");
			frm.txaAddress.focus();
			return false;
	}

//check for city
	if ( trim(frm.txiCity.value).length <= 0 ){
			alert("Delivery - City is missing!");
			frm.txiCity.focus();
			return false;
	}
//check for state
	if ( trim(frm.txiState.value).length <= 0 ){
			alert("Delivery - State is missing!");
			frm.txiState.focus();
			return false;
	}

//check for ZipCOde
	if ( trim(frm.txiZipcode.value).length <= 0 ){
			alert("Delivery - Zip code is missing!");
			frm.txiZipcode.focus();
			return false;
	}

//check for country
	if ( trim(frm.selCountry.value).toUpperCase() == "NA" ){
			alert("Delivery - Country is missing!");
			frm.selCountry.focus();
			return false;
	}

//check for phone
	if ( trim(frm.txiPhone.value).length <= 0 ){
			alert("Delivery - Phone is missing!");
			frm.txiPhone.focus();
			return false;
	}
//check for phone validity.
	if ( !isValidPhone(trim(frm.txiPhone.value)) ) {lo
			alert("Delivery - Phone no is not correct!");
			frm.txiPhone.focus();
			return false;
	}


//check for email
	if ( trim(frm.txiEmail.value).length <= 0 ){
			alert("Delivery -  Email is missing!");
			frm.txiEmail.focus();
			return false;
	}

//check for email validity.
	if ( !isValidEmail(trim(frm.txiEmail.value)) ) {
			alert("Delivery - Email is not correct!");
			frm.txiEmail.focus();
			return false;
	}





//if all fields are valid then
	return true;

}



function confirmRemove(){
if(confirm("Do you realy want to delete this recipient address details from your address book?")){
	return true;
}else{
return false;
}


}

function confirmCartRemove(pcode){
	if(confirm("Do you realy want to delete "+ pcode +" from your shopping cart?"))
		return true;
	else
		return false;
}


function checkForm(frm){

var q=frm.quantity.value;
var lastcurrency=frm.lastTimeCurrency.value.toUpperCase();
var currency= frm.currency.value.toUpperCase();

if ( isNaN(q) || !isAllNumericQuantity(q)){
	alert("Product quantity is incorrect.\nPlease enter correct quantity!");
	frm.quantity.focus();
	return false;
}


if ( currency != lastcurrency && lastcurrency !=""){
		if ( confirm("You have choosen a different currency "+currency+" this time. Do you want to buy in "+currency+ "?")){
		}else{
			frm.currency.value=lastcurrency;
		}
}
return true;
}


function isAllNumericQuantity(str1){
//This function checks for numeric values
        var numstr="1234567890";
        var intctr,intLen;
            intLen=str1.length;
        for(intCtr=0;intCtr <= intLen && numstr.indexOf(str1.charAt(intCtr))>=0 ;intCtr++);
        if(intCtr > intLen){
                return 1;
        }else{
        return 0;
        }
}


////////////////////////////////////////////////////////////////////////////////////////////////
function checkLoginForm(frm){
	if (frm.user_id.value.length<=0 || frm.user_id.value == "" ){
		alert("Please enter the user id!");
		frm.user_id.focus();
		return false;
	}

	if (frm.password.value.length<=0 || frm.password.value == "" ){
		alert("Please enter the password!");
		frm.password.focus();
		return false;
	}
return true;
}

////////////////////////////////////////////////////////////////////////////////////////////////
function checkNewLoginForm(frm){
	if (frm.user_id.value.length<=0 || frm.user_id.value == "" ){
		alert("Please enter the user id!");
		frm.user_id.focus();
		return false;
	}

	if (frm.password.value.length<=0 || frm.password.value == "" ){
		alert("Please enter the password!");
		frm.password.focus();
		return false;
	}

	if (frm.password.value.length<5){
		alert("Password should have minimum of five characters!");
		frm.password.focus();
		return false;
	}
	

	if (frm.confirm_password.value.length<=0 || frm.confirm_password.value == "" ){
		alert("Please enter the confirm password!");
		frm.confirm_password.focus();
		return false;
	}
	
	if (frm.password.value != frm.confirm_password.value){
		alert("Your password do not match!");
		frm.confirm_password.focus();
		return false;
		
	}
	
	
return true;
}

///////////////////////////////////////////////////////////////////////////////////////
function checkChangePasswordForm(frm){
	if (frm.txiUserId.value.length<=0 || frm.txiUserId.value == "" ){
		alert("Please enter the user id!");
		frm.txiUserId.focus();
		return false;
	}

	if (frm.txiPassword.value.length<=0 || frm.txiPassword.value == "" ){
		alert("Please enter the password!");
		frm.txiPassword.focus();
		return false;
	}

	if (frm.txiNewPassword.value.length<=0 || frm.txiNewPassword.value == "" ){
		alert("Please enter the new password!");
		frm.txiNewPassword.focus();
		return false;
	}
	
	if (frm.txiPassword.value == frm.txiNewPassword.value){
		alert("Your passwords match, enter new Password!");
		frm.txiNewPassword.focus();
		return false;
		
	}
	
	if (frm.txiNewPassword.value.length<5){
		alert("Password should have minimum of five characters!");
		frm.txiNewPassword.focus();
		return false;
	}
	
return true;
}

//////////////////////////////////////////////////////////////////////////////////////////////
function checkCart(frm){
	//alert('called');
	for (var i=0;i<frm.elements.length-1;i++){
		
		if ( frm.elements[i].type.toUpperCase() == "TEXT" ){
			if ( !isAllNumericQuantity(frm.elements[i].value)){
				alert("Please enter correct quantity of product for updating the cart!");
				frm.elements[i].focus();
				return false;
			}
		}
	}
return true;
}


//////////////////////////////////////////////////////////////////////////////////////////////
function checkRegistrationForm(frm){

//check for name field	
	if( trim(frm.txiName.value).length <=0 ){
		alert("Please enter your name!");
		frm.txiName.focus();
		return false;
	}


//check for address field	
	if( trim(frm.txiAddress.value).length <=0 ){
		alert("Please enter your address!");
		frm.txiAddress.focus();
		return false;
	}


//check for city field	
	if( trim(frm.txiCity.value).length <=0 ){
		alert("Please enter your address city!");
		frm.txiCity.focus();
		return false;
	}

//check for state field	
	if( trim(frm.txiState.value).length <=0 ){
		alert("Please enter your address state!");
		frm.txiState.focus();
		return false;
	}

//check for postcode field	
	if( trim(frm.txiPostCode.value).length <=0 ){
		alert("Please enter your address Zip/Pin code!");
		frm.txiPostCode.focus();
		return false;
	}


//check for postcode field	
	if( trim(frm.txiPostCode.value).length <=0 ){
		alert("Please enter your address Zip/Pin code!");
		frm.txiPostCode.focus();
		return false;
	}

//check for country field	
	if( trim(frm.selCountry.value).length <=0 || frm.selCountry.value.toUpperCase() == "NA" || frm.selCountry.value.toUpperCase() == ""){
		alert("Please select your resident country from list!");
		frm.selCountry.focus();
		return false;
	}

//check for phone field	
	if( trim(frm.txiPhone.value).length <=0 ){
		alert("Please enter your phone no.!");
		frm.txiPhone.focus();
		return false;
	}


//check for email field	
	if( trim(frm.txiEmailAddress.value).length <=0 ){
		alert("Please enter your email address.!");
		frm.txiEmailAddress.focus();
		return false;
	}

//check for email validity.
	if ( !isValidEmail(trim(frm.txiEmailAddress.value)) ) {
			alert("Please enter your email id correctly!\n");
			frm.txiEmailAddress.focus();
			return false;
	}

return true;
}

//////////////////////////////////////////////////////////////////////////////////////////////
function checkAddressBookForm(frm){

//check for name field	
	if( trim(frm.txiName.value).length <=0 ){
		alert("Please enter your name!");
		frm.txiName.focus();
		return false;
	}


//check for designation field	
	if( trim(frm.txiDesignation.value).length <=0 ){
		alert("Please enter your Designation!");
		frm.txiDesignation.focus();
		return false;
	}


//check for company field	
	if( trim(frm.txiCompany.value).length <=0 ){
		alert("Please enter your Company!");
		frm.txiCompany.focus();
		return false;
	}

//check for address field	
	if( trim(frm.txiAddress.value).length <=0 ){
		alert("Please enter your address!");
		frm.txiAddress.focus();
		return false;
	}


//check for city field	
	if( trim(frm.txiCity.value).length <=0 ){
		alert("Please enter your address city!");
		frm.txiCity.focus();
		return false;
	}


//check for state field	
	if( trim(frm.txiState.value).length <=0 ){
		alert("Please enter your address state!");
		frm.txiState.focus();
		return false;
	}

//check for postcode field	
	if( trim(frm.txiPostCode.value).length <=0 ){
		alert("Please enter your address Zip/Pin code!");
		frm.txiPostCode.focus();
		return false;
	}


//check for postcode field	
	if( trim(frm.txiPostCode.value).length <=0 ){
		alert("Please enter your address Zip/Pin code!");
		frm.txiPostCode.focus();
		return false;
	}

//check for country field	
	if( trim(frm.selCountry.value).length <=0 || frm.selCountry.value.toUpperCase() == "NA" || frm.selCountry.value.toUpperCase() == ""){
		alert("Please select your resident country from list!");
		frm.selCountry.focus();
		return false;
	}

//check for phone field	
	if( trim(frm.txiPhone.value).length <=0 ){
		alert("Please enter your phone no.!");
		frm.txiPhone.focus();
		return false;
	}


//check for email field	
	if( trim(frm.txiEmailAddress.value).length <=0 ){
		alert("Please enter your email address.!");
		frm.txiEmailAddress.focus();
		return false;
	}

//check for email validity.
	if ( !isValidEmail(trim(frm.txiEmailAddress.value)) ) {
			alert("Please enter your email id correctly!\n");
			frm.txiEmailAddress.focus();
			return false;
	}

return true;
}




