function popupWindow(path, where, hite, wide){
	if (window.event){ 
		window.event.returnValue = false;   
	}
	var width;
	var height;
	var imgWidth;
	var imgHeight;
	
	if (screen.width<wide){
		width=screen.width-20;
		imgWidth=width-10;
		var windowX = (screen.width-width)/2;
	}
	else{
		var windowX = (screen.width-wide)/2;
		width=wide;
	}

	if (screen.height<hite){
		height=screen.height-70;
		imgHeight=height-20;
		var windowY = (screen.height-height)/2-30;
	}
	else{
		var windowY = (screen.height-hite)/2-10;
		height=hite;
	}

	var rand_no = Math.random();
	var i = Math.round(100*Math.random());
	if(screen.height<hite || screen.width<wide){
		var props=window.open(path, i, 'scrollbars=1,toolabars=0,resizable=0,status=0,menubar=0,directories=0,location=0,height='+(hite+30)+', width='+(wide+30));
	}
	else{
		var props=window.open(path, i, 'scrollbars=0,toolabars=0,resizable=0,status=0,menubar=0,directories=0,location=0,height='+(hite+30)+', width='+(wide+30));
	}
	props.moveTo(windowX,windowY);
}



function AddBannerValidation() {
			if(document.add_banner.upload_image.value=="") {
				alert ("Please choose a image...");
				document.add_banner.upload_image.select();
				return false;
			}
}

function popupImageUpload(val1, val2, val3, val4){
		
	if(val2=='' && document.forms[val3].elements[val4].value!=''){
		val2 = document.forms[val3].elements[val4].value;
	}
	
	var popupPath = 'admin_upload_picture.php?type='+val1+'&ID='+val2+'&formName='+val3+'&fieldName='+val4+'';
	popupWindow(popupPath, 1, 500, 500);
}


function deleteImage(val1, val2, val3, val4){			
			if(confirm('Are you sure to delete this picture?')){
				callDeleteImage('<?php echo DOMAIN_PATH;?>/admin/admin_delete_image.php?mode='+val1+'&id='+val2+'&path='+val3+'', val4);
			}
		}
		
function callDeleteImage(page, dispPortion) {
	oHTTP.open("GET", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;			
			if(getValue=="done"){
				document.getElementById(dispPortion).style.display = 'none';
			}
		}
	}
	oHTTP.send(null);
}



