//http://www.featureblend.com/license.txt
var FlashDetect=new function(){var self=this;self.installed=false;self.raw="";self.major=-1;self.minor=-1;self.revision=-1;self.revisionStr="";var activeXDetectRules=[{"name":"ShockwaveFlash.ShockwaveFlash.7","version":function(obj){return getActiveXVersion(obj);}},{"name":"ShockwaveFlash.ShockwaveFlash.6","version":function(obj){var version="6,0,21";try{obj.AllowScriptAccess="always";version=getActiveXVersion(obj);}catch(err){}
return version;}},{"name":"ShockwaveFlash.ShockwaveFlash","version":function(obj){return getActiveXVersion(obj);}}];var getActiveXVersion=function(activeXObj){var version=-1;try{version=activeXObj.GetVariable("$version");}catch(err){}
return version;};var getActiveXObject=function(name){var obj=-1;try{obj=new ActiveXObject(name);}catch(err){obj={activeXError:true};}
return obj;};var parseActiveXVersion=function(str){var versionArray=str.split(",");return{"raw":str,"major":parseInt(versionArray[0].split(" ")[1],10),"minor":parseInt(versionArray[1],10),"revision":parseInt(versionArray[2],10),"revisionStr":versionArray[2]};};var parseStandardVersion=function(str){var descParts=str.split(/ +/);var majorMinor=descParts[2].split(/\./);var revisionStr=descParts[3];return{"raw":str,"major":parseInt(majorMinor[0],10),"minor":parseInt(majorMinor[1],10),"revisionStr":revisionStr,"revision":parseRevisionStrToInt(revisionStr)};};var parseRevisionStrToInt=function(str){return parseInt(str.replace(/[a-zA-Z]/g,""),10)||self.revision;};self.majorAtLeast=function(version){return self.major>=version;};self.minorAtLeast=function(version){return self.minor>=version;};self.revisionAtLeast=function(version){return self.revision>=version;};self.versionAtLeast=function(major){var properties=[self.major,self.minor,self.revision];var len=Math.min(properties.length,arguments.length);for(i=0;i<len;i++){if(properties[i]>=arguments[i]){if(i+1<len&&properties[i]==arguments[i]){continue;}else{return true;}}else{return false;}}};self.FlashDetect=function(){if(navigator.plugins&&navigator.plugins.length>0){var type='application/x-shockwave-flash';var mimeTypes=navigator.mimeTypes;if(mimeTypes&&mimeTypes[type]&&mimeTypes[type].enabledPlugin&&mimeTypes[type].enabledPlugin.description){var version=mimeTypes[type].enabledPlugin.description;var versionObj=parseStandardVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revisionStr=versionObj.revisionStr;self.revision=versionObj.revision;self.installed=true;}}else if(navigator.appVersion.indexOf("Mac")==-1&&window.execScript){var version=-1;for(var i=0;i<activeXDetectRules.length&&version==-1;i++){var obj=getActiveXObject(activeXDetectRules[i].name);if(!obj.activeXError){self.installed=true;version=activeXDetectRules[i].version(obj);if(version!=-1){var versionObj=parseActiveXVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revision=versionObj.revision;self.revisionStr=versionObj.revisionStr;}}}}}();};FlashDetect.JS_RELEASE="1.0.4";

