/* Author: 

	MOSTRO (Santiago Mollajoli)

*/





/*



#################################################################################################################



#***************************************************************************************************************#



#***************************************************************************************************************#



#**********************************                                       **************************************#



#----------------------------------                 SCRIPTS               --------------------------------------#  



#**********************************                                       ************************************* #



#***************************************************************************************************************#



#***************************************************************************************************************#



#################################################################################################################



*/





/* ***************************************************************************************************************



---------------------------------                   TOOGLE HEADER                     ---------------------------  



**************************************************************************************************************** */ 



	





$(document).ready(function(){

	

	if($.browser.msie && parseInt($.browser.version, 10) == 7) {

		$('.login-tab_inner').css('position','absolute');



} 

	

/************************** ROUNDED CORNERS ********************************* */ 

	

	if( $.browser.msie || $.browser.opera ){ $('.btn, .top-tab, .login-tab').corner("round 7px");}

	

/************************** ROUNDED CORNERS ********************************* */ 



	

	

	$(".login-tab_inner").fadeTo(0, 0);



	var logInScrolling = false;

	

	$(".log").click(function(e){
		
	e.preventDefault();
	e.stopPropagation();

		var height = $("."+$(this).attr("rel")).height();

		var target = $("."+$(this).attr("rel"));

	

	if ( logInScrolling == false ) {

		if ( height < 1 ) {

			

				$(".login-tab").css({visibility: "visible", display: "block" });

				logInScrolling = true;

				

				$(target).animate({height: 94}, 500, function() {

					

					$(this).children().fadeTo('fast', 1);

					$(".log-error").css({display: "none"});

					logInScrolling = false;

				});

			

		} else {

			logInScrolling = true;

			$(target).children().fadeTo('fast', 0, function() {

				

				$(target).animate({height: 0}, 200, function(){

					$(".login-tab").css({visibility: "hidden", display: "none" });

					});

				logInScrolling = false;

			});

				

		}

				

		};		

	}); /* end .log click */



			



/* ***************************************************************************************************************



---------------------------------               END TOOGLE HEADER                     ---------------------------  



**************************************************************************************************************** */







/*apply margin left to divs that have cats inside*/



$('.slide-child').has('.cat').find('.cat').next('.slide-child').css('margin-left','20px');











/* ***************************************************************************************************************



---------------------------------               FOCUS FORMS                     ---------------------------  



**************************************************************************************************************** */



	 

			/*$('input, textarea').focus(function() {

				$(this).removeClass("idleField").addClass("focusField");

		        if (this.value == this.defaultValue){

		        	this.value = '';

		    	}

		        if(this.value != this.defaultValue){

			    	this.select();

		        }

		    });

		    $('input, textarea').blur(function() {

		    	$(this).removeClass("focusField").addClass("idleField");

		        if (this.value == ''){

		        	this.value = this.defaultValue;

					$(this).removeClass("idleField");

		    	}

		    });*/



/* ***************************************************************************************************************



---------------------------------              END FOCUS FORMS                     ---------------------------  



**************************************************************************************************************** */





/* ***************************************************************************************************************



---------------------------------------            BASES                 -----------------------------------------  



**************************************************************************************************************** */



$('.cat .slide-toogle a').hover(

  function () {

    $(this).parent().parent().css('background-color' , '#191919');

  },

  function () {

    $(this).parent().parent().css('background-color' , '#0E0E0E');

  }

);



/*var child = $(this).parent().parent().find(".slide-child").first();

var target = $(this).parent().parent().find(".slide-child").first();

var scrollToItem = $(target).position().top+300;

alert($(this).parents(".slide-item").attr("class")); 

*/



$('.slide-toogle a').click(function(e) {

	e.preventDefault();
	e.stopPropagation();

	var slideEnds =false;

	var father = $(this).parent().parent();

	var child = $(this).parents(".slide-item").children(".slide-child").first();

	var target = $(this).parents(".slide-item");

	



	if ($(child).is(':visible')) {

		$(child).fadeTo(0);

		$(child).slideUp(800, function() {

		slideEnds = true;

			

		});

	} else {

		

		if ($ (father).attr("class") == "cat" ) {

			$('.cat a').css('color', '#444444');

			$(this).css('color', '#F9F09F');

			

		};

		$(child).slideDown(900, function() {

			

		 slideEnds = true;

			if ( slideEnds == true) {

				slideEnds = false;

				$.scrollTo($(target).position().top-30, 1000, {axis:'y'}, { easing:'swing' });

				

			};

			

		});

	

	}

	return false;

});











/************************** PRICE TABLE ********************************* */ 



	$(".price-table tr:even").css("background-color", "#171717");

	$(".price-table td:nth-child(1)").css("padding-left", "10px");

	

$('.price-table tr').hover(

	

  function () {	

    $(this).addClass('tr-hover');

  },

  function () {

   $(this).removeClass('tr-hover');

  }

);





/************************** END PRICE TABLE ********************************* */ 







/************************** CREATING TOOLTIPS ********************************* */ 



$('.tip-trigger').click(function(e) {
	
	e.preventDefault();
	e.stopPropagation();
	
	$('.tooltip').hide();

	var showTip = $(this).attr('rel');

	var relativeX = $(this).pageX;

	var relativeY = $(this).pageY;

	$(showTip).css({

	  left: relativeX ,

	  top: relativeY 

	})

	

	/************************** TOOLTIPS TWEAK FOR NOTIFICATIONS ********************************* */ 

	if (showTip == ".notificar") {



		$('.notification .tooltip').css({ top: $('.tip-trigger').position().top+40, left: $('.tip-trigger').position().left-20 });

	};

	/************************** END TOOLTIPS TWEAK FOR NOTIFICATIONS ********************************* */ 

	

	

	$(showTip).fadeTo('slow', 1, function() {

	});

	
	return false;

});



var mouse_is_inside = false;

var targetTip = $('.tip-trigger').attr('rel');



$('body').delegate('.tooltip', 'click', function(){

	$(this).fadeTo('fast', 0, function() {

		$(this).hide()

	});

});





	$(".tooltip li:even").css("background-color", "#0a0a0a");



$('.tip-trigger').click(function() {

	$.scrollTo($(this).position().top-30, 1000, {axis:'y'}, { easing:'swing' });

});	





/************************** END CREATING TOOLTIPS ********************************* */ 







/* ***************************************************************************************************************



-----------------------------------            CHECKBUTTONS                -------------------------------------  



**************************************************************************************************************** */

$('input:checkbox').screwDefaultButtons({
	checked: 	"url(img/system/checkbox_Checked.jpg)",
	unchecked:	"url(img/system/checkbox_Unchecked.jpg)",
	width:		19,
	height:		19
});

/* ***************************************************************************************************************



-----------------------------------            END CHECKBUTTONS                -------------------------------------  



**************************************************************************************************************** */








/* ***************************************************************************************************************



---------------------------------------            END BASES                 -----------------------------------------  



**************************************************************************************************************** */







/* ***************************************************************************************************************



-------------------------------------            CUSTOM SELECTS                ------------------------------------  



**************************************************************************************************************** */


function CustomSelects() {
	if (!$.browser.opera) {



		// select element styling

		$('select.select').each(function(){

			var title = $(this).attr('title');

			if( $('option:selected', this).val() != '0'  ) title = $('option:selected',this).text();

			$(this)

				.css({'z-index':10,'opacity':0,'-khtml-appearance':'none'})

				.after('<span class="select">' + title + '</span>')

				.change(function(){
					if (this.name == "anio_emision"){
							cargarMeses("#mes_emision")
							
						}

					val = $('option:selected',this).text();

					$(this).next().text(val);
					

					
					

					})

		});


		
	};

}

CustomSelects();




function CustomSubSelects() {
	if (!$.browser.opera) {



		// select element styling

		$('select.select').each(function(){
			

			var title = $(this).attr('title');

			if( $('option:selected', this).val() != ''  ) title = $('option:selected',this).text();

			$(this)

				.css({'z-index':10,'opacity':0,'-khtml-appearance':'none'})

				.after('<span class="select">' + title + '</span>')

				.change(function(){
					
					

					val = $('option:selected',this).text();

					$(this).next().text(val);
					

					
					

					})

		});


		
	};

}


/* ***************************************************************************************************************



-------------------------------------            END CUSTOM SELECTS                ------------------------------------  



**************************************************************************************************************** */







/* ***************************************************************************************************************



-------------------------------------            MESES FORM                ------------------------------------  



**************************************************************************************************************** */


var mesesHabilitados = new Array();
		mesesHabilitados[2010] = new Array();
		mesesHabilitados[2010][mesesHabilitados[2010].length] = new Array(9, "Setiembre");
		mesesHabilitados[2010][mesesHabilitados[2010].length] = new Array(10, "Octubre");
		mesesHabilitados[2010][mesesHabilitados[2010].length] = new Array(11, "Noviembre");
		mesesHabilitados[2010][mesesHabilitados[2010].length] = new Array(12, "Diciembre");
		
		mesesHabilitados[2011] = new Array();
		mesesHabilitados[2011][mesesHabilitados[2011].length] = new Array(1, "Enero");
		mesesHabilitados[2011][mesesHabilitados[2011].length] = new Array(2, "Febrero");
		mesesHabilitados[2011][mesesHabilitados[2011].length] = new Array(3, "Marzo");
		mesesHabilitados[2011][mesesHabilitados[2011].length] = new Array(4, "Abril");
		mesesHabilitados[2011][mesesHabilitados[2011].length] = new Array(5, "Mayo");
		mesesHabilitados[2011][mesesHabilitados[2011].length] = new Array(6, "Junio");
		mesesHabilitados[2011][mesesHabilitados[2011].length] = new Array(7, "Julio");
		mesesHabilitados[2011][mesesHabilitados[2011].length] = new Array(8, "Agosto");
		
		
		function cargarMeses(){

			anioActual = document.getElementById("anio_emision").value;
			divMeses = document.getElementById("mes_emision");
			divMeses.innerHTML = "";
			nuevoHTML = "";
			
			if (anioActual != 0) {
			for(var i=0; i<mesesHabilitados[anioActual].length; i++){
				nuevoHTML += '<option value="'+mesesHabilitados[anioActual][i][0]+'"';
				if(mesesHabilitados[anioActual][i][0]==""){
					nuevoHTML += ' selected=selected';
				}
				nuevoHTML += '>'+mesesHabilitados[anioActual][i][1]+'</option>';
			}
			}
			divMeses.innerHTML += '<label>MES</label><select name="mes_emision" class="select">'+nuevoHTML+'</select>';
			
			 title = $('option:selected', divMeses).text();
			 $(divMeses)

				.css({'z-index':10,'opacity':1,'-khtml-appearance':'none'})

				.append('<span class="select">' + title + '</span>')
		
		}
		cargarMeses();


/* ***************************************************************************************************************



-------------------------------------            END MESES FORM                ------------------------------------  



**************************************************************************************************************** */










/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

/*-----------------------------------------------------     VALIDAR      -----------------------------------------------------*/

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

$(":text").blur(function() {
     $('.error_img').html("");
	 $('.success_img').html("");
   });
   
   $(":text").focus(function() {
     $('.error_img').html("");
	 $('.success_img').html("");
   });
   
$(":text").keypress(function() {
   $('.error_img').html("");
	 $('.success_img').html("");
});

$(":text").keyup(function() {
   $('.error_img').html("");
	 $('.success_img').html("");
});


$('.validar').click(function() {
	 $('#inscripForm').submit();
});



/*  $("#inscripForm").validate({
         errorClass: "error_img",
          errorElement: "div",
		  meta: "error-text",
           showErrors: function(errorMap, errorList) {
           		$("#summary").html("Your form contains "
                                              + this.numberOfInvalids() 
                                              + " errores, obvserva los detalles.");
           		this.defaultShowErrors();
           	},
           	errorPlacement: function(error, element) { 
                          if ( element.is("select") ) 
                               error.appendTo( element.parent(".CustomSelect")); 
                          else if ( element.is(":checkbox") ) 
                              error.appendTo ( element.next() ); 
                          else 
						  
						  	var errorClone = error.clone().removeClass('error_img');
                        	$(".error-text").append(errorClone);
                        		error.insertAfter(element).bind("hide", function(){
                                errorClone.hide();
                        });


                              error.appendTo( element.parent(".single_input")).html(""); 
						
                      },
           	
           	
           success: "success_img",
		   
		   	successPlacement: function(error, element) { 
                          if ( element.is("select") ) 
                               error.appendTo( element.parent(".CustomSelect")); 
                          else if ( element.is(":checkbox") ) 
                              success.appendTo ( element.next() ); 
                          else 
						  
						  	var successClone = success.clone().removeClass('success_img');
						   
                        	$(".error-text").append(successClone);
                        		success.insertAfter(element).bind("hide", function(){
                                successClone.hide();
                        });


                              success.appendTo( element.parent(".single_input")).html(""); 
						
                      },
          
       debug: true,
       rules: {
          
            prodName: {
               required:true,
                minlength: 15
            },
            anio_emision: {
                required:true,
             },
            agency: {
               required:true,
               minlength: 15,
               
            }
         }
     
  });*/

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

/*-----------------------------------------------------     END VALIDAR      -----------------------------------------------------*/

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
























});  /* end DOM Ready*/ 


