// JavaScript Document
$(function(){
		   
	$('#padre_left').mouseover(function(){$("#environmentLink").css({color:"#d76914"});}).mouseout(function(){$("#environmentLink").css({color:"#808080"});})
	$('#environmentLink').mouseover(function(){$(this).css({color:"#d76914"});}).mouseout(function(){$(this).css({color:"#808080"});})
	$('#padre_center').mouseover(function(){$("#theaterLink").css({color:"#d76914"});}).mouseout(function(){$("#theaterLink").css({color:"#808080"});})
	$('#theaterLink').mouseover(function(){$(this).css({color:"#d76914"});}).mouseout(function(){$(this).css({color:"#808080"});})
	$('#padre_right').mouseover(function(){$("#eventsLink").css({color:"#d76914"});}).mouseout(function(){$("#eventsLink").css({color:"#808080"});})
	$('#eventsLink').mouseover(function(){$(this).css({color:"#d76914"});}).mouseout(function(){$(this).css({color:"#808080"});})
	
	//Dont't Forget these lines:
	$('#s_environments').mouseover(function(){$("#environmentLink").css({color:"#d76914"});}).mouseout(function(){$("#environmentLink").css({color:"#808080"});})
	$('#s_theater').mouseover(function(){$("#theaterLink").css({color:"#d76914"});}).mouseout(function(){$("#theaterLink").css({color:"#808080"});})
	$('#s_events').mouseover(function(){$("#eventsLink").css({color:"#d76914"});}).mouseout(function(){$("#eventsLink").css({color:"#808080"});})
	
})

var currentBtn;


function loadPic(cualpic){
	
	$('#picGde').html('');
	
	$('#holder_vdo').replaceWith('<div id="picGde"><a href="javascript:void(0)" onclick="Lightbox(\''+cualpic+'\')"></a></div>');
	
	$('#picGde').replaceWith('<div id="picGde"><a href="javascript:void(0)" onclick="Lightbox(\''+cualpic+'\')"></a></div>');

	returnCaption(cualpic);
	
	  var img = new Image();

	  // wrap our new image in jQuery, then:
	  $(img)
		// once the image has loaded, execute this code
		.load(function () {
		  // set the image hidden by default    
		  $(this).hide();
		
		  // with the holding div #loader, apply:
		  $('#picGde a')
		    .css("display","block")
			// remove the loading class (so no background spinner), 
			.removeClass('loading')
			// then insert our image
			.append(this);
		
		  // fade our image in to create a nice effect
		  $(this).show();
		})
		
		// if there was an error loading the image, react accordingly
		.error(function () {
		  // notify the user that the image could not be loaded
		}).attr( {src: 'images/img_pro/gde/'+cualpic,
		         border:'0'});
		
}


function loadVdo(fileVdo){
	
	$('#holder_vdo').html('');
	
	if($('#picGde')){
	
	    $('#picGde').replaceWith('<div id="holder_vdo"></div>');
	
	}
		
	$('#holder_vdo').flash({ // test_flashvars.swf is the flash document   
							 
		swf: 'flash/vdo_pro.swf', // these arguments will be passed into the flash document  
				
	    height:360,
				
		width:640,
				
		params: {wmode: 'transparent'},
				
		flashvars: {   
		     video:fileVdo
		 }  
				
	});
		
};

function loadImgNews(cualpic, id){
	
	$('#vdo'+id).html('');
	
	if( $('#vdo'+id).hasClass('holder_vdo_block') == true ){
		
		   $('#vdo'+id).removeClass('holder_vdo_block');
		   $('#vdo'+id).addClass('holder_vdo_none');
		
	}
	
	$('#img'+id).html('');
	
	  var img = new Image();

	  // wrap our new image in jQuery, then:
	  $(img)
		// once the image has loaded, execute this code
		.load(function () {
		  // set the image hidden by default    
		  $(this).hide();
		
		  // with the holding div #loader, apply:
		  $('#img'+id)
		    .css("display","block")
			// remove the loading class (so no background spinner), 
			.removeClass('loading')
			// then insert our image
			.append(this);
		
		  // fade our image in to create a nice effect
		  $(this).show();
		})
		
		// if there was an error loading the image, react accordingly
		.error(function () {
		  // notify the user that the image could not be loaded
		}).attr( {src: 'images/img_pro/gde/'+cualpic,
		         border:'0'});
		
}


function loadVdoNews(fileVdo, id){
	
    $('#img'+id).css("display", "none");

	$('#vdo'+id).removeClass('holder_vdo_none');
	                                                                                       
	$('#vdo'+id).addClass('holder_vdo_block');
		
	$('#vdo'+id).flash({ // test_flashvars.swf is the flash document   
							 
		swf: 'flash/vdo_news.swf', // these arguments will be passed into the flash document  
				
	    height:161,
				
		width:286,
				
		params: {wmode: 'transparent'},
				
		flashvars: {   
		     video:fileVdo
		 }  
				
	});
		
};