$(function() {	
		 	
	$('.nwk-button.nwk-tw').each(function() {
			var iframeTweet = "";			
			iframeTweet += "<iframe scrolling=\"no\" width=\"64\" height=\"63\" allowtransparency=\"true\" frameborder=\"0\" src=\"http:\/\/platform.twitter.com\/widgets\/tweet_button.html?url="+$(this).parents('.post').find('.permlink').attr('href')+"&amp;via=carrerasfuturo&amp;text="+$(this).parents('.post').find('.permlink').text()+"&amp;count=vertical&amp;lang=en\" ><\/iframe>";			
			$(this).append(iframeTweet);
	});
	
	
	$('.small-buttons .nwk-button.nwk-tw-compact').each(function() {
			var iframeTweetCompact = "";
			iframeTweetCompact += "<iframe scrolling=\"no\" width=\"110\" height=\"20\" allowtransparency=\"true\" frameborder=\"0\" src=\"http:\/\/platform.twitter.com\/widgets\/tweet_button.html?url="+$('.post').find('.permlink').attr('href')+"&amp;via=carrerasfuturo&amp;text="+$('.post').find('.permlink').text()+"&amp;count=horizontal&amp;lang=es\" ><\/iframe>";		
			$(this).append(iframeTweetCompact);
	});
	
	$('.fb-like').each(function(){
		var iframeFB = "";
		iframeFB = "<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=" + escape($(this).parents('.post').find('.permlink').attr('href')) + "&amp;layout=button_count&amp;show_faces=false&amp;width=135&amp;action=like&amp;colorscheme=light&amp;locale=es_ES\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden; width:135px; height:25px; vertical-align:middle\"><\/iframe>";
		$(this).append(iframeFB);
	});
	
	$('#fb-fans').prepend("<iframe scrolling=\"no\" height=\"246\" frameborder=\"0\" width=\"300\" allowtransparency=\"true\" src=\"http:\/\/www.facebook.com\/connect\/connect.php?id=125802874115397&amp;connections=10&amp;stream=0&css=http:\/\/www.carrerasconfuturo.com\/wp-content\/themes\/default\/css\/fan.css&amp;locale=es_ES\" class=\"fb-fan-box\"><\/iframe>");	
	
	$('.fb-like-corp').each(function(){
		var iframeFBCorp = "";
		iframeFBCorp = "<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=" + escape($(this).parents('.small-buttons').find('.corplink').attr('href')) + "&amp;layout=button_count&amp;show_faces=false&amp;width=135&amp;action=like&amp;colorscheme=light&amp;locale=es_ES\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden; width:135px; height:25px; vertical-align:middle\"><\/iframe>";
		$(this).append(iframeFBCorp);
	});
	
	$('.nwk-button.nwk-tw-corp').each(function() {
			var iframeTweetCorp = "";
			iframeTweetCorp += "<iframe scrolling=\"no\" width=\"110\" height=\"20\" allowtransparency=\"true\" frameborder=\"0\" src=\"http:\/\/platform.twitter.com\/widgets\/tweet_button.html?url="+$('.small-buttons').find('.corplink').attr('href')+"&amp;via=carrerasfuturo&amp;text="+$('.corp-video').find('.corplink').text()+"&amp;count=horizontal&amp;lang=es\" ><\/iframe>";		
			$(this).append(iframeTweetCorp);
	});
	
	
	$('#fb-becomefan').append("<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=http://www.facebook.com/carrerasfuturo&amp;layout=button_count&amp;show_faces=false&amp;width=135&amp;action=like&amp;colorscheme=light&amp;height=25&amp;locale=es_ES\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:135px; height:25px;\" allowTransparency=\"true\"><\/iframe>");
	
	$('#count-down').mouseover(function(){
	    $(this).css({"width" : "295px" , "overflow" : "visible"});
		$('#fdbk_tab').css({"z-index" : "1020"});
		$('#count-down .close,.counter-nav').show();
	});
	
	$('.slidedoor , #count-down .close').click(function(){
	    $('#count-down').css({"width" : "48px" , "overflow" : "hidden" });
		$('#fdbk_tab').css({"z-index" : "50"});
		$('#count-down .close,.counter-nav').hide();
		return false;
	});
	
	$('#pollbox').hover(function(){
		$('.pollmsg').show();
	},function(){$('.pollmsg').hide();});
	/*Insercion de flash 'countdown' */	
	
	$('#summary-more').click(function(){	
		$(this).fadeOut();
		$('#intro-expand').fadeTo('',1,'').slideDown();
		return false;
	});
	$('#summary-less').click(function(){		
		$('#intro-expand').fadeTo('',0,'').slideUp();
		$('#summary-more').fadeIn();
		return false;
	});
	
	$('#author-more').click(function(){	
		$(this).fadeOut();
		$('#author-expand').fadeTo('',1,'').slideDown();
		return false;
	});
	$('#author-less').click(function(){		
		$('#author-expand').fadeTo('',0,'').slideUp();
		$('#author-more').fadeIn();
		return false;
	});
	
	//JW Payer
	$(".video-player").each(function(){
		var videoType = $(this).find("a").attr("rel");
		var videoPath = $(this).find("a").attr("href");
		var videoImage = $(this).find("img").attr("src");		
		var videoW = $(this).find("img").attr("width");
		var videoH = $(this).find("img").attr("height");
		var videoControls = $(this).find("a").attr("controls");
		if(FlashDetect.installed){
			$(this).empty();
			$(this).flash(
				{ src: 'http://www.carrerasconfuturo.com/wp-content/themes/carrerasconfuturo/swf/player.swf',
				  width: videoW,
				  height: videoH,
				  wmode: 'transparent',
				  allowfullscreen: true,
				  flashvars: { 
					file: videoPath, 
					image: videoImage, 
					stretching: 'exactfit',
					controlbar: videoControls,
					skin: 'http://www.carrerasconfuturo.com/wp-content/themes/carrerasconfuturo/swf/skin/modieus.xml'
					}
				},
				{ version: 8 }
			);
		} else {
			if(videoType == 'youtube'){
				$(this).empty();
				var embedVid = "<object width=\"" + videoW + "\" height=\"" + videoH + "\"><param name=\"movie\" value=\"" + videoPath + "\"><\/param><param name=\"allowFullScreen\" value=\"true\"><\/param><param name=\"allowscriptaccess\" value=\"always\"><\/param><embed src=\"" + videoPath + "\"&hl=es_ES&fs=1&\" type=\"application\/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"" + videoW + "\" height=\"" + videoH + "\"><\/embed><\/object>";
				
				$(this).append(embedVid);
			}
		}

	});
	
	/*PICASA*/

	$("#picasa-gallery").pwi({
	  username: 'carrerasconfuturo',
	  maxResults: 5,
	  albumMaxResults: 5,
	  thumbSize: 72,
	  albumThumbSize: 72,
	  mode: 'albums',
	  album: '',	  
	  thumbCss: { margin: '0 28px 10px 0' },
	  showSlideshowLink: false,
	  showAlbumdate: false
	});
		
	$('.icon-picasa a').hover(
		function(){$('.gallery small').show();},
		function(){$('.gallery small').hide();}
	);
	
	/*CYCLE*/
		
	$(".tweet").getTwitter({
		userName: "carrerasfuturo",
		numTweets: 2,
		loaderText: "Cargando twitts...",
		slideIn: false,
		showHeading: false,
		showProfileLink: false

	});
	
	/*STYLE SWITCHER*/
	
	/*Eventos para cambiar de estilo con los links*/
	$('#theme1').click(function(){
	
		setActiveStyleSheet('Estilo Granate');
		Cufon.refresh();
		return false;
	});
	
	$('#theme2').click(function(){
	
		setActiveStyleSheet('Estilo Celeste');
		Cufon.refresh();
		return false;
	});
	
	$('#theme3').click(function(){
	
		setActiveStyleSheet('Estilo Verde');
		Cufon.refresh();
		return false;
	});
	
	$('#theme4').click(function(){
	
		setActiveStyleSheet('Estilo Amarillo');
		Cufon.refresh();
		return false;
	});
   
   $('#adv').flash(
	  { src: 'http://www.carrerasconfuturo.com/wp-content/themes/carrerasconfuturo/swf/cu3er.swf',
		width: 850,
		height: 150,
		wmode: 'transparent',
		flashvars: { xml: 'http://www.carrerasconfuturo.com/wp-content/themes/carrerasconfuturo/xml/config.xml' }
	  },
	  { version: 8 }
  );
   
   
   $('.vote-up').toggle(function(){$(this).addClass('vote-up-on');},function(){$(this).removeClass('vote-up-on');});
   $('.vote-down').toggle(function(){$(this).addClass('vote-down-on');},function(){$(this).removeClass('vote-down-on');});
   
   $('#add-friends').click(function(){
		$('#hidden-content .friend-list').clone(true).appendTo('#friends-added').show();
		return false;
	});
   
   $('.open-chat').click(function(){
		var chatURL = $(this).attr('href');
		var w = 580;
		var h = 480;
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
		settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,toolbar=no';
		window.open(chatURL, "Chat de Admisi\341n",settings).focus();	
		return false;
	});
   	
	/*jQuery(document).ready(function() {
		var rutaori = document.location.href;
		if(rutaori=="http://www.carrerasconfuturo.com/" || rutaori=="http://www.carrerasconfuturo.com" || rutaori=="http://carrerasconfuturo.com"  || rutaori=="http://carrerasconfuturo.com/" || rutaori=="www.carrerasconfuturo.com" || rutaori=="www.carrerasconfuturo.com/"){
			$.get('http://www.carrerasconfuturo.com/ventana-flotante/', function(data) { $.facebox(data) }); 	
		}
		
	})	*/
   
   $('a[rel*=facebox]').facebox();

 	$('.vida-video ul a').hover(
		function(){
			var tip = $(this).attr('title');
			$(this).attr('title','');
			$(this).attr('ut',tip);
			var tipmarkup = "<div class=\"tooltip\"><div class=\"sm-arrow\"></div>"+tip+"</div>";
			$(this).before(tipmarkup);
		},
		function(){
			var tip = $(this).attr('ut');
			$(this).removeAttr('ut');
			$(this).attr('title',tip);
			$('.tooltip').remove();
			
		}
	);

});

