
var links={
	
}


var curves = {		
	createPatrocinadores:function(){
		var cBLeft = cBRight = null;
		var obj = $("#patrocinadores");
		cBLeft = curves.createElementsCurves("cBl");
		cBRight = curves.createElementsCurves("cBr");
		obj.append(cBLeft);
		obj.append(cBRight);
	},
	createFooterLinks:function(){
		var cTLeft = cTRight = null;
		var obj = $("#footerLinks");
		cTLeft = curves.createElementsCurves("cTl");
		cTRight = curves.createElementsCurves("cTr");
		obj.append(cTLeft);
		obj.append(cTRight);
	},
	createElementsCurves:function(style){
		return $("<div class='sp " + style + "'>&nbsp;</div>");
	}
}

var fixes={	
	fix:function(){
		return $("<div class='fix png'>&nbsp;</div>");		
	},
	fixType2:function(){
		return $("<span class='fix png'>&nbsp;</span>");		
	}
}

var behaviours = {	
	borraCampo:function(){
		$("#header input.text").focus(function(){$(this).attr("value","")})
	}
}

var filterResults = {
	init:function(){
		var obj = $("#filterResults");
		$(obj).find("ul").eq(0).addClass("Jv");
	}
}

var carruseles = {
	
	init: function(){		 
		$(".carrousel ul").jcarousel({
			scroll: 1				
		});
		$(".carrouselHome ul").jcarousel({
			scroll: 1				
		});
	}
	
}

/* validaciones de formularios */
var formsValidations = {
	setMsgError:function(txt, form){
		var parentForm = form.parent();
		var msgError = parentForm.find(".msgError");
		var divElement = (msgError.length != 0) ? msgError.eq(0) : document.createElement("div");		
		var ulElement = document.createElement("ul");
		var liElement = null;		
		var errors = txt.split("|");				
		jQuery(divElement).attr("class", "msgError");
		jQuery(divElement).attr("tabIndex","-1");
		if(jQuery(divElement).find("ul").length != 0) jQuery(divElement).empty();
		for(var i = 0; i < errors.length - 1; i++){
			liElement = document.createElement("li");
			liElement.appendChild(document.createTextNode(errors[i]));
			ulElement.appendChild(liElement);
		}
		jQuery(divElement).append(ulElement);		
		if(msgError.length == 0) form.before(jQuery(divElement));
		jQuery(divElement).focus();
	},	
	setMsgOK:function() {
		var ok = jQuery(".msgOk");
		if(ok.length != 0)
			ok.remove();
	},
	validaVoluntarioForm:function(obj){
		var errorTxt = "";
		var f = jQuery(obj);			
		if(!f.find("input[@id='empresa']").attr("value")){
			errorTxt += literal["voluntario"][0];			
		} 		
		if(!f.find("input[@id='contacto']").attr("value")){
			errorTxt += literal["voluntario"][1];			
		} 
		if (!f.find("input[@id='email']").attr("value")) {
			errorTxt += literal["voluntario"][2];
		}else {
			if (!regularExpressions.isValidEmail(f.find("input[@id='email']").attr("value"))) {				
				errorTxt += literal["voluntario"][3];
			}
		}
		if(!f.find("input[@id='direccion']").attr("value")){
			errorTxt += literal["voluntario"][4];						
		} 		
		if(!f.find("input[@id='telefono']").attr("value")){
			errorTxt += literal["voluntario"][5];			
		} 
		if(errorTxt != ""){	
			formsValidations.setMsgError(errorTxt, f);
			return false;
		}else return true;
	}
}



/* expresiones regulares para validar formularios */


jQuery(document).ready(function() {	
	if($(".carrousel").length != 0) carruseles.init();	
	if($(".carrouselHome").length != 0) carruseles.init();	
	if($(".varios").length != 0) fixes.links();	
});	

