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

function cleanAndSetPassType()
{
	var cont  = document.getElementById('clave_cont');
	var clave = document.getElementById('clave_log');

	if(clave.value == 'clave')
	{
		cont.innerHTML = '<input type="password" id="clave_log" name="clave_log" value="">';
		
		document.getElementById('clave_log').focus();	
	}	
}


function motor_productos()
{
	var html_productos_asociados = document.getElementById('html_productos_asociados');
	var html_productos_relacionados = document.getElementById('html_productos_relacionados');

	var html = '';
	
	if(html_productos_asociados)
	{
		html = '';
		for(var i in lista_productos_asociados)
		{
			if(lista_productos_asociados[i] != '')
			{
				html+='<input type="hidden" name="productos_asociados[]" value="'+i+'" />';
				html+='<a href="javascript:borrarAlgo(\'productos_asociados\','+i+')"><img src="images/ico_trash.gif" /></a> '+lista_productos_asociados[i]+'<br />';
			}
		}
		
		html_productos_asociados.innerHTML = html;
	}
	
	if(html_productos_relacionados)
	{
		
		html = '';
		var html = '';
		for(var i in lista_productos_relacionados)
		{
			if(lista_productos_relacionados[i] != '')
			{
				html+='<input type="hidden" name="productos_relacionados[]" value="'+i+'" />';
				html+='<a href="javascript:borrarAlgo(\'productos_relacionados\','+i+')"><img src="images/ico_trash.gif" /></a> '+lista_productos_relacionados[i]+'<br />';
			}
		}
		
		html_productos_relacionados.innerHTML = html;
	}
}

function select_jump(obj,url){
	document.location = url+obj.options[obj.selectedIndex].value;
}

function colorin(obj,color){ 
	obj.style.backgroundColor=color;
}

function eliminar(preg,URL) {
	if(confirm(preg)) {
		location = URL;
	}
}



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+",scrollbars=yes,height="+h+vars);
	
}

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 isEmail(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;
	}	
}
