jQuery.fn.exists=function(){return jQuery(this).length>0};jQuery.fn.extend({slideLeft:function(){return this.each(function(){jQuery(this).animate({marginLeft:-$(this).outerWidth()});$(this).hide(0)})},slideRight:function(){return this.each(function(){$(this).show(0);jQuery(this).animate({marginLeft:0})})},});var err_state=0;var NavElem=0;var curHashVal="Blank";var link_t="";imgLoadSpin=new Image;imgNavActive=new Image;imgNavHighlight=new Image;imgNavIndicator=new Image;imgLoadSpin.src="images/main_loader.gif";imgNavActive.src="images/template/nav-active.png";imgNavHighlight.src="images/template/nav-highlight.png";imgNavIndicator.src="images/template/nav-indicator.png";var pageCache=new Array();var pos=new Object();pos.left=0;var ExternalNavLink=0;var DefaultTarget="#ContentMain";var DefaultIndex=1;var SubLocationCache=0;var cs1,cs2;var SubMain=0;var SubIndex=0;function checkHash(e){if(typeof(e)=="undefined"){e=0}var d=window.location.hash;if(curHashVal!=d||e){if(d!=""){var b=curHashVal;var a="-";if(d.charAt(d.length-1)==a){d=d.slice(-1)}curHashVal=d;err_state=0;if((d.indexOf("?")>-1)||(d.indexOf(a)==-1)){DefaultIndex=1;LoadPage(d.slice(1))}else{var f=d.slice(1).split(a);for(var c=2;c<f.length;c++){f[1]+="/"+f[c]}if(b.slice(1).split(a)[0]==f[0]){DefaultIndex=1;if(typeof(LoadSub)=="function"){LoadSub(f[0]+"/"+f[1])}}else{DefaultIndex=0;SubLocationCache=f[0]+"/"+f[1];LoadPage(f[0])}}}}}function LoadPage(c,b){if(typeof(b)=="undefined"){b=DefaultTarget}if(err_state==0){document.title="IAESTE IndiaMIT";MoveIndicator();var a=c;if(pageCache[a]==undefined){$(b+" .content").fadeOut("medium",function(){$(b).html("<div class='content' style='display:none'></div>").find(".content").html("<br /><br /><br /><br /><br /> <br /> <br /><div style='text-align:center;'><img src='images/main_loader.gif' /> <br /><br /><b>Loading..</b></div><br /><br />").show(500,function(){if(c.indexOf("?")>-1){clocation=c.substring(0,c.indexOf("?"))+".php"+c.substring(c.indexOf("?"))}else{clocation=c+".php"}$.ajax({url:"content/"+clocation,success:function(d){pageCache[a]=d;LoadPage(c,b)},error:function(d){$(b).html("<div class='content' style='display:none'></div>").find(".content").html("<br /><br /> <br /><br /><br /><center><font style='color:red'>Oops... Seems like there's some problem with your internet connection!<br />We're not able to connect to the Server!</font><br /><br /><br/><img src='images/main_loader.gif' /> <br/><br/><b>This page will automatically load once your internet is back!....</b></center><br />").show(500);err_state=1;LoadPage(c,b)}})})})}else{$(b+" .content").stop();ShowPage(a,b)}}else{if(c.indexOf("?")>-1){clocation=c.substring(0,c.indexOf("?"))+".php"+c.substring(c.indexOf("?"))}else{clocation=c+".php"}$.ajax({url:"content/"+clocation,success:function(d){pageCache[c]=d;err_state=0;LoadPage(c,b)},error:function(d){err_state=1;LoadPage(c,b)}})}}function preCache(a){$.ajax({url:"content/"+a+".php",success:function(b){pageCache[a]=b}})}function ShowPage(a,b){if(typeof(b)=="undefined"){b=DefaultTarget}if(link_t==a||link_t==""){$(b+" .content").slideUp("medium",function(){$(b).html("<div class='content' style='display:none'></div>");$(".currentNav").removeClass("currentNav");var c=pageCache[a].toString();$(b+" .content").html(c);$(b+" .videospace").fadeTo(0,0);if($.browser.msie){$(b+" .content").children().wrap("<div class='fadeHelper' style='background:white;zoom:1'></div").end().find(".fadeHelper").fadeTo(0,0);$(b+" .content").show(0,function(){$(".ajax").unbind("click");$(".ajax").click(click_fn);$(b+" .fadeHelper").fadeTo(700,1,function(){$(b+" .fadeHelper").each(function(){var d=$(this).children();$(this).replaceWith(d)})});MoveIndicator();$(b+" .videospace").fadeTo(700,1)})}else{$(b+" .content").fadeTo(700,1,function(){$(".ajax").unbind("click");$(".ajax").click(click_fn);$(b+" img:not(#slider>img)").fadeTo(700,1);$(b+" .videospace").fadeTo(700,1);MoveIndicator()})}});link_t=""}}function click_fn(a){if(!$(this).hasClass("currentNav")){if(ExternalNavLink!=1){$(".currentNav").removeClass("currentNav");$(this).addClass("currentNav")}else{ExternalNavLink=0}if(($(this).attr("class")!="noajax")){$("#NavIndicator").stop();$("#ContentMain").stop();$("#ContentMain .content").stop();link_t=$(this).attr("href");if(link_t!=undefined){DefaultIndex=1;document.location.hash=link_t;link_t=link_t.slice(1);curHashVal=document.location.hash;err_state=0;LoadPage(link_t);a.preventDefault()}}}}$(document).ready(function(){$.ajaxSetup({global:true,cache:false,type:"GET"});setInterval("checkHash()",400);$("#NavList li a, .ajax").click(click_fn);$(window).resize(function(){HandleResize()});$("#NavList li").mousemove(function(){var a=$(this).position().left;if(!$(".NavHighlight").exists()){$("#NavList").prepend("<div class='NavHighlight'></div>")}if($.browser.msie){$(".NavHighlight").children().wrap("<div class='fadeHelper' style='background:white;zoom:1'></div").end().find(".fadeHelper").fadeTo(0,0);$(".NavHighlight").show(0,function(){$(".NavHighlight .fadeHelper").fadeTo(700,1,function(){$(".NavHighlight .fadeHelper").each(function(){var b=$(this).children();$(this).replaceWith(b)})})});$(".NavHighlight").clearQueue().animate({left:a},300)}else{$(".NavHighlight").clearQueue().animate({left:a},300).animate({opacity:1},500)}});$("#NavigationWrapper").mouseleave(function(){if($.browser.msie){$(".NavHighlight").remove()}else{$(".NavHighlight").clearQueue().animate({opacity:0},200,function(){$(this).remove()})}})});function HandleResize(){if($(".currentNav").exists()){pos=$(".currentNav").position()}if(pos.left==0){pos=$("#NavItemHome").position()}$("#NavIndicator").css({left:pos.left+60,top:pos.top+35})}function MoveIndicator(){if($(".currentNav").exists()){pos=$(".currentNav").position()}if(pos.left==0){pos=$("#NavItemHome").position()}$("#NavIndicator").stop().animate({left:pos.left+60,top:pos.top+35},500,function(){$(this).fadeIn(1)})}function LinkToNav(a){ExternalNavLink=1;$(".currentNav").removeClass("currentNav");$("#"+a).addClass("currentNav")}function scrollToTop(){$("html").animate({scrollTop:0},"slow");$("body").animate({scrollTop:0},"slow")}function ChangeHeading(a){if(a==""){$("#PageHeading").hide(300).html("")}else{$("#PageHeading").delay(300).html(a).show(400)}}function LoadSub(a,b){if(typeof(b)=="undefined"){b="#subcontent"}if(typeof(a)=="undefined"){if(DefaultIndex){ChangeHeading("");LoadPage(SubMain+"/"+SubIndex,b)}else{ChangeHeading("");LoadPage(SubLocationCache,b)}}else{ChangeHeading("");LoadPage(a,b)}};
