﻿(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var b=false,animCss=o.vertical?"top":"right",sizeCss=o.vertical?"height":"width";var c=$(this),ul=$("ul",c),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v}var f=$("li",ul),itemLength=f.size(),curr=o.start;c.css("visibility","visible");f.css({overflow:"hidden",float:o.vertical?"none":"right"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});c.css({overflow:"hidden",position:"relative","z-index":"2",right:"0px"});var g=o.vertical?height(f):width(f);var h=g*itemLength;var j=g*v;f.css({width:f.width(),height:f.height()});ul.css(sizeCss,h+"px").css(animCss,-(curr*g));c.css(sizeCss,j+"px");if(o.btnPrev)$(o.btnPrev).click(function(){return go(curr-o.scroll)});if(o.btnNext)$(o.btnNext).click(function(){return go(curr+o.scroll)});if(o.btnGo)$.each(o.btnGo,function(i,a){$(a).click(function(){return go(o.circular?o.visible+i:i)})});if(o.mouseWheel&&c.mousewheel)c.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll)});if(o.auto)setInterval(function(){go(curr+o.scroll)},o.auto+o.speed);function vis(){return f.slice(curr).slice(0,v)};function go(a){if(!b){if(o.beforeStart)o.beforeStart.call(this,vis());if(o.circular){if(a<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*g)+"px");curr=a==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll}else if(a>=itemLength-v+1){ul.css(animCss,-((v)*g)+"px");curr=a==itemLength-v+1?v+1:v+o.scroll}else curr=a}else{if(a<0||a>itemLength-v)return;else curr=a}b=true;ul.animate(animCss=="right"?{right:-(curr*g)}:{top:-(curr*g)},o.speed,o.easing,function(){if(o.afterEnd)o.afterEnd.call(this,vis());b=false});if(!o.circular){$(o.btnPrev+","+o.btnNext).removeClass("disabled");$((curr-o.scroll<0&&o.btnPrev)||(curr+o.scroll>itemLength-v&&o.btnNext)||[]).addClass("disabled")}}return false}})};function css(a,b){return parseInt($.css(a[0],b))||0};function width(a){return a[0].offsetWidth+css(a,'marginRight')+css(a,'marginLeft')};function height(a){return a[0].offsetHeight+css(a,'marginTop')+css(a,'marginBottom')}})(jQuery);

//jsTabs by neo22s
function getElementsByClassDustin(searchClass,node,tag) { //by http://www.dustindiaz.com/getelementsbyclass/
    var classElements = new Array();
    if ( node == null ) node = document;
    if ( tag == null )  tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
    for (i = 0, j = 0; i < elsLen; i++) {
            if ( pattern.test(els[i].className) ) {
                    classElements[j] = els[i];
                    j++;
            }
    }
    return classElements;
}
function getElementsByClass(searchClass,node,tag) { 
	//if is Netscape we use the native procedure
	if (navigator.appName=="Netscape") return document.getElementsByClassName(searchClass);
	else return getElementsByClassDustin(searchClass,node,tag);
}
function ShowTab(id){
	if (document.getElementById("sub"+id)==null) id=0;//some menus do not have submenus
	//hidding the boxes
	var eBox = getElementsByClass("sub",document.getElementById('top_cats'),"div");//all the boxes
	for (i in eBox) hide(eBox[i].id);
	//show the box
	show('sub'+id);	
	//change tab class
	var eTab = getElementsByClass("default_page_item",document.getElementById('nav'),"li");//all the tabs
	for (i in eTab) eTab[i].className ='page_item page-item';
	//set on the tab
	document.getElementById('nav'+id).className ='default_page_item';
}

function show(id){element=document.getElementById(id);if(element!=null){element.style.display='block';}}
function hide(id){element=document.getElementById(id);if(element!=null){element.style.display='none';}}
function openClose(id){element=document.getElementById(id);if(element!=null){if(element.style.display=='block'){hide(id);}
else{show(id);}}}
var errorColor="#fbc311";var normalColor="#FFFFFF";function ValidationException(codigo,mensaje,campo){this.codigo=(codigo==undefined)?0:codigo;this.mensaje=(mensaje==undefined)?null:mensaje;this.campo=(campo==undefined)?null:campo;}
function validateElements(elementos){for(var idx=0;idx<elementos.length;idx++){var vacio=elementos[idx].getAttribute("lang");if(((vacio=="false")&&(elementos[idx].value==""))||elementos[idx].style.backgroundColor=="rgb(251, 195, 17)"){throw new ValidationException(1,"Needed: ",elementos[idx])}}}
function checkForm(form){var ok;try{validateElements(form.elements);ok=true;}catch(ex){ex.campo.style.backgroundColor=errorColor;ex.campo.focus();ok=false;}
if(ok==true)document.getElementById('submit').value="loading...";return ok;}
function validateEmail(email){if(!isEmail(email.value)){email.style.backgroundColor=errorColor;}
else{email.style.backgroundColor=normalColor;}}
function validateText(e){if(e.value.length<3){e.style.backgroundColor=errorColor;}
else{e.style.backgroundColor=normalColor;}}
function validateNumber(e){if(e.value.length<1){e.style.backgroundColor=errorColor;}
else{e.style.backgroundColor=normalColor;}}
function isNumberKey(evt){var charCode=(evt.which)?evt.which:event.keyCode;if((charCode==46||charCode==8||charCode==45||charCode==47)||(charCode>=48&&charCode<=57)){return true;}
else{return false;}}
function isAlphaKey(evt){var charCode=(evt.which)?evt.which:event.keyCode;if((charCode==231||charCode==199)||(charCode==241||charCode==209)||(charCode==8||charCode==32)||((charCode>=65&&charCode<=90)||(charCode>=97&&charCode<=122))){return true;}
else{return false;}}
function isEmail(valor){if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){return(true)}else{return false;}}
function youtubePrompt(){
    vurl=prompt('Youtube.com URL','http://www.youtube.com/watch?v=XXXXXXX');
    if(vurl != null && vurl.indexOf("http://www.youtube.com/watch?v=")==0){
        document.getElementById('video').value=vurl;
        file=vurl.substr(31,vurl.length);
        tags = "<object width=\"425\" height=\"350\"><param name=\"movie\" value=\""+file+"\"></param><param name=\"wmode\" value=\"transparent\" ></param><embed src=\"http://www.youtube.com/v/"+file+"\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"425\" height=\"350\"></embed> </object>"; 
        document.getElementById('youtubeVideo').innerHTML=tags;
    }
    else {
         document.getElementById('video').value="";
         document.getElementById('youtubeVideo').innerHTML="";
    }
}


$(document).ready(function($) {
	
	submitRedirectForm();
	
	$('#human').hide();
	
	$(".slider").jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev",
		visible: 5,
		scroll: 2,
		auto: 4000,
		speed: 1000
	});
});

function submitRedirectForm()
{
	if($("#redirectForm") != null && typeof $("#redirectForm") != "undefined")
	{
		var submitRForm = function(){$("#redirectForm").submit();};
		setInterval(submitRForm, 7000);
	}
}
