
$(document).ready(function(){var levels=3;var statusArray=new Array();for(var loopCounter=0;loopCounter<levels;loopCounter++){$(".toggle_box"+loopCounter).each(function(){$(this).hide();});statusArray[loopCounter]=new Array();$(".toggle_href"+loopCounter).each(function(i){$(this).bind('click',{index:i,curLevel:loopCounter},function(e){$(".toggle_box"+e.data.curLevel).each(function(divIndex){if(e.data.index==divIndex){if(!statusArray[e.data.curLevel][divIndex]){$(this).animate({height:'show',opacity:'show'},'slow');statusArray[e.data.curLevel][divIndex]=true;}else{$(this).animate({height:'hide',opacity:'hide'},'slow');hideSubBoxes(e.data.curLevel,levels);statusArray[e.data.curLevel][divIndex]=false;}}else{if(statusArray[e.data.curLevel][divIndex]){$(this).animate({height:'hide',opacity:'hide'},'slow');hideSubBoxes(e.data.curLevel,levels);statusArray[e.data.curLevel][divIndex]=false;}}});});});}
$("input#send").click(function(event){var name=$("input#name").val();var email=$("input#email").val();var text=$("textarea#text").val();var form_valid=true;$("#contact_error_name").hide();$("#contact_error_email").hide();$("#contact_error_text").hide();if(name==""){form_valid=false;$("#contact_error_name").show();}
if(email==""||!isValidEmail(email)){form_valid=false;$("#contact_error_email").show();}
if(text==""){form_valid=false;$("#contact_error_text").show();}
var dataString='name='+name+'&email='+email+'&text='+text+"&jquery=true";if(form_valid){$.ajax({type:"POST",url:"class/mail.php",data:dataString,success:function(){$('#contact_form').hide();$('#contact_title').show();}});}
event.preventDefault();});$("input#reset").click(function(event){$("#contact_error_name").hide();$("#contact_error_email").hide();$("#contact_error_text").hide();});$('a.lightbox').lightBox();function hideSubBoxes(curLevel,levels){for(var i=curLevel+1;i<=levels;i++){$(".toggle_box"+i).each(function(index){if(statusArray[i][index]){$(this).animate({height:'hide',opacity:'hide'},'slow');}
statusArray[i][index]=false;});}}});function isValidEmail(str){return(str.indexOf(".")>2)&&(str.indexOf("@")>0);}