Shadowbox.init();


/*-----------------END START DOC READY*/






/*




function MM_validateForm() { //v4.0

  if (document.getElementById){

    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;

    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);

      if (val) { nm=val.name; if ((val=val.value)!="") {



   if(nm == "name"){

      if(val=="Nombre"){

	      $("#name_error").show("slow");

		  $("#name_ok").hide("slow");

		  errors += "name"

	  }

  else if (val=="Name"){

		  $("#name_error").show("slow");

		  $("#name_ok").hide("slow");

		  errors += "name"

		  }

	  

	   else{

	     $("#name_error").hide("slow");

		  $("#name_ok").show("slow");

	  }

	

	};

	  

        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');

          if (p<1 || p==(val.length-1)) {

		  $("#email_ok").hide("slow");

		  $("#email_error").show("slow");

		  errors += "email"

		} else 

		{

		  $("#email_error").hide("slow");

		  $("#email_ok").show("slow");

		}

		 

        } else if (test!='R') { num = parseFloat(val);

         

		  if (isNaN(val)) 

	    {

		  $("#tel_ok").hide("slow");

		  $("#tel_error").show("slow");

		  errors += "number"

		} else 

		{

		  $("#tel_error").hide("slow");

		  $("#tel_ok").show("slow");

		}

		

     if (test.indexOf('inRange') != -1) { p=test.indexOf(':');

            min=test.substring(8,p); max=test.substring(p+1);

            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';

      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }

    } if (errors){

	document.MM_returnValue = (errors == '');}

	else{

	document.forms[0].submit();

	}

} }

//-->



function gup( name ){

	var regexS = "[\\?&]"+name+"=([^&#]*)";

	var regex = new RegExp ( regexS );

	var tmpURL = window.location.href;

	var results = regex.exec( tmpURL );

	if( results == null )

		return"";

	else

		return results[1];

}





function evalmail(){



var message = gup( 'email' );



if (message == "sent"){

$.scrollTo($("#contact").position().top-40 , 1000, { easing:'swing' , onAfter: function(){

	$("#msg_mail").show("slow");

	} });



}



}

*/






























