jQuery.noConflict();
jQuery(document).ready(
	function () {
	url = window.location;
		var altura = jQuery('#vmMainPage').height();
		if(altura > 800){
			jQuery('#izquierda').height(altura);
			jQuery('#derecha').height(altura);
		} else {
			jQuery('#izquierda').height(970);
			jQuery('#derecha').height(970);
		}
		/*if(url == "http://www.publi-kate.com/web/promociones.html" ){
			jQuery("#promos table td").attr('width','140');
			jQuery("#promos table").attr('cellspacing','5');			
			jQuery("#promos table td div").attr('style','height: 77px; float: left; width: 140px; line-height: 14px;');					
		}*/
		jQuery('.requerido').after(" <span class='red'>*</span>");
		
		//Define correo de registro.
		var variables = getUrlVars();
		var elcorreo = variables['correo'];
		if(elcorreo != null){
			jQuery('#email_registro').val(elcorreo);
		}
	
	}
);
/***********************************************************************
	OBTIENE VARIABLES GET
************************************************************************/
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
 
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
 
    return vars;
}
/*************************************       FUNCION FORMULARIO      *********************************************/
function enviar_formulario () {
	var Nombre = jQuery('#nombre').val();
	var Correo = jQuery('#emailcontacto').val();
	var Telefono = jQuery('#telefono').val();
	var Comentarios = jQuery('#comentario').val();

	if(Nombre == "") {
		alert("El campo Nombre es obligatorio.");
		return false;
	}
	if(Correo == "") {
		alert("El campo Correo es obligatorio.");
		return false;
	}
	if(Comentarios == "") {
		alert("El campo Comentario es obligatorio.");
		return false;
	}
	
	
	jQuery('#centro #contacto').fadeOut(500, function(){jQuery("#contacto").load('/web/formulario.php', {'Nombre' : Nombre, 'Correo' : Correo, 'Telefono' : Telefono, 'Comentarios' : Comentarios},function (){
	jQuery('#centro #contacto').fadeIn(1000);
		});
    });
	
}
/***********************************************************************
	FUNCION PARA ENVIAR FORMULARIO
************************************************************************/
function envia_formulario (forma,div,url) {
	var consulta = {};
	var bandera = true;
	jQuery('#' + forma + ' :input').each(function(){
		var serequiere = jQuery(this).hasClass('requerido');
		var elid = jQuery(this).attr('id');
		if(elid != undefined){
			var elvalor = jQuery('#' + elid).val();
			if(serequiere){
				if(elvalor == ""){
					alert('El campo ' + elid.toUpperCase() + ' es obligatorio.');
					bandera = false;
					return false;
				}
			}
			consulta[elid] = elvalor;
		}
	});
	if (bandera){
		jQuery('#' + div).fadeOut(500, function(){
			jQuery(this).html('Cargando...').fadeIn(500, function(){
				jQuery(this).fadeOut(500, function() {
					jQuery(this).load(url, consulta, function(){
						jQuery(this).fadeIn(500);
						jQuery('.requerido').after(" <span class='red'>*</span>");
					});
				});
			});
		});
	}
}
/**********************************************************
	 FUNCION DE REGISTRO
***********************************************************/
function email_registro() {
	var correo = jQuery('#email').val();
	var laurles = "/web/correo.html?correo=" + correo;
	window.open(laurles,'_self');
}