function Lightbox(img){
				//alert(img);
			$('#img').html('');
			$('div#ligthBox').css("background-color","#999999");
     
			
			if( $('div#overlay').hasClass('overlay') == true ){
				
					$('div#overlay').removeClass('overlay');
					$('div#overlay').addClass('overlay_full');
					
					var alto = $(document).height();
					
					$('div#ligthBox').removeClass('sugerencias');
					$('div#ligthBox').addClass('sugerencias2');
					
					$('div#overlay').css("height", alto+"px");
									
						$('#img').html('<img src="images/img_pro/lightbox/'+img+'"  />');
				
				} else {
					
					$('#img').html('');
					$('div#overlay').addClass('overlay');
					$('div#overlay').removeClass('overlay_full');
					$('div#ligthBox').removeClass('sugerencias2');
					$('div#ligthBox').addClass('sugerencias');
					
				}
	}
	
function Brochure(){
				closeBIO();
			$('#img').html();
			
			 $('div#ligthBox').attr({onclick:""});
			$('div#overlay').attr({onclick:""});
			
			if( $('div#overlay').hasClass('overlay') == true ){
					$('div#overlay').removeClass('overlay');
					$('div#overlay').addClass('overlay_full');
					
					var alto = $(document).height();
					
					$('div#ligthBox').removeClass('sugerencias');
					$('div#ligthBox').addClass('sugerencias2');
					
					$('div#overlay').css("height", alto+"px");
						
					$('#img').css({width:'762px', height:'555px'});
						
					//$('#img').load('brochure/mailForm.php');
					
					$.ajax({
						   
						   url: 'brochure/mailForm.php',
						   cache: false,
						   success: function(msg){
                                $('div#img').append(msg);
	 
                             },
                          complete: function(success){
							  
							  actucap();
							  
							  $('img#captchaIMG').attr({
										  
										 /* src: "brochure/captcha/captcha.php",*/
										  width:"200",
										  height:"50",
										  vspace:"0"
										  
										  })
							  
						  }
						   
				   })//end ajax
				
				} else {
					
					$('#img').html('');
					$('div#overlay').addClass('overlay');
					$('div#overlay').removeClass('overlay_full');
					$('div#ligthBox').removeClass('sugerencias2');
					$('div#ligthBox').addClass('sugerencias');
					
				}
	}
	
function actucap(){
      var obj=document.getElementById('captchaIMG');
      if (!obj) 
	  obj=window.document.all.cap;
      if (obj){
       obj.src= 'brochure/captcha/captcha.php?' + Math.random() ;
      }
}

var myInterval;
function returnCaption(img){
		
	$.ajax({
		type: "POST",
	    url: "secciones/caption.php",
		data: "cap="+img,
		success: function(msg){

			info = jQuery.trim(msg);
			
			if(info != ""){
				
				//$('#caption').show();
				
				$('#caption').html(info);
				
				$('#picGde a').mouseover(function(){
												  
					 clearInterval(myInterval);
							
					$('#caption').css({display: "block"});
											   
				 }).mouseout(function(){
					    clearInterval(myInterval);
					  myInterval = setInterval(hideCaption,300);
					   
				 })
		
				$('#caption').mouseover(function(){
													 
							clearInterval(myInterval);		
							
					}).mouseout(function(){
						
						 clearInterval(myInterval);
							 myInterval = setInterval(hideCaption,300);
						
					})
			}else{
				//$('#caption').hide();
				
				}
		 }//end success
     });//end ajax
	
}

function hideCaption(){
	
	$('#caption').css({display: "none"});
	
}
var pos_x;
var pos_y;
function info_bio(cualBio, posX){
	$.getJSON("XML/bio.php?jsoncallback=?",
        function(data){
		 
		 for (var x = 0; x < data.length; x++) { 
		 
			 if(data[x].nombre == cualBio){
				 
		      if(posX == 2 || posX == 5 || posX == 8){

				    pos_x = "60px";
					pos_y = "513px";
				 
				  
				  }else if(posX == 3 || posX == 6 || posX == 9){
					         pos_x = "281px";
					         pos_y = "513px" ;
					  
					  }
					  else if(posX == 4 || posX == 7 || posX == 10){
					  		pos_x = "510px";
					         pos_y = "513px" ;
					         
					  }
			   $('#infoBIO').css({display:"block",
								  marginLeft:pos_x,
	                              marginTop:pos_y
								  });
			
			  $('#picBIO').html('<img src="images/bio/gde/'+data[x].file+'"  />');
			  
			  var str_one = data[x].descripcion;
			  
			  var str_two = str_one.replace("<p>","");
			  
			  var str_three = str_two.replace("</p>","");

			  $('#textBIO').html(str_three);
			  
			 }

       }  
    })//end json
}

function closeBIO(){
		$('#infoBIO').css({display:"none"});
}

function regBrochure(){
	
	
	$.ajax({
		type: "POST",
	    url: "brochure/reg.php",
		data: "name="+document.myForms.contactName.value+"&email="+document.myForms.contactMail.value+"&captcha="+document.myForms.contactCaptcha.value,
		success: function(msg){
		
		
		   if(msg == "succes"){
			   Brochure();
			  window.location = "brochure/getpdf.php?file=PDF/brochure.pdf";
					   
		   }else{
			   $('#msg').html(msg);
			   }
		
		 }//end success
     });
	
}
