function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una dirección e-mail válida.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' debe ser especificado.\n'; }
  } if (errors) alert('Información obligatoria:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function changeCountry(paginaActual) { //v1.0
  //alert (paginaActual)
  	pName = document.orderform.name.value
  	pLastName = document.orderform.lastName.value
  	pCustomerCompany = document.orderform.customerCompany.value
  	pPhone = document.orderform.phone.value
  	pEmail = document.orderform.email.value
  	pCedula_rif = document.orderform.cedula_rif.value
  	pAddress = document.orderform.address.value
  	pZip = document.orderform.zip.value
  	pStateCode = document.orderform.stateCode.value
  	pCity = document.orderform.city.value
  	pIdPayment = document.orderform.idPayment.value
	pSeparateShipping = document.orderform.separateShipping.checked
  	pDiscountCode = document.orderform.discountCode.value
	parms = "?newCountry=" + document.orderform.countryCode.value
	parms = parms + "&pName=" + pName + "&pLastName=" + pLastName
	parms = parms + "&pCustomerCompany=" + pCustomerCompany + "&pPhone=" + pPhone
	parms = parms + "&pEmail=" + pEmail + "&pCedula_rif=" + pCedula_rif
	parms = parms + "&pAddress=" + pAddress + "&pZip=" + pZip
	parms = parms + "&pStateCode=" + pStateCode + "&pCity=" + pCity
	parms = parms + "&pIdPayment=" + pIdPayment + "&pSeparateShipping=" + pSeparateShipping
	parms = parms + "&pDiscountCode=" + pDiscountCode
  document.location = "" + paginaActual + parms + "";
}

function changeShippingCountry() { //v1.0
  	pShippingAddress = document.shippingform.shippingAddress.value
  	pShippingCity = document.shippingform.shippingCity.value
  	pShippingZip = document.shippingform.shippingZip.value
  	pShippingStateCode = document.shippingform.shippingStateCode.value
  	parms = "?newShippingCountry=" + document.shippingform.shippingCountryCode.value
	parms = parms + "&pShippingAddress=" + pShippingAddress + "&pShippingCity=" + pShippingCity
	parms = parms + "&pShippingZip=" + pShippingZip + "&pShippingStateCode=" + pShippingStateCode
document.location = "comersus_checkShippingAddress.asp" + parms + "";
}

function SaveOrder(){
if (document.saveorder.agree.checked == false)
{
alert('Para poder continuar, debe aceptar las Condiciones Generales');
}else
document.saveorder.submit();
}

var hwndPopup_29cf;
function openpopup_29cf(url){
var ua = window.navigator.userAgent;
var isOpera = (ua.indexOf("Opera") > -1);
if (isOpera) {
	var i = ua.indexOf("Opera");
	var operaVersion = ua.substring(i + 6, ua.indexOf(" ", i + 8));		
	if (operaVersion > 7.00) {
		var isAccessible = false;
		eval("try { isAccessible = ( (hwndPopup_29cf != null) && !hwndPopup_29cf.closed ); } catch(exc) {  } ");
		if (!isAccessible) {
			hwndPopup_29cf = null;
		}
	}			
}
	
if ( (hwndPopup_29cf == null) || hwndPopup_29cf.closed ) {		
	hwndPopup_29cf = window.open("","popupwin_29cf","toolbar=0, scrollbars=1, menubar=0, status=0, resizable=0");
	hwndPopup_29cf.resizeTo(400, 500);
	hwndPopup_29cf.moveTo((screen.width-400)/2, (screen.height-500)/2);
	hwndPopup_29cf.focus(); 
	with(hwndPopup_29cf.document) {
		open();
		write("<ht"+"ml><he"+"ad></he"+"ad><bo"+"dy onLoad=\"document.location='" + url + "'\"></bo"+"dy></ht"+"ml>");
		close();
	}
} else {
	hwndPopup_29cf.focus();
	hwndPopup_29cf.location.href = url;
}
}

function SetFocusToSubmit1() {
//alert ('hola');
document.form_buscar.btnBuscar.focus();
}

function SetFocusToSubmit2() {
//alert ('hola');
document.orderform.Submit.focus();
}

function SetFocusToSubmit3() {
//alert ('hola');
document.shippingform.Submit.focus();
}

function errorimagen(img)
{
document.images[img.name].src = "images/no_disponible.jpg"
}

function LinkOfertas()
{
	document.location.href="/store/comersus_listCategoriesAndProducts.asp?idCategory=53";
}