	
	// Cufon text replacememnt, add more elements to replace text with cufon generated text.
	Cufon.replace('h1, h2, h3, h4',{hover: true});
		
$(document).ready(function() { 
		
		//Main navigation dropdowns
		
	
	
		if($('#logearme').length > 0){
			$('#logearme').click(function() {
				$('#login_contratar').removeClass('hidden');
				$('#registroform').addClass('hidden');
			});
		}
		
		if($('#registrarme').length > 0){
			$('#registrarme').click(function() {
				$('#registroform').removeClass('hidden');
				$('#login_contratar').addClass('hidden');
			});
		}
		
		if($('#btnaceptar').length > 0){
			$('#btnaceptar').click(function(e) {
				e.preventDefault();
				$('#paso1').addClass("hidden");
				if($('#paso3a').length > 0){
					$('#paso3a').removeClass("hidden");
				}
				if($('#paso2').length > 0){
					//alert('paso2');
					$('#paso2').removeClass("hidden");
				}
				//$('#paso2').removeClass("hidden");
				//$('#estado1').addClass("hidden");
				//$('#estado2').removeClass("hidden");
			});
		}
		
		if ($('#tarifas-contratar-basic').length > 0) {
		
			$('.btncntr').each(function(index){
				if (index == 0) {
					$(this).click(function(e){
						e.preventDefault();
						
						elarr = $('#t_busq').text() + '-' + $('#t_act').text() + '-1';
						setContratoAjax(1,elarr);
						//alert(listaPrecios[elarr])
						$('#pb3seleccionado').attr('id', 'pb3');
						$('#pb6seleccionado').attr('id', 'pb6');
						$('#pb12seleccionado').attr('id', 'pb12');
						$(this).attr('id', 'pb1seleccionado');
					});
				}
				if (index == 1) {
					$(this).click(function(e){
						e.preventDefault();
						
						elarr = $('#t_busq').text() + '-' + $('#t_act').text() + '-2';
						setContratoAjax(3,elarr);
						//alert(listaPrecios[elarr])
						$('#pb1seleccionado').attr('id', 'pb1');
						$('#pb6seleccionado').attr('id', 'pb6');
						$('#pb12seleccionado').attr('id', 'pb12');
						$(this).attr('id', 'pb3seleccionado');
					});
				}
				if (index == 2) {
					$(this).click(function(e){
						e.preventDefault();
						
						elarr = $('#t_busq').text() + '-' + $('#t_act').text() + '-3';
						setContratoAjax(6,elarr);
						//alert(listaPrecios[elarr])
						$('#pb3seleccionado').attr('id', 'pb3');
						$('#pb1seleccionado').attr('id', 'pb1');
						$('#pb12seleccionado').attr('id', 'pb12');
						$(this).attr('id', 'pb6seleccionado');
					});
				}
				if (index == 3) {
					$(this).click(function(e){
						e.preventDefault();
						
						elarr = $('#t_busq').text() + '-' + $('#t_act').text() + '-4';
						setContratoAjax(12,elarr);
						//alert(listaPrecios[elarr])
						$('#pb3seleccionado').attr('id', 'pb3');
						$('#pb6seleccionado').attr('id', 'pb6');
						$('#pb1seleccionado').attr('id', 'pb1');
						$(this).attr('id', 'pb12seleccionado');
					});
				}
			});
			
		}
		
		if ($('#tarifas-contratar-standard').length > 0) {
			$('.btncntr').each(function(index){
				if (index == 0) {
					$(this).click(function(e){
						e.preventDefault();
						
						elarr = $('#t_busq').text() + '-' + $('#t_act').text() + '-1';
						setContratoAjax(1,elarr);
						//alert(listaPrecios[elarr])
						$('#ps3seleccionado').attr('id', 'ps3');
						$('#ps6seleccionado').attr('id', 'ps6');
						$('#ps12seleccionado').attr('id', 'ps12');
						$(this).attr('id', 'ps1seleccionado');
					});
				}
				if (index == 1) {
					$(this).click(function(e){
						e.preventDefault();
						setContratoAjax(3);
						elarr = $('#t_busq').text() + '-' + $('#t_act').text() + '-2';
						setContratoAjax(3,elarr);
						//alert(listaPrecios[elarr])
						$('#ps1seleccionado').attr('id', 'ps1');
						$('#ps6seleccionado').attr('id', 'ps6');
						$('#ps12seleccionado').attr('id', 'ps12');
						$(this).attr('id', 'ps3seleccionado');
					});
				}
				if (index == 2) {
					$(this).click(function(e){
						e.preventDefault();
						
						elarr = $('#t_busq').text() + '-' + $('#t_act').text() + '-3';
						setContratoAjax(6,elarr);
						//alert(listaPrecios[elarr])
						$('#ps3seleccionado').attr('id', 'ps3');
						$('#ps1seleccionado').attr('id', 'ps1');
						$('#ps12seleccionado').attr('id', 'ps12');
						$(this).attr('id', 'ps6seleccionado');
					});
				}
				if (index == 3) {
					$(this).click(function(e){
						e.preventDefault();

						elarr = $('#t_busq').text() + '-' + $('#t_act').text() + '-4';
						setContratoAjax(12,elarr);
						//alert(listaPrecios[elarr])
						$('#ps3seleccionado').attr('id', 'ps3');
						$('#ps6seleccionado').attr('id', 'ps6');
						$('#ps1seleccionado').attr('id', 'ps1');
						$(this).attr('id', 'ps12seleccionado');
					});
				}
			});
			
		}
		
		if ($('#tarifas-contratar-premium').length > 0) {
		
				$('.btncntr').each(function(index){
				if (index == 0) {
					$(this).click(function(e){
						e.preventDefault();
						
						elarr = $('#t_busq').text() + '-' + $('#t_act').text() + '-1';
						setContratoAjax(1,elarr);
						//alert(listaPrecios[elarr])
						$('#pp3seleccionado').attr('id', 'pp3');
						$('#pp6seleccionado').attr('id', 'pp6');
						$('#pp12seleccionado').attr('id', 'pp12');
						$(this).attr('id', 'pp1seleccionado');
					});
				}
				if (index == 1) {
					$(this).click(function(e){
						e.preventDefault();
						
						elarr = $('#t_busq').text() + '-' + $('#t_act').text() + '-2';
						setContratoAjax(3,elarr);
						//alert(listaPrecios[elarr])
						$('#pp1seleccionado').attr('id', 'pp1');
						$('#pp6seleccionado').attr('id', 'pp6');
						$('#pp12seleccionado').attr('id', 'pp12');
						$(this).attr('id', 'pp3seleccionado');
					});
				}
				if (index == 2) {
					$(this).click(function(e){
						e.preventDefault();
						
						elarr = $('#t_busq').text() + '-' + $('#t_act').text() + '-3';
						setContratoAjax(6,elarr);
						//alert(listaPrecios[elarr])
						$('#pp3seleccionado').attr('id', 'pp3');
						$('#pp1seleccionado').attr('id', 'pp1');
						$('#pp12seleccionado').attr('id', 'pp12');
						$(this).attr('id', 'pp6seleccionado');
					});
				}
				if (index == 3) {
					$(this).click(function(e){
						e.preventDefault();
						
						elarr = $('#t_busq').text() + '-' + $('#t_act').text() + '-4';
						setContratoAjax(12,elarr);
						//alert(listaPrecios[elarr])
						$('#pp3seleccionado').attr('id', 'pp3');
						$('#pp6seleccionado').attr('id', 'pp6');
						$('#pp1seleccionado').attr('id', 'pp1');
						$(this).attr('id', 'pp12seleccionado');
					});
				}
			});
		}
		
	
		if ($('#mesespack').length > 0) {
			
			elarr = $('#t_busq').text()+'-'+$('#t_busq').text()+'-'+$('#mesespack').attr('value');
			meses = $('#mesespack').attr('value');
			if(meses==4){
				meses = 12;
			}else if(meses == 3){
				meses = 6;
			}else if(meses == 2){
				meses = 3
			}
			$('#preumes').text(listaPrecios[elarr]/meses);
			$('#preuunic').text(listaPrecios[elarr]);
			
			$('#mesespack').change(function(){
				//alert('Value change to ' + $(this).attr('value'));
				elarr = $('#t_busq').text()+'-'+$('#t_busq').text()+'-'+$(this).attr('value');
				//alert(elarr);
				//alert(listaPrecios[elarr]);
				meses = $(this).attr('value');
				if(meses==4){
					meses = 12;
				}else if(meses == 3){
					meses = 6;
				}else if(meses == 2){
					meses = 3
				}
				$('#preumes').text(listaPrecios[elarr]/meses);
				$('#preuunic').text(listaPrecios[elarr]);
			});
		}
		
		if ($('ul.sf-menu').length > 0) {
		}
			$('ul.sf-menu').superfish({
				delay: 300, // one second delay on mouseout 
				animation: {
					height: 'show'
				}, // fade-in and slide-down animation 
				speed: 'normal', // faster animation speed 
				autoArrows: true, // disable generation of arrow mark-up 
				dropShadows: false // disable drop shadows 
			});
		
			
			//Nivo slider customization
			$(window).load(function(){
				$('#slider').nivoSlider({
					effect: 'fade', //Specify sets like: 'fold,fade,sliceDown'
					slices: 20,
					animSpeed: 800, //Slide transition speed
					pauseTime: 5000,
					startSlide: 0, //Set starting Slide (0 index)
					directionNav: true, //Next & Prev
					directionNavHide: true, //Only show on hover
					controlNav: false, //1,2,3...
					controlNavThumbs: false, //Use thumbnails for Control Nav
					controlNavThumbsFromRel: false, //Use image rel for thumbs
					controlNavThumbsSearch: '.jpg', //Replace this with...
					controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
					keyboardNav: true, //Use left & right arrows
					pauseOnHover: true, //Stop animation while hovering
					manualAdvance: false, //Force manual transitions
					captionOpacity: 0.8, //Universal caption opacity
					beforeChange: function(){
					},
					afterChange: function(){
					},
					slideshowEnd: function(){
					}, //Triggers after all slides have been shown
					lastSlide: function(){
					}, //Triggers when last slide is shown
					afterLoad: function(){
					} //Triggers when slider has loaded
				});
			});
			
			//Coin slider customization
			$('#coin-slider').coinslider({
				width: 934,
				height: 335,
				navigation: true,
				opacity: 0.9
			});
			
			//PrettyPhoto customization
			$(document).ready(function(){
				$("a[rel^='prettyPhoto']").prettyPhoto();
			});
		
				
}); 		
		
function setContratoAjax(meses,index){
	$('#btnaceptar').attr('href','#seguir');
	$('#btnaceptar').removeClass('btn_g');
	$('#btnaceptar').addClass('btn');
	$.ajax({
		type: "POST",
		url: '/includes/ajax/contratar.php',
		data: "meses="+meses+"&index="+index+"&submit=submitContratoMes",
		  success: function(data) {
		    //alert(data);
			$('#nextstep').submit();
		  }
	});
}


