function goTo(_url, _target) {
	document.location=_url;
}

function openImgZoom(_p_ref, _wname) {
	//openPopup('zoom.php?p_ref='+_p_ref, 'zoom', '250', '250');
	var son=window.open(url_root+'catalog/product_info.php?p_ref='+_p_ref+'&'+session_name+'='+session_id, _wname,'scrollbars=yes,resizable=yes,width='+'1000'+',height='+'900'+',status=no,location=no,toolbar=no,menubar=no');
	son.focus();
}

function openImgZoomGeneric(_path_img, _p_ref_list) {
	var son=window.open(url_root+'catalog/zoom_show.php?path_img='+_path_img+'&'+session_name+'='+session_id+'&p_ref_list='+_p_ref_list, 'zoom','scrollbars=yes,resizable=yes,width='+'800'+',height='+'750'+',status=no,location=no,toolbar=no,menubar=no');
	son.focus();
}

function openInfoPaiement() {
	var son=window.open(url_root+'info_paiement.php'+'?popup_width=580&'+session_name+'='+session_id, 'paiement','scrollbars=yes,resizable=yes,width=640,height=600,status=yes,location=no,toolbar=no,menubar=no');
	son.focus();
}

function openCallBackPopup(_origine_call_back) {
	var son=window.open(url_root+'contact/call_back.php?origine_call_back='+_origine_call_back+'&'+session_name+'='+session_id, 'call_back','scrollbars=yes,resizable=yes,width=400,height=400,status=yes,location=no,toolbar=no,menubar=no');
	son.focus();
}

function openPopup(_url, _name, _width, _height) {
	var son=window.open(_url, _name,'scrollbars=yes,resizable=yes,width='+_width+',height='+_height+',status=yes,location=no,toolbar=no,menubar=no');
	son.focus();
}
function openPopupRaw(_url, _name, _raw_option) {
	var son=window.open(_url, _name, _raw_option);
	son.focus();
}
function openPopupImg(_url, _name, _width, _height) {
	var son=window.open(_url, _name,'scrollbars=no,resizable=yes,width='+_width+',height='+_height+',status=no,location=no,toolbar=no,menubar=no');
	son.focus();
}

function openForgotPwd() {
	var son=window.open(url_root+'customer/forgot_pwd.php?'+session_name+'='+session_id, 'forgot_pwd','scrollbars=yes,resizable=yes,width=500,height=450,status=yes,location=no,toolbar=no,menubar=no');
	son.focus();
}

function addFavorite() {
	if (window.external)
		window.external.AddFavorite(location.href, document.title) ;
	else
		alert("Votre navigateur ne supporte pas cette fonctionnalité. "
		+ "Si vous utilisez Netscape Navigator --\n"
		+ "Cliquez sur \"Signets\" puis \"Ajouter la page en cours\" "
		+ "ou tapez \"Ctrl+D\" pour ajouter PeauDeVache.com à vos signets.");
}


function verifEmail(email) {
   var reg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,3}$/
   return (reg.exec(email)!=null)
}



function _pdv_calculette_product_info(_this_form, _shipping_included) {
	var res=0;
	var p_ref = _this_form.p_ref.value;	
	var pi_ref_itemObj = _this_form.pi_ref_item;	
	if (pi_ref_itemObj.length>1) {
		for (i=0;i<pi_ref_itemObj.length;i++) {
			var aRadio= pi_ref_itemObj[i];
			if (aRadio.checked==1) {
				res=1;
				_montant=eval('_this_form.montant['+i+'].value');
			}
		}
	}
	else {
		res=1;
		_montant=eval('_this_form.montant.value');
	}
	if (res==0) {
		alert('Merci de sélectionner une taille avant de cliquer sur le bouton CALCULER.');
	}
	else {
		var son=window.open(url_root+'catalog/calculette.php?montant='+_montant+'&shipping_included='+_shipping_included,'calculette','width=600,height=495,toolbar=false,scrollbars=yes');	
		son.focus();					
	}
}


function _pdv_calculette(_montant, _shipping_included) {
		var son=window.open(url_root+'catalog/calculette.php?montant='+_montant+'&shipping_included='+_shipping_included,'calculette','width=600,height=495,toolbar=false,scrollbars=yes');	
		son.focus();					
}

function formatNumber(num) {
	num = eval(num);
	num *= 100;
	num = Math.round(num)/100;
	
	if (num - Math.floor(num) == 0) {
		num = num + ".00";
	} else {
		string = num.toString();
		parts = string.split(".");
		cents = parts[1];
			if (cents.length == 1) {
				num = num + "0";
			}
	}
	return num;
}


// ------------------------------------------------------------------------

var no_close_popup=0

function handleOnClose() {
	if (no_close_popup!=1 && iex) {
		//openOnClose();
	}
}

function setNoOnClosePopup() {
	no_close_popup=1;
}

function getOpenerLocation() {
	var opener_loc = ''
	try {opener_loc = parent.opener.location;}
	catch (err) {}
	return opener_loc;
}

function openOnClose() {
	if (event.clientY < 0) {
		var opener_loc = getOpenerLocation();
		if (opener_loc=='') {
			//event.returnValue = 'Are you sure you want to leave the page (NO PARENT)?';
			//window.open('http://www.google.fr', 'Google', 200, 200);
			
			//msg_txt = "Merci pour votre visite!\nSouhaitez-vous profiter de nos prochaines ventes privées?";
			//if ( confirm(msg_txt) ) {}
			openPopup(url_root+'contact/onclose_popup.php', 'popupOnClose', '600', '600');
			
		}
		else {
			//alert(url_root);
		}
	}
}

// ------------------------------------------------------------------------
