function clearText(thefield)
{
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
}

function clearSearchBox()
{
  var theForm = document.searchForm;
  
  if (theForm.searchKey.value == "")
  {
    theForm.searchKey.value = "";
  }
}
 

function Go(location, cat_id) {
	var key = document.orderby.orderselect.options[document.orderby.orderselect.selectedIndex].value;
	var ref = location + 'devices/' + cat_id +'/0/' + key + '/index.html';		
	document.location.href = ref;
} 

function GoCompare(location, cat_id) {	
	if (document.all)
	   key = document.getElementById("device1").value;	
	else
	   var key = document.compare1.device1.options[document.compare1.device1.selectedIndex].value;

	if (cat_id == "")
		cat_id = 0;

	var ref = location + 'devices/compare/' + key +'/' + cat_id + '.html';
	document.location.href = ref;
} 


function GoCompare2(location, cat_id) {	
	if (document.all)
	   key = document.getElementById("device2").value;	
	else
	   var key = document.compare2.device2.options[document.compare2.device2.selectedIndex].value;

	if (cat_id == "")
		cat_id = 0;

	var ref = location + 'devices/compare/' + cat_id +'/' + key + '.html';
	document.location.href = ref;
} 


function iLite(field, theColor)
{
	field.style.backgroundColor= theColor;
}
function prettyPrint()
{
	if (window.print) 
		window.print();
}
function MM_jumpMenu(targ,selObj,restore)
{ //v3.0

eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}


function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

function openwindow(master){
newWindow=window.open (master,"Details","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=400,height=250,left=250,top=150");
newWindow.focus();
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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+' must contain a valid email address.\n';
      } else if (test!='R') {
        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 (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' si '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += 'The field '+nm+' is required.\n'; }
  } if (errors) alert('There are some errors:\n'+errors);
  document.MM_returnValue = (errors == '');
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function openWin(url, name, w, h) {
    var left = Math.round((screen.availWidth - w)/2);
    var top = Math.round((screen.availHeight-h)/2);
    win = window.open(url, name, "scrollbars=yes,toolbar=no,resizable=yes,menubar=no"
            + ",width=" + w + ",height=" + h
            + ",left=" + left + ",top=" + top);
    win.location.href = url;
    win.focus();
}

function verificaTelefon(destination,manufacturer,telefon)
{
	newWindow=window.open (destination+"php/devices/verificadevice.php?manufacturer="+manufacturer+"&telefon="+telefon,"Verifica","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=480,height=400,left=350,top=150");
	newWindow.focus();
}

