

function hide20(){
		$('#anniversary').fadeOut('slow');
		$('#20logo').show();
		$('#20logo').flash({ src: '/wp-content/themes/gtp/20_logo-2.swf', height: 70, width: 70 });
	 }

$(function(){
		   
	$('#20logo').hide();

	$(document).pngFix(); 
	
	jQuery.fn.exists = function(){return this.length>0;}
	 
	$('a[rel*=facebox]').facebox();		
		
	if ($('#anniversary').exists()) {
		$('#anniversary').flash({ src: '/wp-content/themes/gtp/20_new.swf', height: 427, width: 446, wmode: 'transparent',allowscriptaccess: 'always'});
	 
	 
	//setTimeout(hide20,5000);
	} else {
		 $('#20logo').show();
		 $('#20logo').flash({ src: '/wp-content/themes/gtp/20_logo-2.swf', height: 70, width: 70 });
	 
	}
		
	$("a[rel*=external]").each(function() {
			$(this).attr("target","_blank");
 		});
	
	$('#cboArea').change(function() {			
	 	 if($('#cboArea').val() == "GTP"){
			$('#divs').hide();
			$('#hidden').val(0);
		} else{
			$('#divs').show();
			$('#hidden').val(1);	

		}
	});
	 
	 if ($('.wrap').exists()) {
		 $('.wrap').hover(function(){
				
			  $(this).children('.box').stop().animate({ 'top' : '-30px'},300);
		  
		  }, function(){
		  
			  $(this).children('.box').stop().animate({ 'top' : '0'},200);
		  
		  });
		 
		 $('.box').click(function(){	
			window.location = $(this).next().attr('href');
			return false;						  
		 });
	 }
	 
	if ($('#newsticker').exists()) { 
	   $('#newsticker ul').cycle({
			  fx: 'scrollDown'
		  });
	}
	
	if($('.side-options').length != 0){
			
		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) 	{	
			$('.side-options').css('position','static');
				
		} else {
			
			var top = $('.side-options').offset().top - 115;			
			
			$(window).scroll(function (event) {
		  // what the y position of the scroll is
			  var y = $(this).scrollTop();
			  var view = $(window).height() - 100;
			  var itemh = $('.side-options').height();
			
			  // whether that's below the form
			  if (y >= top && view >= itemh ) {
				// if so, ad the fixed class
				$('.side-options').addClass('fixed');
			  } else {
				// otherwise remove it
				$('.side-options').removeClass('fixed');
			  }
			});
			
		}
	}//end .side-options
	
	if($('.side-box-holder').length != 0){
			
		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) 	{	
			$('.side-box-holder').css('position','static');
				
		} else {
			
			var top = $('.side-box-holder').offset().top - 115;
			$(window).scroll(function (event) {
		  // what the y position of the scroll is
			  var y = $(this).scrollTop();
			  var view = $(window).height() - 100;
			  var itemh = $('.side-options').height();
			
			  // whether that's below the form
			  if (y >= top && view >= itemh ) {
				// if so, ad the fixed class
				$('.side-box-holder').addClass('fixed');
			  } else {
				// otherwise remove it
				$('.side-box-holder').removeClass('fixed');
			  }
			});
			
		}
	}//end .side-box-holder
	
	//CONTACT FORM
	$('#submit').live("click", function(){
										
		$('#frmContact .btn_send').append('<img src="ct-email/ajax-loader.gif" alt="Cargando" id="loading" style="vertical-align:middle; margin-left:5px" />');
			$('.btnDefault').attr('disabled','disabled');
			var submit = $('#submit').val();
			var name = $('#name').val();
			var company = $('#company').val();			
			var phone = $('#phone').val();
			var email = $('#email').val();
			var comments = $('#comments').val();
			var hidden = $('#hidden').val();
			var cboArea = $('#cboArea').val();
			var cboDiv = $('#cboDiv').val();
			
			//console.log(name,email,comments);
			
			$.ajax({
				url: 'ct-email/script_contact.php',
				type: 'POST',
				data: 'submit=' + submit +  '&cboArea=' + cboArea +  '&cboDiv=' + cboDiv +  '&hidden=' + hidden +  '&name=' + name +  '&company=' + company + '&email=' + email + '&phone=' + phone + '&comments=' + comments,
				
				success: function(result){
					//console.log(result);
					$('#response').remove();
					$('#loading').fadeOut(500, function(){
					$('#frmContact').append( result )
					
						$(this).remove();
						$('.btnDefault').removeAttr('disabled');
					});
				}
			});
			return false;

										
	});
	
	//CV FORM
	
	 var options = { 
        target:        '#output1',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse
	 }
	 
	 if($('#frmCV').length != 0){
	 	$('#frmCV').ajaxForm(options); 
	 }
	 // pre-submit callback 
	function showRequest(formData, jqForm, options) { 	
		
		var queryString = $.param(formData);
		$('#frmCV .btn_send').append('<img src="ct-email/ajax-loader.gif" alt="Cargando" id="loading" style="vertical-align:middle; margin-left:5px" />');		
		$('.btnDefault').attr('disabled',true);		
		return true; 
		
	} 
	 
	// post-submit callback 
	function showResponse(responseText, statusText, xhr, $form)  {
		$('#loading').fadeOut(500);
		$('#loading').remove();
		$('.btnDefault').removeAttr('disabled');
	} 
	
	//e800 FORM
	
	$('#submit2').live("click", function(){
										
		$('#frme800 .btn_send').append('<img src="ct-email/ajax-loader.gif" alt="Cargando" id="loading" style="vertical-align:middle; margin-left:5px" />');
			$('.btnDefault').attr('disabled','disabled');
			var submit2 = $('#submit2').val();
			var name = $('#name').val();
			var company = $('#company').val();
			var area = $('#area').val();
			var phone = $('#phone').val();
			var anexo = $('#anexo').val();
			var subject = $('#subject').val();
			var persona = $('#persona').val();
			
			$("input:text, textarea, input:password").each(function(){
				if(this.value == '')
					this.value = this.title;
					$(this).removeClass('hoverColor');
					
			});
			
			//console.log(name,email,comments);
			
			$.ajax({
				url: 'ct-email/script_e800.php',
				type: 'POST',
				data: 'submit2=' + submit2 +  '&name=' + name +  '&company=' + company + '&area=' + area + '&phone=' + phone + '&anexo=' +  anexo + '&subject=' + subject + '&persona=' + persona,
				
				success: function(result){
					//console.log(result);
					$('#response').remove();
					$('#loading').fadeOut(500, function(){
					$('#frme800').append( result )
					
						$(this).remove();
						$('.btnDefault').removeAttr('disabled');
					});
				}
			});
			return false;

										
	});
	
	//map
	
	$('.pin').hover(
		
		function(){
			var location = $(this).attr('id');
			//alert('sdsd');
			$(this).css('z-index','5');
			$(this).append('<div id="clients"></div>');
			var content = $('.'+location).html();			
			$('#clients').append(content);
			},
		
		function(){
				$('#clients').remove();
				$(this).css('z-index','2');
			}
	
	);

});
