function timeHide() {
    $('#timer').css('display','none');
    $('.close').css('display','none');
    $('#cntdwn').css('display','none');
    return;
}
function timeShow() {
    $('#timer').css('display','block');
    $('.close').css('display','block');
    $('#cntdwn').css('display','block');
    return;
}
/*function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
return false;
}*/
$(window).load(function(){

	if (navigator.appName == 'Microsoft Internet Explorer')
		$('#mcs2_container .customScrollBox .content').css('height','auto');
	
    $("body").css("background-image","url('img/gradient.png')")
    $("#container").show();
	$("#specials").show();
    $("#loader").hide();
    $.jGrowl("Check out the specials page for supporting the green initiative of Waves 2011");
    $.jGrowl("Check out the Accommodation tab for accommodation assistance for out station participants");
    $.jGrowl("The Rulebook has been Updated!");
    $.jGrowl("Animusic Sample has been added. Check the Rules of Animusic.");
    setInterval(function() {
        $("#lights").toggle();
    }, 1000);
    $("#forgot-form").toggle();
    window.open("http://www.coolage.in", '_blank');
	//setTimeout(timeShow(), 50000);
	
	
    /***
     *-------------------SCROLLING functions------------------------*
     ***/

    $.scrollTo( $('#home'), 1 );
    $('.homenav').click(function(){
        $.scrollTo( $('#home'), 800 );
        timeShow();
    });
    $('.returnhome').click(function(){
        $.scrollTo( $('#home'), 800 );
        timeShow();
    });
    $('.eventsnav').click(function(){
        $.scrollTo( $('#events'), 800 );
        timeHide();
        $(".textarea").html("<h1>The Events</h1><p>Kick up your heels. Conjure up a storm. Whet your inquisitiveness. Unleash the Bard within. All the world's a stage, it calls upon you to perform. Witness the coming together of the false Gods of the performing arts. Prove your mettle against the very finest. Or simply take pot-shots at your friends' making a laughingstock of themselves. An eclectic mix of dazzling events awaits you this Waves, brace yourselves.</p>");
    });
    $('.specialsnav').click(function(){
        $.scrollTo( $('#specials'), 800 );
        timeHide();
    });

    $('.workshopsnav').click(function(){
        $.scrollTo( $('#workshops'), 800 );
        timeHide();
    });
    $('.nitesnav').click(function(){
        $.scrollTo( $('#nites'), 800 );
		timeHide();
		
        for (var i=0;i<50;i++)
        {
            $('#nitefish1').animate({
                top: '-=50'
            }, 7000, function() {
                // Animation complete.
            });
            $('#nitefish1').animate({
                top: '+=50'
            }, 6000, function() {
                // Animation complete.
            });
            $('#nitefish2').animate({
                top: '+=50'
            }, 11000, function() {
                // Animation complete.
            });
            $('#nitefish2').animate({
                top: '-=50'
            }, 9000, function() {
                // Animation complete.
            });
        };
        
    });
    $('.informalsnav').click(function(){
        $.scrollTo( $('#informals'), 800 );
        
    });

    $('.contactnav').click(function(){
        $.scrollTo( $('#contact'), 800 );
        timeHide();
		
		
        /*Animations for Contacts Page*/
		
        for (var i=0;i<200;i++)
        {
            $('#scuba').animate({
                left: '+=50',
                top: '-=50'
            }, 10000, function() {
                // Animation complete.
            });
            $('#scuba').animate({
                left: '+=50',
                top: '+=50'
            }, 10000, function() {
                // Animation complete.
            });
            $('#scuba').animate({
                left: '-=50',
                top: '-=50'
            }, 10000, function() {
                // Animation complete.
            });
            $('#scuba').animate({
                left: '-=50',
                top: '+=50'
            }, 10000, function() {
                // Animation complete.
            });
        };
		
    });

        $('.sponsorsnav').click(function(){
        $.scrollTo( $('#sponsors'), 800 );
		timeHide();		
        /***
         *------------------SPONSORS PAGE CODE(Should be inside Scrollto Function, animation starts when the Frame is loaded)---------------------------*
         ***/
		 
		 //On page load, cloud animations
    
    for (var i=0;i<50;i++)
    {
        $('.a1').animate({
            left: '-=80',
            top: '+=95'
        }, 20000, function() {
            // Animation complete.
        });
        $('.a1').animate({
            left: '+=52',
            top: '-=103'
        }, 17000, function() {
            // Animation complete.
        });
    };
    for (var i=0;i<50;i++)
    {
        $('.a2').animate({
            left: '+=70',
            top: '-=110'
        }, 14000, function() {
            // Animation complete.
        });
        $('.a2').animate({
            left: '-=130',
            top: '+=120'
        }, 11000, function() {
            // Animation complete.
        });
    };
		 
        for (var i=0;i<50;i++)
        {
            $('#fz').animate({
                top: '-=100'
            }, 12000, function() {
                // Animation complete.
            });
            $('#fz').animate({
                top: '+=100'
            }, 15000, function() {
                // Animation complete.
            });
        };
        for (var i=0;i<50;i++)
        {
            $('#f1').animate({
                top: '-=100'
            }, 20000, function() {
                // Animation complete.
            });
            $('#f1').animate({
                top: '+=100'
            }, 20000, function() {
                // Animation complete.
            });
        };
        for (var i=0;i<50;i++)
        {
            $('#f2').animate({
                left: '-=600'
            }, 500000, function() {
                // Animation complete.
            });
            $('#f2').animate({
                left: '+=600'
            }, 500000, function() {
                // Animation complete.
            });
        };

        for (var i=0;i<50;i++)
        {
            $('#f5').animate({
                left: '-=100',
                top: '-=100'
            }, 30000, function() {
                // Animation complete.
            });
            $('#f5').animate({
                left: '+=100',
                top: '+=100'
            }, 30000, function() {
                // Animation complete.
                
            });

        };

	
    });

    $('.registernav').click(function(){
        $.scrollTo( $('#registration'), 800 );
		timeHide();
        /*Animations for Registration Page*/
		
        for (var i=0;i<50;i++)
        {
            $('#regfish1').animate({
                top: '-=50'
            }, 7000, function() {
                // Animation complete.
            });
            $('#regfish1').animate({
                top: '+=50'
            }, 6000, function() {
                // Animation complete.
            });
            $('#regfish2').animate({
                top: '+=50'
            }, 11000, function() {
                // Animation complete.
            });
            $('#regfish2').animate({
                top: '-=50'
            }, 9000, function() {
                // Animation complete.
            });
        };
    });
});





