function header(path,showViewCartFlag){
if(path==null)path="./";
if(showViewCartFlag==null) showViewCartFlag=true;
{
		document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
		document.write('<tr><td width="100%" height="3" bgcolor="#49829F"></td></tr>');
		document.write('<tr><td width="100%" background="/images/top-bg.jpg" height="63">');
		document.write('<table border="0" cellpadding="0" cellspacing="0" width="779">');
		document.write('<tr><td width="40%" height="63" background="/images/top-bg.jpg"><img border="0" src="/images/logo.jpg" width="237" height="63"></td><td width="60%" height="63" background="/images/top-bg.jpg">');
		document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
		document.write('<tr><td width="19%" align="center">');
		document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
		document.write('<tr><td width="100%"><p align="center"><img border="0" src="/images/home-icon.gif" width="11" height="10"></td></tr>');
		document.write('<tr><td width="100%" height="5"></td></tr>');
		document.write('<tr><td width="100%"><p align="center"><a href=../index1.php><font face="Verdana" size="1">Home</font></a></td></tr></table>');
		document.write('</td><td width="1%" align="center"><img border="0" src="/images/toplink-line.jpg" width="1" height="51"></td><td width="19%" align="center">');
		document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
		document.write('<tr><td width="100%"><p align="center"><img border="0" src="/images/about-icon.gif" width="14" height="14"></td></tr>');
		document.write('<tr><td width="100%" height="5"></td></tr>');
		document.write('<tr><td width="100%"><p align="center"><a href=../aboutus.php><font face="Verdana" size="1">About Us</font></a></td></tr>');
		document.write('</table></td><td width="1%" align="center"><img border="0" src="/images/toplink-line.jpg" width="1" height="51"></td><td width="19%" align="center">');
		document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
		document.write('<tr><td width="100%"><p align="center"><img border="0" src="/images/contact-icon.gif" width="14" height="14"></td></tr>');
		document.write('<tr><td width="100%" height="5"></td></tr>');
		document.write('<tr><td width="100%"><p align="center"><a href=../contactus.php><font face="Verdana" size="1">Contact Us</font></a></td></tr>');
		document.write('</table></td><td width="1%" align="center"><img border="0" src="/images/toplink-line.jpg" width="1" height="51"></td><td width="20%" align="center">');
		document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
		document.write('<tr><td width="100%"><p align="center"><img border="0" src="/images/viewcart-icon.gif" width="20" height="14"></td></tr>');
		document.write('<tr><td width="100%" height="5"></td></tr>');
		document.write('<tr><td width="100%"><p align="center"><a href="/cart/viewCart.php?action=show"><font face="Verdana" size="1">View Cart</font></a></td></tr>');
		document.write('</table></td><td width="1%" align="center"><img border="0" src="/images/toplink-line.jpg" width="1" height="51"></td><td width="19%" align="center">');
		document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
		document.write('<tr><td width="100%"><p align="center"><img border="0" src="/images/login-icon.gif" width="11" height="14"></td></tr>');
		document.write('<tr><td width="100%" height="5"></td></tr>');
		document.write('<tr><td width="100%"><p align="center"><font face="Verdana" size="1"><!-- Login--></font></td></tr></table></td></tr></table></td></tr></table>');
		document.write('<tr><td width="100%" rowspan="2">');
		document.write('<table border="0" cellpadding="0" cellspacing="0" width="779" background="/images/stripbg.jpg" height="32">');
		document.write('<tr><td width="15%" align="center">');
		document.write('<p align="center"><a href="../main.php" class="headerlink"><b>FOREIGN PUBLISHER</b></a></p>');
		document.write('</td>');
		document.write('<td width="1%" align="center">');
		document.write('<img border="0" src="/images/line.jpg" width="1" height="25"></td>');
		document.write('<td width="20%" align="center"><a href="../government.php" class="headerlink"><b>GOVERNMENT PUBLICATIONS</b></a></td>');
		document.write('<td width="1%" align="center"><img border="0" src="/images/line.jpg" width="1" height="25"></td>');
		document.write('<td width="14%" align="center"><a href="../ownpublication.php" class="headerlink"><b>OWN PUBLICATION</b></a></td>');
		document.write('<td width="1%" align="center">');
		document.write('<img border="0" src="/images/line.jpg" width="1" height="25"></td>');
		document.write('<td width="14%" align="center"><a href="../electronic.php" class="headerlink"><b>ELECTRONIC ITEMS</b></a></td>');		
		document.write('<td width="1%" align="center">');
		document.write('<img border="0" src="/images/line.jpg" width="1" height="25"></td>');
		document.write('<td width="16%" align="center"><a href="../toauthor.php" class="headerlink"><b>INVITE TO AUTHOR</b>  </a></td>');
		document.write('<td width="1%" align="center">');
		document.write('<img border="0" src="/images/line.jpg" width="1" height="25"></td>');
		document.write('<td width="8%" align="center"><a href="../feedback.php" class="headerlink"><b>FEED BACK</b></a></td>');
		document.write('<td width="1%" align="center"><img border="0" src="/images/line.jpg" width="1" height="25"></td>');
		document.write('<td width="7%" align="center"><a href="../enquiry.php" class="headerlink"><b>ENQUIRY</b></a></td>');
		document.write('</tr></table></td></tr></table>');
	}
}