function blog_redireccionar(url){
	document.location.href=url;	
}
function getXMLHttpRequest(){
	var xmlhttp=false;
	try{
		// Crea objeto AJAX para navegadores diferentes a Internet Explorer
		xmlhttp=new ActiveXObject("Msxml12.XMLHTTP");	
	}catch(e){
		try{
			// Crea objeto AJAX para navegadores de Internet Explorer
			xmlhttp=new ActiveXObject("Microsoft:XMLHTTP");	
		}catch(E){
			if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
				xmlhttp=new XMLHttpRequest();	
			}
		}
	}
	return xmlhttp;
}
function enviarCorreo(idnombre,idcorreo,URL){
	var nombre=document.getElementById(idnombre);
	var correo=document.getElementById(idcorreo);
	var minombre=simularTrim(nombre.value);
	var micorreo=simularTrim(correo.value);
	if(minombre!="" && micorreo!="" && valEmail(micorreo) && minombre!="Tu nombre"){
		var param="nombre="+minombre+"&correo="+micorreo+"&miURL="+escape(URL);
		var ajax=getXMLHttpRequest();
		ajax.open("POST",URL+"/enviarcorreo.php",true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				alert("Correo enviado");
				//jQuery.facebox({ ajax: 'http://localhost/carreras/httpdocs/validarmicorreo.php' });
			}
		}
		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.send(param);		
		nombre.value="";
		correo.value="";
	}else{
		if(minombre=="" || minombre=="Tu nombre"){
			alert("Complete su nombre");	
			nombre.focus();
			nombre.value="";
		}else if(micorreo=="" || !valEmail(micorreo)){
			alert("Complete bien su correo");
			correo.focus();
			correo.value="";
		}
	}

}
function simularTrim(parametro){
	var texto=parametro.replace(/^\s+|\s+$/gi, "");
	return texto;
}
function valEmail(valor){    // Cortesa de http://www.ejemplode.com
    re=/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/
    if(!re.exec(valor))    {
        return false;
    }else{
        return true;
    }
}

function validarformulariocomentario(){
	var comentario=document.getElementById('comment');
	var autor=document.getElementById('author');
	var correo=document.getElementById('email');
	var scomentario=comentario.value;
	var sautor=autor.value;
	var scorreo=correo.value;
	if(simularTrim(scomentario)==""){
		alert("Coloque un comentario");
		comentario.focus();
		return false;
	}else if(simularTrim(sautor)==""){
		alert("Indique quien es");
		autor.focus();
		return false;
	}else if(simularTrim(scorreo)=="" || !valEmail(simularTrim(scorreo))){
		alert("Coloque bien su correo");
		correo.focus();
		return false;
	}else{
		return true;	
	}
}
