function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) {
  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_swapImage() { 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openCenteredWindow(url, height, width, name, parms) {
   var left = Math.floor( (screen.width - width) / 2);
   var top = Math.floor( (screen.height - height) / 2);
   var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
   if (parms) { winParms += "," + parms; }
   var win = window.open(url, name, winParms);
   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
   return win;
}

function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}

function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function MM_goToURL() { 
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}

function update(url, index) 
{
	currentImage = index;
	document['picture'].src=url;
	return;
}

function setvalor(){
	//if window.document.form1.entrega.value = "pick"{
		window.document.form1.ship.value = "0";
	//}
}

function showflat(){
			flat.style.visibility = 'visible';		
	}
	
function hideflat(){
			flat.style.visibility = 'hidden';
	}
	
function showsin(){
			sinsurance.style.visibility = 'visible';	
	}
	
function hidesin(){
			sinsurance.style.visibility = 'hidden';
	}
	
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		
		html += '\n</HE' + 'AD>\n<BODY>\n';
		
		var printReadyElem = document.getElementById("printReady");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
			
		html += '\n</BO' + 'DY>\n</HT' + 'ML>';
		
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}

function update(url, index) 
{
	currentImage = index;
	document['picture'].src=url;
	return;
}

function selectAll(f,n,v) {
		var chk   = ( v == null ? true : v );
		for (i = 0; i < f.elements.length; i++) {
			if( f.elements[i].type == 'checkbox' && f.elements[i].name == n ) {
				f.elements[i].checked = chk; }
		}
}


//Added by Raul Grimaldo to clear and restore default value to text 
//==========================================================
function SetHandlers(){
	for(var i=0;i<document.forms.length;i++){
		f=document.forms[i];
		for(var j=0;j<f.length;j++){
			c=f[j];
			if(c.type=="text" || c.type=="textarea"){
				c.onfocus=clearDefault;
				c.onblur=restoreDefault;
			}
		}
	}
}
function restoreDefault(){
	if (!this.value){
		this.value=this.defaultValue;
	}
}
function clearDefault(){
	if (this.value==this.defaultValue){
		this.value="";
	}
}


function setmetro(metrocombo3){
	wcv_iGeo3ID = metrocombo3[metrocombo3.selectedIndex].value;
	//publicacity(metrocombo3, document.form1.city);
	//publicalista(document.form1.tstate, document.form1.geomaster);
}


function publicastates(wsv_objCombo, wsv_StateFromMetro){
	
	var sLastState
	var wcv_iSelectThis;
	//alert (arreglostatesmetros[1][1]);
	wcv_iSelectThis=-1; 
	wsv_objCombo.length = 1;
	sLastState="";
	if (sLastState=="") sLastState=wsv_StateFromMetro;
	for(i=0;i<arreglostatesmetros.length;i++){
		if ((wcv_iSelectThis==-1) && (sLastState != "")) {
			if (arreglostatesmetros[i][0]==sLastState) {
				wcv_iSelectThis=i+1;
			}
		}
		//alert ("hey");
		var wcv_moOption = new Option(arreglostatesmetros[i][1], arreglostatesmetros[i][0]);
		wsv_objCombo.options[wsv_objCombo.length]=wcv_moOption;

	}
	if (wcv_iSelectThis != -1) {wsv_objCombo.selectedIndex=wcv_iSelectThis;}
		
	return true
}


function publicalista2(statecombo22,metrocombo32){ 
  metrocombo32.length = 1;
  if (statecombo22[statecombo22.selectedIndex].value == '') {
	resetmetro2(metrocombo32);
	return true;
  }
  
  if (statecombo22[statecombo22.selectedIndex].text != "Category") {metrocombo32.length = 0}
  for(i=0;i<arreglostatesmetros.length;i++){
	if(arreglostatesmetros[i][0] == statecombo22[statecombo22.selectedIndex].value){
		var wcv_iGeo2ID = statecombo22[statecombo22.selectedIndex].value;
		for (k=0;k<arreglostatesmetros[i][2].length;k++){
			var wcv_moOption2 = new Option(arreglostatesmetros[i][2][k][2], arreglostatesmetros[i][2][k][1]);
			metrocombo32.options[metrocombo32.length]=wcv_moOption2;
		}
		break;
	}
  }

  var iMatchedLastMetro='';
  var iMatchedQSMetro='';
  for(i=0;i<metrocombo32.options.length;i++){
	if(metrocombo32[i].value == '0'){iMatchedQSMetro = i  }
  }


  //if lastmetro, then select that if qs, then select that, otherwise 0
  i=0;
  if(iMatchedQSMetro!=''){i = iMatchedQSMetro}
  if(iMatchedLastMetro!=''){i = iMatchedLastMetro}
  metrocombo32.options.selectedIndex = i;

  setmetro2(metrocombo32);

  return true;
}

// this function sets the value of the tracking variable (sLastMetro)
// in index.asp to the value of the currently selected metro
function setmetro2(metrocombo32){
	wcv_iGeo3ID = metrocombo32[metrocombo32.selectedIndex].value;
}
    
// this function resets the Metro box to its default state,
// clearing out all other items that might have been there previously    
function resetmetro2(metrocombo32){
	metrocombo32.length = 1;
	metrocombo32.options[0] = new Option("All Subcategories       ", "", true);
	metrocombo32.options.selectedIndex = 0;
}
function setstate2(statecombo22) {
	publicalista2(document.PROCESS.state2, document.PROCESS.county2);
}

var ids

function preguntar(ids){

 var where_to= confirm("Do you want to remove this product?");
 if (where_to== true)
 {
   window.location="products.asp?del=yes&id="+ids;
 }

}

function applyvals() {
	products.applyc.value=1;
	products.submit();
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//===========================================

