function clean(obj,t)
{
	if(obj.value == t)
	{
		obj.value = '';	
	}
}

function refreshCarrito(este)
{
	var cant = parseInt(este.value);
	if(!isNaN(cant))
	{
		setTimeout("document.getElementById('carrito_main').submit()",1000);
	}
}

function comprar()
{
	var texto = '';
	
	if(texto)
	{
		alert(texto);
	}
	else
	{
		document.getElementById('compra').value = 'ok';
		document.getElementById('carrito_main').submit();
	}
}

function log()
{
	var texto = '';
	
	if(texto)
	{
		alert(texto);
	}
	else
	{
		document.getElementById('log').submit();
	}
}

function post(url, vars){
	var xml = null;
	try {
		xml = new ActiveXObject('Microsoft.XMLHTTP');
	}catch(exception){
		xml = new XMLHttpRequest();
	}
	xml.open('POST',url,false);
	xml.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xml.send (vars);
	if(xml.status == 404) alert('Url no valida');
	return xml.responseText;
}

function popup(URL,w,h,vars) {
	
        var left = (screen.width - w) / 2;
        var top  = (screen.height - h) / 2
	
	window.open(URL,"","left="+left+",top=" + top + ",width="+w+",height="+h+",scrollbars=yes" + vars);
	
}

function jump(url,selected){
	location = url+selected.options[selected.selectedIndex].value;
}

function viewPic(img){    
   picfile = new Image();    picfile.src =(img);    fileCheck(img); }

function fileCheck(img){    
   if( (picfile.width!=0) && (picfile.height!=0) ){        makeWindow(img);    }else{
       funzione="fileCheck('"+img+"')";        intervallo=setTimeout(funzione,50);    }
}

function makeWindow(img){    
   ht = picfile.height;
    wd = picfile.width;

   var args= "height=" + ht + ",innerHeight=" + ht;
   args += ",width=" + wd + ",innerWidth=" + wd;
   if (window.screen){
       var avht = screen.availHeight;        var avwd = screen.availWidth;
       var xcen = (avwd - wd) / 2;        var ycen = (avht - ht) / 2;
       args += ",left=" + xcen + ",screenX=" + xcen;
       args += ",top=" + ycen + ",screenY=" + ycen + ",resizable=yes";    
   }
   popwin=window.open("","_blank",args)
    popwin.document.open();
    popwin.document.write('<html><head><title>'+img+'</title></head><body bgcolor=white scroll=no topmargin=0 leftmargin=0 rightmargin=0 bottomargin=0 marginheight=0 marginwidth=0><div style="position: absolute; top:0px;left:0px"><a href="javascript:window.close()"><img src="'+img+'" width="'+wd+'" height="'+ht+'" border="0"></a></div></body></html>')
    popwin.document.close()
}

function isMail(id)
{
    var s = document.getElementById(id);
    var filter=/^[A-Za-z][A-Za-z0-9_.-]*@[A-Za-z0-9_.-]+\.[A-Za-z0-9]+[A-za-z]$/;
    if (s.length == 0 ) return true;
    
    if (filter.test(s.value)){
    	return true;
    }else{
    	return false;
    }
}