function validSearch()
{
	if(document.frm_se.keywords.value=='' || document.frm_se.keywords.value=='Enter Search Keywords')
	{
		alert("Please Enter Keywords for search");
		document.frm_se.keywords.focus();
		return false;
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

function leftpanel(path){
if(path==null)path="./";
document.write('<TABLE WIDTH=150 CELLPADDING=0 CELLSPACING=0 ><TR><TD><? include("/store/dCategories.php") ?><!-- <IFRAME WIDTH="100%" HEIGHT="100%" SRC="/store/dCategories.php" FRAMEBORDER=0></IFRAME> --></TD></TR></TABLE>');
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////
function rightpanel(path){

if(path==null)path="./";

document.write('<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BGCOLOR=WHITE><tr height=6><td></td></tr><TR HEIGHT=25><TD><img src=../images/memberlogin.jpg width="178" height="25">');
document.write('</TD></TR><TR><TD><table border="0" cellspacing="0" cellpadding="0" width=100%><tr><td width="100%"><form NAME="login_form" ACTION="../user/login.php" METHOD=POST onsubmit="return checkLoginForm(this);">');
document.write('<table border="0" cellspacing="2" cellpadding="0" width =178 height=77 background="../images/memberlogin_stripbg.jpg"><tr><td width="40%" align=right><font class=login>&nbsp;<b>Login</b></font></td>');
document.write('<td width="60%" colspan=2><input type=text name="user_id" size="14" style="{font-size=10}"></td></tr><tr><td width="40%" align=right><font class=login>&nbsp;<b>Password</b></font></td>');
document.write('<td><input type=password name="password" size="10" style="{font-size=10}"></td><td> <input type="image" src="../images/bulet1.gif" width="27" height="16"></td>');
document.write('</tr><tr><td width="100%" colspan="3"><a href="../user/newLogin.php"><font color="#484848" face="Verdana" size="1"><b>');
document.write('New User</b></font></a>&nbsp;&nbsp;<a href=../user/forgotPassword.php><font color="#484848" face="Verdana" size="1"><b>Forgot Password</b></font></a></td></tr></table></td></tr></table></TD></TR>');
document.write('<tr height=5><td></td></tr><TR><TD valign=top height=23>');
document.write('<img src=../images/showcase.jpg  width="178" height="23"></td></tr>');
document.write('<td width="178" background="../images/showcase_stripbg.jpg" width="178" height = 100 valign=middle><p align="center"><IMG name="SlideShow" id="SlideShow" src="../images/image.jpg" width="140" height="87"  border=1><script>runSlideShow()</script></p></td>');
document.write('<tr><td height=200 bgcolor=#FCF9E0><img width="174" height="153" src=" "></p></td></tr></form></table>');
/*document.write('<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=1 BGCOLOR=WHITE class=smalltable><TR><TD align=center>');
document.write('We accept Master and Visa Credit Cards issued by any back anywhere in the World.</TD></TR><TR>');
document.write('<TD><IMG SRC='+path+'/images/master.gif alt="Master Card"><IMG SRC='+path+'/images/visa.gif  alt="Visa Card"></TD></TR>');
document.write('<TR><TD ALIGN=CENTER>&nbsp;</TD></TR></TABLE>');
//document.write('<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=2 BGCOLOR=WHITE style="{border:1 solid BLACK}" class=smalltable>');
//document.write('<TR><TD ALIGN=CENTER BGCOLOR="SKYBLUE"><FONT SIZE=6>BANNER<BR>WILL<BR>COME<BR>HERE</FONT></TD></TR></TABLE>');*/
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////
function footer(path){
if(path==null)path="./";
//document.write('<tr><td width="100%" colspan="3" height=15></td></tr><tr><td width="100%" colspan="3" bgColor=#484848 height=1></td></tr><td width="100%" colspan="3">');
//document.write('<p align="center"><font face="verdana" size=1 color= #6A6A6A>Copyright© Bookwellindia.com<br>eBuisness powered by</font> <a href="http://www.emavens.com" target=_new><font color=#81A66A>eMaven Solutions</font></a></p></td>');
document.write('<table width="100%"><tr><td width="100%" colspan="3" height=15></td></tr><tr><td width="100%" colspan="3" bgColor=#484848 height=1></td></tr><tr><td width="100%" colspan="3"><p align="center"><font face="verdana" size=1 color= #6A6A6A>Copyright© Bookwellindia.com<br>eBuisness powered by</font> <a href="http://www.emavens.com" target=_new><font color=#81A66A>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="#D8ECA0">&nbsp;<FONT class=heading>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="#A8C098" 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(document.frm.selSenderCountry.value=="India"){
	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;}
else{
	alert("To dispatch outside India, Please choose another Currency  ");
	return false;
}
}

//////////////////////////////////////////////////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(pid){
	if(confirm("Do you realy want to delete "+ pid +" 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 checkFormT(frm){

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

/*if(q<5){
	alert("Quantity of the form is atleast 5");
	frm.quantity.focus();
	return false;
}*/
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;
}




function checkForm()
{
	if(document.frm.name.value=='')
	{
		alert("Please enter your Name");
		document.frm.name.focus();
		return false;
	}
	if(document.frm.address.value==0)
	{
		alert("Please enter Address");
		document.frm.address.focus();
		return false;
	}
	if(document.frm.country.value=='')
	{
		alert("Please Select Country");
		document.frm.country.focus();
		return false;
	}
	
	if(document.frm.phone.value=='')
	{
		alert("Please enter phone");
		document.frm.phone.focus();
		return false;
	}
	if(document.frm.email.value=='')
	{
		alert("Please enter email Address");
		document.frm.email.focus();
		return false;
	}
}


function homeflash()
{
	document.write('<embed width="402" height="126" src="mainflash.swf">');
}