
var MAIN={};var maxAngles=Array();var angles=[1.57,1.177,0.78,0.39,0,-0.393,-0.786,-1.179,-1.572,-1.964];var piMinusangles=[3.142,2.749,2.356,1.963,1.571,1.178,0.785,0.393,0,-0.393];var allLinks=undefined;var timer=undefined;var animationTime=0;var xValues=Array();var yValues=Array();MAIN.move_teepees=function(){if($(window).height()>800){$("#teepees").css('top','30%');}else{$("#teepees").css('top','26%');}}
$(document).ready(function(){if($.browser.msie){ie_resize();$(window).resize(ie_resize);}
$(window).resize(MAIN.move_teepees);MAIN.move_teepees();allLinks=$(".level1");var len=allLinks.length;var len2=angles.length;for(var i=0;i<len;i++){maxAngles[i]=jQuery(allLinks[i]).children('input')[0].value;xValues[i]=Array();yValues[i]=Array();for(var s=0;s<len2;s++){myAngle=angles[s]+(3.14-maxAngles[i]);xValues[i][s]=Math.cos(myAngle);yValues[i][s]=Math.sin(-myAngle);}}
createStars();$('#wsaf').click(ShowMainMenu_start);$("#message").find('.close').click(function(){$("#message").fadeOut('slow');});$("#contactUs").click(MAIN.showContactUs);$("#topWindow").find('.close').click(MAIN.hideContactUs);});function ie_resize(){var docWidth=$(window).width();var docHeight=$(window).height();if((docWidth>=980)&&(docHeight>=590)){$('html').css('overflow','hidden');}else{$('html').css('overflow','auto');}}
function rand(n)
{return(Math.floor(Math.random()*n+1));}
createStars=function(){var docWidth=$(document).width();var stars=$("#star_holder");if(stars==undefined){return}
var numStars=docWidth/30;for(var i=0;i<numStars;i++){var x=rand(100);var y=rand(30);if(($.browser.msie)&&(parseFloat($.browser.version)<7)){stars.append("<div class='star1_ie6' style='top: "+y+"%; left: "+x+"%;'></div>")}else{stars.append("<div class='star1' style='top: "+y+"%; left: "+x+"%;'></div>")}}}
ShowMainMenu=function(){for(var i=0;i<4;i++){if(piMinusangles[animationTime]<=parseFloat(maxAngles[i])){x=25+(xValues[i][animationTime]*220);y=44+(yValues[i][animationTime]*220);allLinks[i].style.top=y+'px';allLinks[i].style.left=x+'px';}}
if(-(angles[animationTime]-1.57)>3.34){animationTime--;clearInterval(timer);$('#wsaf').click(HideMainMenu_start);$("#homeLink").click(HideMainMenu_start);}
animationTime++;}
HideMainMenu_start=function(){timer=setInterval('HideMainMenu()',60);$('#wsaf').unbind('click');var homeLink=$('#homeLink');homeLink.unbind('click');HideMainMenu()
homeLink.fadeOut();}
ShowMainMenu_start=function(){timer=setInterval('ShowMainMenu()',60);$(".level1").css('display','block');$('#wsaf').unbind('click');ShowMainMenu();$("#homeLink").fadeIn('slow');}
HideMainMenu=function(){for(var i=0;i<4;i++){if(piMinusangles[animationTime]<=parseFloat(maxAngles[i])){x=25+(xValues[i][animationTime]*220);y=44+(yValues[i][animationTime]*220);allLinks[i].style.top=y+'px';allLinks[i].style.left=x+'px';}}
if(-(angles[animationTime]-1.57)<=0){animationTime=0;clearInterval(timer);$(".level1").css('display','none');$('#wsaf').bind('click',ShowMainMenu_start);}
animationTime--;}
MAIN.sendContactUs=function(e){$("#message").fadeOut('fast');var targetEl=(e.srcElement==undefined)?e.target:e.srcElement;var form=$(targetEl);var reg=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;var email=$('#contact_email').val();var name=$('#contact_name').val();var subject=$('#contact_subject').val();var message=$('#contact_message').val();var sendTo=form[0]['contact[sendTo]'].value;window.location=window.location.protocol+'//'+window.location.hostname+window.location.pathname+"#contactTop";if((message=='')||(subject=='')||(name=='')||(email=='')){var msg=$("#message");msg.children('p').html('You must fill in all fields! - please complete the form and resubmit.');msg.fadeIn();return false;}
if(reg.test(email)==false){var msg=$("#message");msg.children('p').html('Your email address appears to be invalid, please correct this and resubmit the form.');msg.fadeIn();return false;}
$.ajax({cache:false,data:{contact:{name:name,email:email,subject:subject,message:message,sendTo:sendTo,sendToName:$("#contactMsgFor").html()}},dataType:'html',type:'POST',url:$(form).attr('action'),success:function(data){$("#topWindow").find('.content').html(data);$("#topWindow").find('form').submit(MAIN.sendContactUs);$("#message").find('.close').click(function(){$("#message").fadeOut('slow');});$("#topWindow").find('.col3').children('a').click(MAIN.changeContactPerson);}});form.find('input').attr("disabled","disabled");form.find('textarea').attr("disabled","disabled");form[0]['contact[submit]'].value='Sending...';return false;}
MAIN.showContactUs=function(e){var targetEl=(e.srcElement==undefined)?e.target:e.srcElement;var el=$(targetEl);var url=el.attr('href');$("#dialogTitle").html(el.html());$("#topWindow").find('.content').html('<img src="/img/ajax-loader.gif" alt="Loading..." id="AjaxLoader"/>');$("#topWindow").find('.content').load('/ajax'+url,function(){$("#topWindow").find('form').submit(MAIN.sendContactUs);$("#message").find('.close').click(function(){$("#message").fadeOut('slow');});$("#topWindow").find('.col3').children('a').click(MAIN.changeContactPerson);});if($.browser.msie){$("#topWindowBackdrop").show();}else{$("#topWindowBackdrop").fadeIn();}
$("#topWindow").fadeIn();e.returnValue=false;return false;}
MAIN.changeContactPerson=function(e){e.returnValue=false;var targetEl=(e.srcElement==undefined)?e.target:e.srcElement;if(targetEl.tagName!='a'){var aTag=$(targetEl).parents('a');}else{var aTag=$(targetEl);}
$("#topWindow").find('.col3').children('a').removeClass('selected');aTag.addClass('selected');$("#contactMsgFor").fadeOut(function(){$("#contactMsgFor").html(aTag.find('p')[1].innerHTML);$("#contactMsgFor").fadeIn();});var hrefPos=aTag.attr('href').lastIndexOf('/');$("#topWindow").find('form')[0]['contact[sendTo]'].value=aTag.attr('href').substring(hrefPos+1);return false;}
MAIN.hideContactUs=function(event){if($.browser.msie){$("#topWindowBackdrop").hide();}else{$("#topWindowBackdrop").fadeOut();}
$("#topWindow").fadeOut();}