function quantity(type,obj){
	if(type=='moins' && obj.value>1)
		obj.value=parseInt(obj.value)-1;
	else if(type=='plus')
		obj.value=parseInt(obj.value)+1;
}
function checkEmail(stringIn) {
	if (stringIn.indexOf("@") < 1){
		return false;
	}else{
		st = stringIn.substr(stringIn.indexOf("@"));
		if(st.indexOf(".") == -1){
			return false;
		}else{
			if(!checkNormalChar(stringIn)){
				return false;
			}else{
				return true;
			}
		}
	}
}
function checkNormalChar(stringIn) {
	 retval = false 
	 var i;
     for (i=0;i<=stringIn.length-1;i++) { 
     	 //cho phep nhung ky tu tu A->Z, a->z, 0->9,va cac ky tu @,_
	      if (((stringIn.charCodeAt(i) >= 48)&&(stringIn.charCodeAt(i) <= 57)) || ((stringIn.charCodeAt(i) >= 64)&&(stringIn.charCodeAt(i) <= 90)) || ((stringIn.charCodeAt(i) >= 97)&&(stringIn.charCodeAt(i) <= 122)) ||(stringIn.charCodeAt(i)==95) ||(stringIn.charCodeAt(i)==46) ||(stringIn.charCodeAt(i)==45)) { 
                retval = true;
      	  }else{
      	  		retval = false;
      	  		break;
         }
     }
	 return retval;
}
function change_zoom(id,pid,nzoom,newid,newvalue,ids,ids2){
	if(document.getElementById(id)){
		if(document.getElementById(id).style.display == "inline"){
			document.getElementById(id).style.display = "none";
			document.getElementById(id).style.position = "";
			if(newid && newvalue){
				if(document.getElementById('change_pdzoom').value=='1'){
					document.getElementById('pd_zoom').style.display = 'none';
				}else{
					document.getElementById('pd_zoom').style.display = '';
				}
			}
			if(ids){
				hide_all(ids);
			}
			if(newid){
				document.getElementById(newid).value = 'product_zoom';
				if(document.getElementById('pdtid_defaut'))	document.getElementById('change_img_hd').value = document.getElementById('pdtid_defaut').value;
			}
		}else{
			if(ids && ids2){
				hide_all(ids);
				hide_all(ids2);
			}
			document.getElementById(id).style.display = "inline";
			document.getElementById(id).style.position = "absolute";
			if(newid && newvalue){
				document.getElementById(newid).value = newvalue;
			}
			if(pid){
				document.getElementById('change_img_hd').value = pid;
				if(document.getElementById('pid_'+pid)){
					document.getElementById('pdtimg_'+pid).src=document.getElementById('pid_'+pid).value;
				}
			}
			if(document.getElementById('pd_zoom')){
				if(nzoom=='1'){
					document.getElementById('pd_zoom').style.display = 'none';
				}else{
					document.getElementById('pd_zoom').style.display = '';
				}
			}
		}
	}
}
function hideshow_id(id,type){
	if(type==1)
		document.getElementById(id).style.display = '';
	else
		document.getElementById(id).style.display = 'none';
}
function getElementsByName_iefix(tag, name) {
	 var elem = document.getElementsByTagName(tag);
	 var arr = new Array();
	 for(i = 0,iarr = 0; i < elem.length; i++) {
		  att = elem[i].getAttribute("name");
		  if(att == name) {
			   arr[iarr] = elem[i];
			   iarr++;
		  }
	 }
	 return arr;
}
function hide_all(id){
	for(var i=0;i<(getElementsByName_iefix('div',id).length);i++){
		getElementsByName_iefix('div',id)[i].style.display = "none";
		getElementsByName_iefix('div',id)[i].style.position = "";
	}
}
function hideall_class(type,id){
	for(var i=0;i<(getElementsByName_iefix(type,id).length);i++){
		getElementsByName_iefix(type,id)[i].className = "";
	}
}
function hideall(nzoom,newid,pid,ids,ids2){
	if(ids && ids2){
		hide_all(ids);
		hide_all(ids2);
	}
	document.getElementById(newid).value = 'product_zoom';
	document.getElementById('change_img_hd').value = pid;
	if(document.getElementById('pd_zoom')){
		if(nzoom=='1'){
			document.getElementById('pd_zoom').style.display = 'none';
		}else{
			document.getElementById('pd_zoom').style.display = '';
		}
	}
}

function writeCookie(nom,valeur,jours) {
var expDate = new Date()
expDate.setTime(expDate.getTime() + (jours * 24 * 3600 * 1000))
document.cookie = nom + "=" + escape(valeur)+ ";expires=" + expDate.toGMTString()
}
// this fixes an issue with the old method, ambiguous values 
// with this test document.cookie.indexOf( name + "=" );
function getCookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}	

if(getCookie( 'user_resolution' ) == null){
	writeCookie('user_resolution',screen.width +"x"+ screen.height,30);
}
/* LOGO RECEIVE&PAY in left.php*/
function popupcalc(merchantID,montant){ 		
	var win2 = window.open("http://www.receiveandpay.com/wallet/customer/calculette.php?MerchantID="+merchantID+"&Amount="+montant ,'popup','height=503,width=600,status=yes,scrollbars=yes,menubar=no,resizable=yes'); 
}
function popupRnp(name,url,width,height){
  var var_popuprnp = window.open(url, name ,'height='+height+',width='+width+',status=yes,scrollbars=yes,menubar=no,resizable=yes');
}

function popupWin(name,url,height){ 		
	window.open(url ,name,'height=500,width=600,status=yes,scrollbars=auto,menubar=no,resizable=yes'); 
}
