/******************************************************************************
* web.js
*
* Scripts generals per la web
*
*	Albert Sunyer @ Soluciones Multimedia Tec (SMTec) 2009 | http://www.smtec.es
******************************************************************************/

var WEB={
	xxxx:function(){
		
	}
}

$(document).ready(function(){
	/** Enllaços generals *******************************/
	$('a[rel="external"]').click(function(){
		window.open(''+this.href+'');
		return false;
	});
	
	$('a.legal').click(function(){
		//UTILS.popup($(this).attr('href'), "legal", 300, 400, 'yes');
		window.open(''+$(this).attr('href')+'','legal','width=500,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top='+((screen.height/2)-(200))+',left='+((screen.width/2) - (150)) + '');
		return false;
	});
	
	$('#frm').submit(function(){
		var ok=true;
		var cur=$('#cur');
		var nom=$('#nom');
		var cog1=$('#cog1');
		var cog2=$('#cog2');
		var tel=$('#tel');
		var mai=$('#mai');
		var prv=$('#prv');
		
		if(cur.val()==""){
			cur.addClass("falta");
			ok=false;
		}else{
			cur.removeClass("falta");
		}
		
		if(nom.val()==""){
			nom.addClass("falta");
			ok=false;
		}else{
			nom.removeClass("falta");
		}
		
		if(cog1.val()==""){
			cog1.addClass("falta");
			ok=false;
		}else{
			cog1.removeClass("falta");
		}
		
		if(cog2.val()==""){
			cog2.addClass("falta");
			ok=false;
		}else{
			cog2.removeClass("falta");
		}
		
		if(tel.val()==""){
			tel.addClass("falta");
			ok=false;
		}else{
			tel.removeClass("falta");
		}
		
		if(mai.val()=="" || !UTILS.isMail(mai.val())){
			mai.addClass("falta");
			ok=false;
		}else{
			mai.removeClass("falta");
		}
		
		if(prv.val()==""){
			prv.addClass("falta");
			ok=false;
		}else{
			prv.removeClass("falta");
		}
		
		if(prv.val()=="" || mai.val()=="" || tel.val()=="" || cog2.val()=="" || cog1.val()=="" || nom.val()==""  ){
		alert("Todos los campos son obligatorios");
		}
		
		return ok;
	});
	
	var flashvars={};
	var params={menu:"false", allowscriptaccess:"sameDomain", play:"true", loop:"true", quality:"high"};
	var attributes={id:'testimonials', name:'testimonials'};
	
	swfobject.embedSWF("img/bannertestimonio5.swf", "testimonials", "562", "73", "10.0.0","img/expressInstall.swf", flashvars, params, attributes);
	
	$.address.init(function(event){
		$('a.addr').address(function(){
			return $(this).attr('href').replace(location.pathname, '');
		});
	}).change(function(event){
		var text = (event.value == '') ? 'inicio' : event.pathNames[0];
		
		switch(text){
			case 'sistema':
				$("#videos").attr("style", "background-image:none;");
				$("#videos").html('<br /><object width="560" height="354"><param name="movie" value="http://www.youtube.com/v/nxi3xQt2YIg&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/nxi3xQt2YIg&hl=es_ES&fs=1&rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="354"></embed></object>');
				break;
			
			case 'ventajas_video':
				$("#videos").attr("style", "background-image:none;");
				$("#videos").html('<br /><object width="560" height="354"><param name="movie" value="http://www.youtube.com/v/UWiOom-3OPI&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/UWiOom-3OPI&hl=es_ES&fs=1&rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="354"></embed></object>');
				break;
			
			case 'titulacion-uoc':
				$("#videos").attr("style", "background-image:none;");
				$("#videos").html('<br /><object width="560" height="354"><param name="movie" value="http://www.youtube.com/v/jcv3shTWA0M&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/jcv3shTWA0M&hl=es_ES&fs=1&rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="354"></embed></object>');
				break;
				
				case 'doble-titulacion_video':
				$("#videos").attr("style", "background-image:none;");
			$("#videos").html('<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/WMps2IfWkGI?fs=1&amp;hl=es_ES&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/WMps2IfWkGI?fs=1&amp;hl=es_ES&amp;rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>');
				break;
			case 'doble-titulacion':
			case 'catalogo':
			case 'temario':
				$("#videos").attr("style", "background-image:none;");
				$("#videos").load(text + ".html");
				break;
			case 'metodologia':
			case 'ventajas':
				$("#videos").attr("style", "background-image:url(img/" + text + ".jpg)");
				$("#videos").load(text + ".html");
				break;
			
			case 'temario_long':
				$("#videos").attr("style", "background-image:url(img/" + text + ".jpg)");
				$("#videos").load(text + ".php");
				break;
			case 'profesion-de-futuro':
			case 'formacion-de-calidad':
			case 'unico-curso':
			case 'netbook':
				$("#videos").attr("style", "background-image:url(img/" + text + ".jpg)");
				$("#videos").load(text + ".html");
				break;
				
			case 'faq':
				$("#videos").attr("style", "background-image:url(img/" + text + ".jpg)");
				$("#videos").load(text + ".html");
				break;
			case 'otros_cursos':
				$("#videos").load(text + ".php");
				 break;
			case 'curso':
				$("#videos").attr("style", "background-image:none;");
				$("#videos").html('<br /><object width="560" height="354"><param name="movie" value="http://www.youtube.com/v/Bj5dr6SGY1Y&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Bj5dr6SGY1Y&hl=es_ES&fs=1&rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="354"></embed></object>');
				break;
			case 't1':
				$("#videos").attr("style", "background-image:none;");
				$("#videos").html('<br /><object style="height: 560px; width: 354px"><param name="movie" value="http://www.youtube.com/v/lQiXx8cnSC0?version=3"><param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><embed src="http://www.youtube.com/v/lQiXx8cnSC0?version=3&autoplay=1&rel=0" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="560" height="354"></object>');
				break;		
			case 't2':
				$("#videos").attr("style", "background-image:none;");
				$("#videos").html('<br /><object width="560" height="354"><param name="movie" value="http://www.youtube.com/v/9PXJaX3hZ8Y?fs=1&amp;hl=es_ES&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/9PXJaX3hZ8Y?fs=1&amp;hl=es_ES&amp;rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="354"></embed></object>');
				break;
			case 't3':
				$("#videos").attr("style", "background-image:none;");
				$("#videos").html('<br /><object width="560" height="354"><param name="movie" value="http://www.youtube.com/v/K43B2NbAH_M?fs=1&amp;hl=es_ES&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/K43B2NbAH_M?fs=1&amp;hl=es_ES&amp;rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="354"></embed></object>');
				break;
			
			case 't4':
			$("#videos").attr("style", "background-image:none;");
				$("#videos").html('<br /><object width="560" height="354"><param name="movie" value="http://www.youtube.com/v/hgIUx8b7lmM?fs=1&amp;hl=es_ES&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/hgIUx8b7lmM?fs=1&amp;hl=es_ES&amp;rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="354"></embed></object>');
				break;
			case 't5':
				$("#videos").attr("style", "background-image:none;");
				$("#videos").html('<br /><object width="560" height="354"><param name="movie" value="http://www.youtube.com/v/veZ0tLiE-7Q?fs=1&amp;hl=es_ES&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/veZ0tLiE-7Q?fs=1&amp;hl=es_ES&amp;rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="354"></embed></object>');
				break;
			case 't6':
				$("#videos").attr("style", "background-image:none;");
				$("#videos").html('<br /><object width="560" height="354"><param name="movie" value="http://www.youtube.com/v/9PXJaX3hZ8Y?fs=1&amp;hl=es_ES&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/9PXJaX3hZ8Y?fs=1&amp;hl=es_ES&amp;rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="354"></embed></object>');
				
				break;
			default:
				$("#videos").attr("style", "background-image:url(img/inicio.jpg)")
				$("#videos").load("inicio.html");
				break;
		}
		
		$('a.addr').each(function(){
			$(this).toggleClass('actual', $(this).attr('href') == '/' + text);
		});
	});
});

var num=new Array();

num[0]=0;
num[1]=0;
num[2]=0;
num[3]=0;
num[4]=0;
num[5]=0;
num[6]=0;
num[7]=0;
num[8]=0;
num[9]=0;
num[10]=0;
num[11]=0;
num[12]=0;

function ViewText(n){
	if(parseInt(num[n])%2==0){
		eval("document.getElementById('t"+n+"').style.display='';");
		eval("document.getElementById('t"+n+"').style.visibility='visible';");
	}
	else{
		eval("document.getElementById('t"+n+"').style.display='none';");
		eval("document.getElementById('t"+n+"').style.visibility='hidden';");
	}	
	
	num[n]=parseInt(num[n])+1;
	
}