$(document).ready(function(){

	$('.close').click(function(){
	    $('#timer').fadeOut('slow', function() {
        });
	    $('.close').fadeOut('slow', function() {
        });
	    $('#cntdwn').fadeOut('slow', function() {
        });
    });
	
	timeHide();

	$("#mcs_container").mCustomScrollbar("vertical",300,"easeOutCirc",1.05,"auto","yes","yes",15);
		
    $("#container").hide();
	$("#specials").hide();
    $("#loader").show();
	
	$("#mcs2_container").mCustomScrollbar1("vertical",200,"easeOutCirc",1.05,"auto","yes","yes",10);
	
    var globalevent="";
    var globalcategory="";
    var globalcheck="";
	var accp = "offcampus";
	
	$('.checkbox').removeClass('checked').addClass('unchecked');
	/***var chkBox1 = document.getElementById('accom_place');
	chkBox.checked=false;***/
	
	/****-------------------CHECKBOX CODE------------------------****/
	
	$('.checkbox').click(function(){
			
		var chkBox = document.getElementById('accom_place');
		var status="";
		if (chkBox.checked){
			status="true";
		}
		else{
			status="false";
		}
				
		if(status==="true"){
			// uncheck
			$(this).removeClass('unchecked').addClass('checked');
			accp = "incampus";
			//alert("Accomodation Changed to: "+accp);
		}
		else{
			// uncheck
			$(this).removeClass('checked').addClass('unchecked');
			accp = "offcampus";
			//alert("Accomodation Changed to: "+accp);
		}
	});

	
    /***
     *----------------------WORKSHOPS TABS CODE------------------------*
     ***/	
	
	    $('.workshopstab').click(function(){
        if($(this).hasClass('disabled')){
            $(this).removeClass('disabled').addClass('active');
        }
        if($(this).hasClass('hiphop')){
            ajaxLoader('data/1.xml','wshp',0);
        }
        else if($(this).hasClass('bachata')){
            ajaxLoader('data/2.xml','wshp',0);
        }
        else if($(this).hasClass('jazz')){
            ajaxLoader('data/3.xml','wshp',0);            
        }
        else if($(this).hasClass('canvas')){
            ajaxLoader('data/4.xml','wshp',0);
        }
		else if($(this).hasClass('fashion')){
            ajaxLoader('data/5.xml','wshp',0);
        }
		else if($(this).hasClass('light')){
            ajaxLoader('data/9.xml','wshp',0);
        }
		else if($(this).hasClass('cook')){
            ajaxLoader('data/17.xml','wshp',0);
        }
		else if($(this).hasClass('calli')){
            ajaxLoader('data/16.xml','wshp',0);
        }
		else if($(this).hasClass('mockt')){
            ajaxLoader('data/15.xml','wshp',0);
        }
        $('.tab2').children().not($(this)).removeClass('active').addClass('disabled');
    });


    /***

     *----------------------NITES TABS CODE------------------------*
     ***/	
	
	    $('.nitestab').click(function(){
		if($(this).hasClass('agam')){
            ajaxLoader('data/nitesagam.xml','nc',0);
        }
		else if($(this).hasClass('kailasa')){
            ajaxLoader('data/nitesk.xml','nc',0);
        }
		else if($(this).hasClass('sr')){
            ajaxLoader('data/nitessr.xml','nc',0);
		}
		else if($(this).hasClass('dj')){
            ajaxLoader('data/nitesdj.xml','nc',0);
		}
		else if($(this).hasClass('raeth')){
            ajaxLoader('data/nitesr.xml','nc',0);
		}
    });


    /***
 *-------------------AJAX Load function------------------------*
 ***/
	
	function ajaxLoader(url,wid,hasSubMenu)
	{
		if (document.getElementById) {
			var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
			}
			if (x)
				{
			$("'."+wid+"'").html("<img src='img/ajax-loader.gif'/>");
			x.onreadystatechange = function()
					{
				if (x.readyState == 4 && x.status == 200)
					{
						el = document.getElementById(wid);
						el.innerHTML = x.responseText;
                        
                            if (hasSubMenu == 1)
                            {
                            submenuLoader();
                            }
					}
					}
				x.open("GET", url, true);
				x.send(null);
				}
	}



    /***
     *----------------------Specials TABS CODE------------------------*
     ***/	
	
	    $('.specialstab').click(function(){
        if($(this).hasClass('sdisabled')){
            $(this).removeClass('sdisabled').addClass('sactive');
        }
		if($(this).hasClass('rugby')){
            ajaxLoader('data/6.xml','spcl',0);
        }
		else if($(this).hasClass('soccer')){
            ajaxLoader('data/7.xml','spcl',0);
        }
		else if($(this).hasClass('frisbee')){
            ajaxLoader('data/8.xml','spcl',0);
		}
		else if($(this).hasClass('paintball')){
            ajaxLoader('data/10.xml','spcl',0);
		}
		else if($(this).hasClass('ball')){
            ajaxLoader('data/11.xml','spcl',0);
		}
		else if($(this).hasClass('poke')){
            ajaxLoader('data/12.xml','spcl',0);
		}
		else if($(this).hasClass('exhibition')){
            ajaxLoader('data/13.xml','spcl',0);
		}
		else if($(this).hasClass('savem')){
            ajaxLoader('data/14.xml','spcl',1);
		}
		else if($(this).hasClass('gbr')){
            ajaxLoader('data/20.xml','spcl',1);
		}
       $('.tab3').children().not($(this)).removeClass('sactive').addClass('sdisabled');
    });

    /***

     *----------------------Informals TABS CODE------------------------*
     ***/	
	
	    $('.informalstab').click(function(){
        if($(this).hasClass('sdisabled')){
            $(this).removeClass('sdisabled').addClass('sactive');
        }
		if($(this).hasClass('rugby')){
            ajaxLoader('data/6.xml','infrml',0);
        }
		else if($(this).hasClass('mom')){
            ajaxLoader('data/18.xml','infrml',0);
        }
		else if($(this).hasClass('housie')){
            ajaxLoader('data/19.xml','infrml',0);
		}
       $('.tab3').children().not($(this)).removeClass('sactive').addClass('sdisabled');
    });

    function submenuLoader(){
    $("#savem1").toggle();
    $("#savem2").toggle();
    $("#savem3").toggle();
    $("#savem4").toggle();
    $("#savem5").toggle();
    $("#savem6").toggle();

    $("#savema1").click(function(){
    $("#savem1").toggle()});
    $("#savema2").click(function(){
    $("#savem2").toggle()});
    $("#savema3").click(function(){
    $("#savem3").toggle()});
    $("#savema4").click(function(){
    $("#savem4").toggle()});
    $("#savema5").click(function(){
    $("#savem5").toggle()});
    $("#savema6").click(function(){
    $("#savem6").toggle()});
    }



    /***
 *-------------------AJAX Load function------------------------*
 ***/
	
	function ajaxLoaderInf(url)
	{
		if (document.getElementById) {
			var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
			}
			if (x)
				{
			$(".infrml").html("<img src='img/ajax-loader.gif'/>");
			x.onreadystatechange = function()
					{
				if (x.readyState == 4 && x.status == 200)
					{
						el = document.getElementById(iid);
						el.innerHTML = x.responseText;
					}
					}
				x.open("GET", url, true);
				x.send(null);
				}
	}

    
    /***
     *----------------------MENU CODE------------------------*
     ***/
    $('.tab').css("display","none");
    $('.eventstab').click(function(){
        if($(this).hasClass('off')){
            $(this).removeClass('off').addClass('on');
        }
        if($(this).hasClass('register')){
            register();
        }
        if($(this).hasClass('contacts')){
            displaycontacts();
        }
        if($(this).hasClass('desc')){
            displaydesc();
            
        }
        if($(this).hasClass('rules')){
            displayrules();
        }
        if($(this).hasClass('schema')){
            displayschema();
        }
        $('.tab').children().not($(this)).removeClass('on').addClass('off');
    });
    function resettabs() {
        if($('.register').hasClass('on')) $('.register').removeClass('on').addClass('off');
        if($('.contacts').hasClass('on')) $('.contacts').removeClass('on').addClass('off');
        if($('.rules').hasClass('on')) $('.rules').removeClass('on').addClass('off');
        if($('.desc').hasClass('off')) $('.desc').removeClass('off').addClass('on');
		if($('.schema').hasClass('on')) $('.schema').removeClass('on').addClass('off');
    }
    $('#menubigfour').css("display","none");
    $('#menuliterary').css("display","none");
    $('#menukala').css("display","none");
    $('#menuquiz').css("display","none");
    $('#menudance').css("display","none");
    $('#menumusic').css("display","none");
    $('#menudrama').css("display","none");
    $('#menumisc').css("display","none");
    $('#bigfour').click(function(){
        $("#menuevents").css("display","none");
        $("#menubigfour").css("display","block");
    });
    $('#literary').click(function(){
        $("#menuevents").css("display","none");
        $("#menuliterary").css("display","block");
    });
    $('#kala').click(function(){
        $("#menuevents").css("display","none");
        $("#menukala").css("display","block");
    });
    $('#quiz').click(function(){
        $("#menuevents").css("display","none");
        $("#menuquiz").css("display","block");
    });
    $('#dance').click(function(){
        $("#menuevents").css("display","none");
        $("#menudance").css("display","block");
    });
    $('#music').click(function(){
        $("#menuevents").css("display","none");
        $("#menumusic").css("display","block");
    });
    $('#drama').click(function(){
        $("#menuevents").css("display","none");
        $("#menudrama").css("display","block");
    });
    $('#misc').click(function(){
        $("#menuevents").css("display","none");
        $("#menumisc").css("display","block");
    });
    function displaydesc() {	
        if (globalevent!="homeitem" && globalcheck!="menuitem events") {
            $(".textarea").html("<img src='img/ajax-loader.gif'/>");
        }
        else if (globalevent=="homeitem") {
            $(".textarea").html("<h1>The Events</h1><p>Kick up your heels. Conjure up a storm. Whet your inquisitiveness. Unleash the Bard within. All the world's a stage, it calls upon you to perform. Witness the coming together of the false Gods of the performing arts. Prove your mettle against the very finest. Or simply take pot-shots at your friends' making a laughingstock of themselves. An eclectic mix of dazzling events awaits you this Waves, brace yourselves.</p>");
        }
        if(globalcategory != "events") {
            $('.tab').css("display","block");
        }
        else
        {
            $('.tab').css("display","none");
        }
        
        $.getJSON('js/events.json', function(json) {
            
            $.each(json.events, function(key, val) {
                    
                if(val.name.search(globalevent) !=-1 && val.category.search(globalcategory)!=-1){
                    $(".textarea").html("<h1>"+val.title+"</h1><p>"+val.content+"</p>");
                }
            });
            
        });
    }
    function displayrules() {	
        if (globalevent!="homeitem" && globalcheck!="menuitem events") {
            $(".textarea").html("<img src='img/ajax-loader.gif'/>");
        }
        $.getJSON('js/events.json', function(json) {
            
            $.each(json.events, function(key, val) {
                    
                if(val.name.search(globalevent) !=-1 && val.category.search(globalcategory)!=-1){
                    $(".textarea").html("<h1>"+val.title+"</h1><p>"+val.rules+"</p>");
                }
            });
            
        });
    }
    function displayschema() {	
        if (globalevent!="homeitem" && globalcheck!="menuitem events") {
            $(".textarea").html("<img src='img/ajax-loader.gif'/>");
        }
        $.getJSON('js/events.json', function(json) {
            
            $.each(json.events, function(key, val) {
                    
                if(val.name.search(globalevent) !=-1 && val.category.search(globalcategory)!=-1){
                    $(".textarea").html("<h1>"+val.title+"</h1><p>"+val.schema+"</p>");
                }
            });
            
        });
    }
	function displaycontacts() {	
        if (globalevent!="homeitem" && globalcheck!="menuitem events") {
            $(".textarea").html("<img src='img/ajax-loader.gif'/>");
        }
        $.getJSON('js/events.json', function(json) {
            
            $.each(json.events, function(key, val) {
                    
                if(val.name.search(globalevent) !=-1 && val.category.search(globalcategory)!=-1){
                    $(".textarea").html("<h1>"+val.title+"</h1><p>"+val.contacts+"</p>");
                }
            });
            
        });
    }
    function register() {
        $(".textarea").html("<img src='img/ajax-loader.gif'/>");
        var urltext="event_registration.php?event="+globalevent;
        htmlobj=$.ajax({
            url:urltext,
            async:false
        });
        if(htmlobj.responseText=="already_registered")
        {
            $('.textarea').html("<p>You have already registered for this event.</p><p><a id='unregister' href='javascript:void(0)'>Unregister</a></p>");
        }
        else if(htmlobj.responseText=="registration_successful")
        {
            $('.textarea').html("<p>Thank you for registering for </p><h2>"+globalevent+". (<a id='unregister' href='javascript:void(0)'> Unregister </a>)</h2><h2>Your Events:</h1>"+getevents());
            $("#regevents").html("<p>Here are the events you have already registered for: </p>" + "<p>"+getevents()+"</p><p>To unregister browse to the event you had registered for and then click register and then unregister.");
        }
        else
        {
            $('.textarea').html("<p>Kindly login to register for events.</p>");
            
        }
    }
    $('#unregister').live('click', function(){
        $(".textarea").html("<img src='img/ajax-loader.gif'/>");
        var urltext="unregister.php?event="+globalevent;
        htmlobj=$.ajax( {
            url:urltext, 
            async:false
        } );
                
        if(htmlobj.responseText=="successfully_unregistered")
        {
            $('.textarea').html("<p>Successfully unregistered.</p>");
            $("#regevents").html("<p>Here are the events you have already registered for: </p>" + "<p>"+getevents()+"</p><p>To unregister browse to the event you had registered for and then click register and then unregister.");
        }
        else if(htmlobj.responseText=="not_logged_in")
        {
            $('.textarea').html("<p>Please login to continue.</p>");
        }
    });
    $('.menuitem').click(function(){
        globalevent = $(this).attr('id');
        globalcategory = $(this).parent().parent().parent().parent().attr('id');
        globalcheck = $(this).attr('class');
        globalcategory = globalcategory.substr(4);
        resettabs();
        displaydesc();
    });
    
    $('.events').click(function(){
        
        $(this).parent().parent().parent().parent().css("display","none");
        
        $("#menuevents").css("display","block");
    });
    $('#homeitem').click(function(){
        $.scrollTo( $('#home'), 800 );
    });
    $('.eventsmenu').mobilyblocks({
        trigger: 'hover',
        direction: 'counter',
        duration:600,
        zIndex:50,
        widthMultiplier:1.3
    });
    /*$(".eventsmenu").css("width","270px").css("height","270px");
	$(".eventsmenu").click(function(){
        $(this).css("background","url(img/smitem.png) no-repeat").css("width","130px").css("height","130px");
    }).dblclick(function(){
        $(this).css("background","url(img/mitem.png) no-repeat").css("width","270px").css("height","270px");
    });*/

    /*********************Workshop flicker****************************/
    setInterval(function() {
        $("#light").toggle();
    }, 1000);
    
    
    
    
    
    
    
    
    
    /***
     *-------------------REGISTRATION CODE----------------------------*
     ***/
    $("#regmenu").css("display","none");
    $("#forgotpassword").click(function(){
        $("#forgot-form").toggle();
        $("#login-form").toggle();

    });
    $("#loginback").click(function(){
        $("#forgot-form").toggle();
        $("#login-form").toggle();

    });

    $("#forgot-button").click(function(){
        var forgot_email = $("#forgot-email").val();
        var urltext="forgotpassword.php?email="+forgot_email;
		
        $("#forgot-form .notification").html("Recovering ...").fadeTo(0.93);
        htmlobj=$.ajax({
            url:urltext,
            async:false
        });
	

 
        $("#forgot-form .notification").html(htmlobj.responseText);

    });




    $("#logout").css("display","none");
    $("#User-Info").css("display","none");
    $("#accomodation").css("display","none");
    $("#accomodation-instructions").css("display","none");
    $("#register-button").click(function(){
        var email = $("#register-email").val();
        var password = $("#register-password").val();
        var confirm_password = $("#register-confirm-password").val();
        var mobile = $("#mobile").val().replace(/^0+/, '');
        var name = $("#name").val();
        var college = $("#college").val();
		var state = $("#state").val();
					
        var urltext="register.php?email="+email+"&password="+password+"&mobile="+mobile+"&college="+college+"&name="+name+"&state="+state+"&confirm_password="+confirm_password;
	
        $("#register-form .notification").html("We're verifying your details, give us a few seconds.");
        htmlobj=$.ajax({
            url:urltext,
            async:false,
            success:function(){}
        });
		
	    
        if(htmlobj.responseText=="mailsent"){
            /*			$("#register-form").css("display","none");
			$("#Email-Notifier").html("");
			$("#Email-Notifier").css("display","none");*/
            $("#register-form .notification").html("We've sent you an e-mail to confirm your registration. Check your inbox!" );
			
            // clear all the fields
            $("#register-form input:text, #register-form input:password").each(function() {
                $(this).val(null);
                $(this).focus();
            });
            //			$("#register-form form label").inFieldLabels();
        }
        else {
            //$("#register-form").html(htmlobj.responseText);
            $("#register-form .notification").text(htmlobj.responseText);
        }
        $("#register-form #name").focus();
    });

    $("#login-button").click(function(){
        var login_email = $("#login-email").val();
        var login_password = $("#login-password").val();
        var urltext="login.php?email="+login_email+"&password="+login_password;
		
        $("#login-form .notification").html("Logging In...");
        htmlobj=$.ajax({
            url:urltext,
            async:false
        });
	
        if(htmlobj.responseText=="logged_in"){
            logged_in = true;
            $("#login-form .notification").hide();
            logged_in_pop();
        }
        else {
            $("#login-form .notification").html(htmlobj.responseText);
        }
    });
        
    $("#logout").click(function(){
        var urltext="logout.php";
        logged_in = false;
        htmlobj=$.ajax({
            url:urltext,
            async:false
        });

        logged_out_pop();
    });

        
    function getuserdata(action){
        var urltext="userdata.php?action="+action;
        $("#User-Info").html("Loading user info...");
        htmlobj=$.ajax({
            url:urltext,
            async:false,
            success: function() {
                $("#User-Info").html("");
            }
        });
        return htmlobj.responseText;
    }
    if(getuserdata("login_status")=="false")
    {
        logged_out_pop();
        $("#blackregister").html("Register/Login");
    }
    else
    {
        logged_in_pop();
        $("#blackregister").html("Your Account");
    }
        
    function logged_in_message() {
        return ("<br/><h1>Welcome, "+getuserdata("name").split(" ")[0]+"</h1><p>This control panel will show you the events you are registered to and your accommodation registration options. </p>");
        
    }
    $('#accolink').click(function() {
        $("#regevents").css("display","none");
        $("#accomodation").css("display","block");
    })
    $('#evlink').click(function() {
        $("#regevents").css("display","block");
        $("#accomodation").css("display","none");
    })
    function logged_in_pop()
    {
        logged_in = true;
        $("#login-form").css("display","none");
        $("#register-form").css("display","none");
        $("#User-Info").html("<img src='img/ajax-loader.gif'/>");
        $("#User-Info").html(logged_in_message());
        $("#User-Info").css("display","block");
        $("#regevents").css("display","block");
        $("#regevents").html("<p>Here are the events you have already registered for: </p>" + "<p>"+getevents()+"</p><p>To unregister browse to the event you had registered for and then click register and then unregister.");
        $("#regmenu").css("display","block");
        
        $("#logout").css("display","block");
        $("#blackregister").html("Your Account");
        createUploader();
    }
        
    function logged_out_pop() {
        logged_in = false
        $("#login-form").css("display","block");
        $("#logout").css("display","none");
        $("#User-Info").css("display","none");
        $("#User-Info").html("");
        $("#regevents").css("display","none");
        $("#regmenu").css("display","none");
        $("#accomodation").css("display","none");
        $("#register-form").css("display","block");
        $("#blackregister").html("Register/Login");
    }
        
        
    function getevents() {
        var urltext="events_listing.php";
        htmlobj=$.ajax({
            url:urltext,
            async:false
        });
        return htmlobj.responseText;
    }
        
    var focussed_id; //ID of the focussed date field
        
    //Accomodation Form
    $("#arrival_date, #departure_date").focus(function() {
        var bottom = $(this).offset().top - 2 * $("#datepicker").height();
        var left = $(this).offset().left;
        focussed_id = "#" + $(this).attr('id');
        $("#datepicker").css({
            'top': top, 
            'left': left
        });
        $("#datepicker").fadeIn("fast");
    });
        
    $("#arrival_date, #departure_date").blur(function() {
        $("#datepicker").fadeOut("fast");
    });
        
    var arrival_date = "";
    var departure_date = "";
    var validated_accomodation = true;
        
    $("#datepicker a").click(function() {
        var date = $(this).html();
            
        if (focussed_id == "#arrival_date") {
            if (date == "17") {
                $("#accomodation-form .notification").html("Rejected selected date range.");
                return;
            }
            if (!(isNaN(departure_date))) {
                if (parseInt(departure_date) < parseInt(date)) {
                    $("#accomodation-form .notification").html("Rejected selected date range.");
                    return;
                }
            }
            //$(focussed_id).siblings("label").html("");
            $("#accomodation-form .notification").html("");
            $(focussed_id).val("November " + date + ", 2011");
            arrival_date = $("#arrival_date").val().split(" ")[1].split(",")[0];
        }
            
        else {
            if (date == "13") {
                $("#accomodation-form .notification").html("Rejected selected date range.");
                return;
            }
            if (!(isNaN(arrival_date))) {
                if (parseInt(arrival_date) > parseInt(date)) {
                    $("#accomodation-form .notification").html("Rejected selected date range.");
                    return;
                }
            }
            //$(focussed_id).siblings("label").html("");
            $("#accomodation-form .notification").html("");
            $(focussed_id).val("November " + date + ", 2011");
            departure_date = $("#departure_date").val().split(" ")[1].split(",")[0];
        }
    });
        
    function validateNumbers(val) {
        if (isNaN(val)) {
            validated_accomodation = false;
            $("#accomodation-form .notification").html("We require positive integral numbers.");
        }
    }
        
    function checkBlanks(){
        if ($("#departure_date").val() == "" || $("#arrival_date").val() == "" || $("#num_boys").val() == "" || $("#num_girls").val() == "") {
            $("#accomodation-form .notification").html("You've missed a few fields.");
            validated_accomodation = false;
        }
    }
        
    var uploaded = false;
    var register_clickable = true;
        
    $("#acco-button").click(function() {
        if (!register_clickable) return;
            
        validated_accomodation = true;
        checkBlanks();
        validateNumbers($("#num_boys").val());
        validateNumbers($("#num_girls").val());
        if (!uploaded) {
            $("#accomodation-form .notification").html("You've not uploaded your travel proof.");
            return;
        }
        if (validated_accomodation) {
            $("#accomodation-form .notification").html("Give us a few seconds...");
                
            departure_date = $("#departure_date").val().split(" ")[1].split(",")[0];
            arrival_date = $("#arrival_date").val().split(" ")[1].split(",")[0];

            //get vars
            var boys = $("#num_boys").val();
            var girls = $("#num_girls").val();

            //url for get request
            var urltext2="accomodation_registration.php?boys="+boys+"&girls="+girls+"&arrival="+arrival_date+"&depart="+departure_date+"&accom_place="+accp;
            htmlobj=$.ajax({
                url:urltext2,
                async:false,
                success:function(){}
            });

            //responses : possible four as follows
            if(htmlobj.responseText=="registration_successful"){
                $("#accomodation-form .notification").html("You've been added to the accommodation waitlist.");

            }
            else if(htmlobj.responseText=="not_registered")
            {
                $("#accomodation-form .notification").html("Travel proof is required.");
            }
            else if(htmlobj.responseText=="already_registered")
            {
                $("#accomodation-form .notification").html("You've already registered for accommodation.");
            }
            else $("#accomodation-form .notification").html("Network Error.");
        }
    });
        
    $("#instructions-button").click(function() {
        $("#accomodation").hide();
        $(".acco-instructions").not("#main").hide();
        $("#accomodation-instructions, #main").fadeIn("fast");
    });
        
    $("#instructions-close-button").click(function() {
        $("#accomodation").fadeIn("fast");
        $("#accomodation-instructions").hide();
    });
        
    $("#acco-top-tabs a").click(function() {
        var tabID = "#" + $(this).attr('id').split("-")[0];
        $(".acco-instructions").not(tabID).hide();
        $(tabID).fadeIn("fast");
    });



    
    function createUploader(){
        var uploader = new qq.FileUploader({
            element: document.getElementById("file-uploader"),
            allowedExtensions: ['jpg', 'jpeg'],
            sizeLimit: 1048576,
            onSubmit: function(id, fileName){
                $("#accomodation-form .notification").html("Uploading Travel Proof...");
                register_clickable = false;
            },
            onComplete: function(id, fileName, responseJSON){
                $("#accomodation-form .notification").html("Upload successful.");
                uploaded = true;
                register_clickable = true;
            },
            showMessage: function(message){
                $("#accomodation-form .notification").html(message);
            },
            action: 'upload.php'
        });
    }
	

    /*********************************MENU ITEM MOVEMENT COD*****************************************************/

    /* Animation code needs to be hardcoded with position. Relative values dont work because many a times, if the event end is not triggered, the animations keeps getting bigger and bigger
$("#birdfeather").animate({
			left: '3760px',
			}, 1200); // this value of "200" is the speed of how fast/slow this hover animates


	} , function() {
		.animate({
			left: '1px',
			}, 1400);



});
     */

    $("#eventspic").hover(function() {
        $(this).css({
            'z-index' : '10'
        }); //Add a higher z-index value so this image stays on top
        $(this).addClass("hover").stop() // Add class of "hover", then stop animation queue buildup
        .animate({
            top: '313px',
            left: '760px',
            width: '51px', // Set new width
            height: '141px' // Set new height
        }, 200); // this value of "200" is the speed of how fast/slow this hover animates

    } , function() {
        $(this).css({
            'z-index' : '0'
        }); // Set z-index back to 0
        $(this).removeClass("hover").stop()  // Remove the "hover" class , then stop animation queue buildup
        .animate({
            top: '318px',
            left: '762px',
            width: '47px', // Set width back to default
            height: '135px' // Set height back to default
        }, 400);


    });
    $("#contactpic").hover(function() {
        $(this).css({
            'z-index' : '10'
        }); 
        $(this).addClass("hover").stop()
        .animate({
            top: '344px',
            left: '822px',
            width: '64px',
            height: '69px'
        }, 200);

    } , function() {
        $(this).css({
            'z-index' : '0'
        });
        $(this).removeClass("hover").stop()
        .animate({
            top: '346px',
            left: '826px',
            width: '56px',
            height: '63px'
        }, 400);
    });

    $("#sponsorspic").hover(function() {
        $(this).css({
            'z-index' : '10'
        }); 
        $(this).addClass("hover").stop()
        .animate({
            top: '381px',
            left: '894px',
            width: '105px',
            height: '91px'
        }, 200);

    } , function() {
        $(this).css({
            'z-index' : '4'
        });
        $(this).removeClass("hover").stop()
        .animate({
            top: '386px',
            left: '899px',
            width: '95px',
            height: '81px'
        }, 400);
    });

    $("#specialspic").hover(function() {
        $(this).css({
            'z-index' : '10'
        }); 
        $(this).addClass("hover").stop()
        .animate({
            top: '186px',
            left: '399px',
            width: '235px',
            height: '179px'
        }, 200);

    } , function() {
        $(this).css({
            'z-index' : '0'
        });
        $(this).removeClass("hover").stop()
        .animate({
            top: '191px',
            left: '404px',
            width: '225px',
            height: '169px'
        }, 400);
    });
    $("#workshopspic").hover(function() {
        $(this).css({
            'z-index' : '10'
        }); 
        $(this).addClass("hover").stop()
        .animate({
            top: '377px',
            left: '614px',
            width: '129px',
            height: '132px'
        }, 200);

    } , function() {
        $(this).css({
            'z-index' : '0'
        });
        $(this).removeClass("hover").stop()
        .animate({
            top: '382px',
            left: '619px',
            width: '119px',
            height: '122px'
        }, 400);
    });
    $("#nitespic").hover(function() {
        $(this).css({
            'z-index' : '10'
        }); 
        $(this).addClass("hover").stop()
        .animate({
            top: '372px',
            left: '213px',
            width: '186px',
            height: '137px'
        }, 200);

    } , function() {
        $(this).css({
            'z-index' : '0'
        });
        $(this).removeClass("hover").stop()
        .animate({
            top: '376px',
            left: '217px',
            width: '178px',
            height: '129px'
        }, 400);
    });
    $("#registerpic").hover(function() {
        $(this).css({
            'z-index' : '10'
        }); 
        $(this).addClass("hover").stop()
        .animate({
            top: '413px',
            left: '1006px',
            width: '63px',
            height: '91px'
        }, 200);

    } , function() {
        $(this).css({
            'z-index' : '0'
        });
        $(this).removeClass("hover").stop()
        .animate({
            top: '418px',
            left: '1009px',
            width: '57px',
            height: '85px'
        }, 400);
    });
    $("#informalspic").hover(function() {
        $(this).css({
            'z-index' : '10'
        }); 
        $(this).addClass("hover").stop()
        .animate({
            top: '326px',
            left: '406px',
            width: '171px',
            height: '143px'
        }, 200);

    } , function() {
        $(this).css({
            'z-index' : '0'
        });
        $(this).removeClass("hover").stop()
        .animate({
            top: '332px',
            left: '421px',
            width: '163px',
            height: '133px'
        }, 400);
    });
    $("#lookbackpic").hover(function() {
        $(this).css({
            'z-index' : '10'
        }); 
        $(this).addClass("hover").stop()
        .animate({
            top: '354px',
            left: '573px',
            width: '77px',
            height: '53px'
        }, 200);

    } , function() {
        $(this).css({
            'z-index' : '0'
        });
        $(this).removeClass("hover").stop()
        .animate({
            top: '355px',
            left: '574px',
            width: '75px',
            height: '51px'
        }, 400);
    });





});