if(window.ActiveXObject) {
	try {
		var oHTTP = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch(e) {
		var oHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	}
} 
else {
	var oHTTP = new XMLHttpRequest();
}

/*******************************************************
customer login
*******************************************************/

function CustomerLogin(){
	var loginID = document.forms['user_login'].elements['customer_email'].value;
	var password = document.forms['user_login'].elements['customer_password'].value;
	var sID = document.forms['user_login'].elements['cartID'].value;
	
	if(loginID==""){
		document.getElementById('overAll_err').innerHTML = '';
		document.getElementById('customer_email_err').innerHTML = '&nbsp;Please enter email address.';
		document.forms['user_login'].elements['customer_email'].focus();
		//return false;
	}
	
	if(password==""){
		document.getElementById('overAll_err').innerHTML = '';
		document.getElementById('password_err').innerHTML = '&nbsp;Please enter password.';
		document.forms['user_login'].elements['customer_password'].focus();
		//return false;
	}
	
	if(loginID!="" && password!=""){
		document.getElementById('customer_email_err').innerHTML = '';
		document.getElementById('password_err').innerHTML = '';
		document.getElementById('overAll_err').innerHTML = '';
		
		var checkout = document.forms['user_login'].elements['checkout'].value;		
		
		funmailPage('ajax_call.php?mode=user_login&loginID='+loginID+'&password='+password+'', checkout, sID);
		//return false;
	}
	return false;
}

function descriptionDisplay() {
	document.getElementById('tab_photo').style.display='none';
	document.getElementById('tab_desc').style.display='';
}

function photoDisplay() {
	document.getElementById('tab_desc').style.display='none';	
	document.getElementById('tab_photo').style.display='';
}

function calculateTotalPrice() {
	if(isNaN(parseFloat(document.add_portion.product_quantity.value.replace(/,/g,"")))) a=0;
	else a = parseFloat(document.add_portion.product_quantity.value.replace(/,/g,""));
	
	if(isNaN(parseFloat(document.add_portion.product_unit_price.value.replace(/,/g,"")))) b=0;
	else b = parseFloat(document.add_portion.product_unit_price.value.replace(/,/g,""));	
	
	var total = a*b;
	
	document.add_portion.product_price.value = parseFloat(total).toFixed(2);
}

function calculateVolume() {
	var data = document.add_portion.product_size.value;
	data = data.toLowerCase();
	var volArr = data.split("x");
	var volume = 1;
	for(var i=0;i<volArr.length;i++) {
		var volume = volume*parseFloat(volArr[i]);
	}
	
	totalVolume = volume/1000000;
	
	document.add_portion.product_volume.value = totalVolume.toFixed(2);
}

function funmailPage(page,redirectto,sID) {
	oHTTP.open("GET", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			
			if(getValue=="done"){
				splitValue = redirectto.split("&");
				if(splitValue[0]=="checkout") {
					location.href='checkout_shipping.php?sID='+sID+'';
				}
				else if(splitValue[0]=="alter") {
					location.href='checkout_alternate_shipping.php?'+splitValue[1]+'&sID='+sID+'';
				}
				else {
					location.href='index.php?sID='+sID+'';
				}
			}
			else{
				if(getValue=="Err"){
					document.getElementById('overAll_err').innerHTML = 'Sorry! You have entered wrong information.';
				}
				else{
					var temp = new Array();
					temp = getValue.split('||||');					
					document.getElementById('customer_email_err').innerHTML = temp[0];				
					document.getElementById('overAll_err').innerHTML = temp[2];
				}
			}
		}
	}
	oHTTP.send(null);
}



/*IMAGE FADE I9N FADE OUT JAVASCRIPT START */

nereidFadeObjects = new Object();
nereidFadeTimers = new Object();


function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){  //do this so I can take a string too
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
        
    clearTimeout(nereidFadeTimers[object.sourceIndex]);
    
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;

    if (object.filters.alpha.opacity != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
        nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}

function fillUpBillingAddress() {
	if(document.forms['address'].elements['samebilling'].checked==true) {
		document.forms['address'].elements['shipping_name'].value = document.forms['address'].elements['billing_name'].value;
		document.forms['address'].elements['shipping_street_address'].value = document.forms['address'].elements['billing_street_address'].value;
		document.forms['address'].elements['shipping_post_code'].value = document.forms['address'].elements['billing_post_code'].value;
		document.forms['address'].elements['shipping_city'].value = document.forms['address'].elements['billing_city'].value;
		document.forms['address'].elements['shipping_state'].value = document.forms['address'].elements['billing_state'].value;
		document.forms['address'].elements['shipping_country'].value = document.forms['address'].elements['billing_country'].value;
		document.forms['address'].elements['shipping_email'].value = document.forms['address'].elements['billing_email'].value;
	}
	else {
		document.forms['address'].elements['shipping_name'].value = '';
		document.forms['address'].elements['shipping_street_address'].value = '';
		document.forms['address'].elements['shipping_post_code'].value = '';
		document.forms['address'].elements['shipping_city'].value = '';
		document.forms['address'].elements['shipping_state'].value = '';
		document.forms['address'].elements['shipping_country'].value = '';
		document.forms['address'].elements['shipping_email'].value = '';
	}
}

/*IMAGE FADE I9N FADE OUT JAVASCRIPT END */

/*!!!!!!!!!!!!!!!!!!!!!!!!!!! email validation !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1*/
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateEmail(){
	var emailID=document.emailform.newsletter_email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! end email validation !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/<!-- 