/*CSS Browser Selector v0.3.5 (Feb 05, 2010)*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
/****************/
function toggler(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}
/****************/
function ShowHide(LayerName,TotalLayers){//v1.0
	var temp = new Array();
	temp = LayerName.split('_');
	ReLayerName = temp[0];
	
		for (i=1;i<=TotalLayers;i++){
		document.getElementById(ReLayerName+'_'+i).style.display = 'none';
		}
	document.getElementById(LayerName).style.display = 'block';
}
/****************/
function LinkClasses(IDlink,TotalLinks,OFF,ON){//v1.0
	var temp = new Array();
	temp = IDlink.split('_');
	ReIDlink = temp[0];

		for (i=1;i<=TotalLinks;i++){
		document.getElementById(ReIDlink+'_'+i).className = OFF;
		}
	document.getElementById(IDlink).className = ON;
}
/****************/
/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
/********ANTI IE6 BUG***********/
if (document.all && !window.opera && !window.XMLHttpRequest) {
	document.execCommand("BackgroundImageCache",false,true);
}
/*****jQUERY*****/
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
/*SKYPE*/
$(document).ready(function() {
		window.setTimeout(function() {
			$('.skype_pnh_container').html('');
			$('.skype_pnh_print_container').removeClass('skype_pnh_print_container');
		}, 800);
	});

/****W3C HIDDEN STYLES****/
document.write('<style type="text/css">');
document.write('HTML {overflow:-moz-scrollbars-vertical}');
document.write('TEXTAREA {resize: none}');
//document.write('DIV, IMG, A {behavior: url("css/iepngfix.htc");}');
document.write('</style>');

/*jQuerys*/

/***** Menú superior ******/
$(document).ready(function() {
	$("nav ul #Btn1").click(function() { 
		if($(this).hasClass("Selected")){
			$("nav ul li").removeClass("Selected");
		} else {	
			$("nav ul li").removeClass("Selected");
			$(this).addClass("Selected");
		}
	});
	$("nav ul #Btn2").click(function() { 
		if($(this).hasClass("Selected")){
			$("nav ul li").removeClass("Selected");
		} else {	
			$("nav ul li").removeClass("Selected");
			$(this).addClass("Selected");
		}
	});
	$("nav ul #Btn4").click(function() { 
		if($(this).hasClass("Selected")){
			$("nav ul li").removeClass("Selected");
		} else {	
			$("nav ul li").removeClass("Selected");
			$(this).addClass("Selected");
		}
	});
	$("nav ul #Btn5").click(function() { 
		if($(this).hasClass("Selected")){
			$("nav ul li").removeClass("Selected");
		} else {	
			$("nav ul li").removeClass("Selected");
			$(this).addClass("Selected");
		}
	});
});		

/**** Acordión Pié de página ****/
$(document).ready(function(){
   $('#ShowHide').toggle(function(){ 
		$(this).addClass("Down");
		$('#Inner').animate({height: "0"}, 500, function(){
		$(".Cols").hide();
	  });
   }, 
   function(){ 
		$('#Inner').animate({height: "307"}, 500);
		$(this).removeClass("Down");
		$(".Cols").show();  
		$('html, body').animate({scrollTop: 500000}, 2500);
		if ($.browser.msie && $.browser.version < 7){//ie6
			$('html, body').animate({scrollTop: 500000}, 1000);
		}
   }); 
}); 

$(document).ready(function () { 
	$('#nav li a')
		.append('<span class="hover" id="navcolor"/>').each(function () {
			var $span = $('> span.hover', this).css('opacity', 0);
			$(this).parent().find("ul li a #navcolor").remove();
			$(this).hover(function () {
			$(this).parent().find(".menu").fadeTo(500,1);
			$span.stop().fadeTo(500, 1);
		}, function () {   
			$(this).parent().find(".menu").fadeTo(500,1);
			$span.stop().fadeTo(500, 0);
		});
	});
});
$(document).ready(function () { 
	$('.Card a')   
	  	.append('<span class="hover" id="cardcolor"/>').each(function () {
			var $span = $('> span.hover', this).css('opacity', 0);
			$(this).hover(function () {
			$span.stop().fadeTo(300, 1);
		}, function () {   
			$span.stop().fadeTo(500, 0);
		});
	});
});
/* TRABAJO */
$(document).ready(function() {
	/*$("#TopSlider .Card").css({opacity:0.6});*/
	/*$("#TopSlider .Card").find('.Selected').css({opacity: 1});*/
	$("#TopSlider .Card a").each(function(){
		if($(this).hasClass("Selected")){
			$(this).parent().css({opacity:1});
		} else {
			$(this).parent().css({opacity:0.6});
		}
	});
	$('#TopSlider .Card').mouseenter(function() {
		$(this).fadeTo('normal',1);
	});
	
	$('#TopSlider .Card').mouseleave(function() {
/*					$(this).fadeTo('normal',0.6);
		$(this).find('.Selected').fadeTo('normal',1);
*/
		elem = $(this).children();
		if(elem.hasClass("Selected")){
			$(this).find('.Selected').fadeTo('normal',1);
		} else {
			$(this).fadeTo('normal',0.6);
			$(this).find('.Selected').fadeTo('normal',1);
		}
	});
});
function resetContacts(){
	var f = document.forms['contact'];
	f.reset();
}
$(function(){
	$('#submit').click(function(){
		$('#boxContact').addClass('cargando');
		//mostrar el cargando
		/* Validacion de DATA! aca!! ***********************************
		 * */
		$('#contact').fadeOut(250);
		var $dataForm = $('#contact').serialize();
		$.ajax({
		  type: "POST",
		  url: "php/sendContact.php",
		  data: $dataForm,
		  dataType: "json",
		  success: function(json){
			//ocultar el cargando
			$('#boxContact').removeClass('cargando');
			if(json.response){
				$('#contactGracias').fadeIn(500).delay(950).fadeOut(500);
				$('#contact .error').remove();
				resetContacts();
				$('#contact').hide().delay(1500).fadeIn(500);
			}else{
				$('#contact .error').remove();
				$('#contact').fadeIn(500);
				$msjError = $('<span class="error"><img alt="' + json.error + '" src="images/form/errores/'+json.img+'.gif" /></span>');
				$('#contact #' + json.elem).before($msjError);
			}
		  }
		});
	});
	$('#reset').click(function(){
		resetContacts();
	});
});

if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)) {
		document.location = "iphone/index.html";
}

if (navigator.userAgent.indexOf('iPad') != -1) {
		document.location = "ipad/index.html";
}

/* NOTICIAS - BOTON SUBIR */
$(document).ready(function(){
	$("#Subir").click(function(){
		$('html, body').animate({scrollTop: 0}, 1500);
	});	
	
	if ($.browser.msie && $.browser.version < 7){//ie6
		$("a span").click(function(){
			$('html, body').animate({scrollTop: 0}, 500);
		});	
	}
});

