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 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;
}

//===========================================

