function toggle(div_id) {
	
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}

function mail(num)
{
	var mailTo = "rmendez@mail.suzuki.cr";//Zapote rmendez@suzuki.cr
	var nombre = document.getElementById('txtNombre').value;
	var email = document.getElementById('txtEmail').value;
	var tel = document.getElementById('txtTel').value;
	var cel = document.getElementById('txtCel').value;
		
	if(document.getElementById('uruca').checked)//Uruk ediaz@suzuki.cr
	{ mailTo = "bernal@suzuki.cr"; }//Uruk
		
	if(num==2)
	{	mail_str= "../"; }	
	else mail_str="";
	
	mail_str += "Usados/Enviardatos.asp?mailTo="+ mailTo + "&nombre=" + nombre  + "&email=" + email + "&tel=" + tel + "&cel=" + cel;
	
	if(email.length==0 || email==null)
	{ 	
		document.getElementById('txtEmail').style.backgroundColor = '#EB1C24'; 
	}
	else
	{
		document.getElementById('txtEmail').style.backgroundColor = '#ffffff';
		window.open(mail_str, '_blank','mywindow', 'top=100, left=100, height=350, width=150, status=no, menubar=no, resizable=no,scrollbars=yes, toolbar=no, location=no, directories=no');
		
		document.getElementById('popUpUsados').style.display = 'block'; 
		document.getElementById('popUpFormUsados').style.display = 'none';
		
	}
}

function displayForm2(divToDisplay, divToHide)
{
		document.getElementById(divToDisplay).style.display = 'block'; 
		document.getElementById(divToHide).style.display = 'none';
		document.getElementById('f2email').style.backgroundColor = '#ffffff';
}

function mailForm2()
{
	var mailTo = "aaltamirano@suzukipan.com";
	var nombre = document.getElementById('f2nombre').value;
	var tel = document.getElementById('f2telefono').value;
	var email = document.getElementById('f2email').value;	
	var veh = document.getElementById('f2vehiculo').value;	
	var sucursal = document.getElementById('f2sucursal').value;
	var comm = document.getElementById('f2comentario').value;	
	
	str_mail = "../Home/form2/Enviardatos.asp?mailTo="+ mailTo + "&nombre=" + nombre  + "&email=" + email + "&tel=" + tel + "&veh=" + veh + "&sucursal=" + sucursal  + "&comm=" + comm;
	//alert(str_mail);
	
	if(email.length==0 || email==null)
	{ 	
		//alert("Ingrese su Email"); 	
		//document.getElementById('mensaje').style.display = 'block'; // <label id="mensaje" style="display:none; color:#EB1C24">*</label>
		document.getElementById('f2email').style.backgroundColor = '#FFFF00'; 
	}
	else
	{
		document.getElementById('f2email').style.backgroundColor = '#ffffff';
		window.open(str_mail, '_blank','top=100, left=100, height=400, width=800, status=no, menubar=no, resizable=no, scrollbars=yes, toolbar=no, location=no, directories=no');
		
		document.getElementById('btnForm2').style.display = 'block'; 
		document.getElementById('form2').style.display = 'none';
	}
}

function blanket_size(popUpDivVar) {
	
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=blanket_height/2-250;//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
}

function window_pos(popUpDivVar) {
	
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} 
	else {
		viewportwidth = document.documentElement.clientHeight;
	}
	
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} 
	else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} 
		else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-250;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}

function popup(windowname){
	
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}