/*

This file is having all the JS for the home page which includes left nav expand/collapse, change of body bg and show/hide of the page content.

*/


// Jquery ready function - making default function calls on DOM load

jQuery(function($) {

    // Function call to preload body background images
    $.preloadCssImages();


    // Function call for dragable right menus

    //$("#right_container ul").sortable({ opacity: 0.6, cursor: 'move'});	



    /********** Start - Script for left menu - expand/collapse **********/



    // Hiding expanded <ul>'s

    $("li.expanded_menu ul").hide();



    // Adding 'up' class by default

    $("li.expanded_menu a").addClass('up');



    // Binding click event on expanded menu <a> tags

    $("li.expanded_menu a").click(function() {



        if ($(this).hasClass('up')) {

            $(this).next('ul').slideDown('slow', function() { rajkafunctionleft(); });

            $(this).removeClass('up');

            $(this).addClass('down');



            $("img.arrow", $(this)).attr({ src: "images/arrow_up.png" });
			$("img.subarrow", $(this)).attr({ src: "images/yellow_arrow.png" });



        } else {

        $(this).next('ul').slideUp('slow', function() { rajkafunctionleft(); });

            $(this).removeClass('down');

            $(this).addClass('up');



            $("img.arrow", $(this)).attr({ src: "images/arrow_down.png" });
			$("img.subarrow", $(this)).attr({ src: "images/yellow_arrow_down.png" });			

        }



        return false;

    });



    // Defining click event action for 'Navigation' link/heading

    $("div.heading a").click(function() {

        if ($(this).hasClass('up')) {

            $('ul.links').slideDown('slow');

            $(this).removeClass('up');

            $(this).addClass('down');

            $("img.yellow_arrow", $(this)).attr({ src: "images/yellow_arrow.png" });



        } else {

            $('ul.links').slideUp('slow');

            $(this).removeClass('down');

            $(this).addClass('up');



            $("img.yellow_arrow", $(this)).attr({ src: "images/yellow_arrow_down.png" });

        }



    });
	
	
	



    /******** End - Script for left menu - expand/collapse *********/



    /********** Start - Script for right menu - expand/collapse **********/



    $('div.right_link a').click(function() {

        var curIdx = $('div.right_link a').index($(this));

        $('div.details_container').eq(curIdx).slideDown('slow', function() { pageHeight(); });

        $('div.right_link').eq(curIdx).hide();


    });



    $('div.link_heading a').click(function() {

        var curIdx = $('div.link_heading a').index($(this));

        $('div.details_container').eq(curIdx).slideUp('slow', function() {

            $('div.right_link').eq(curIdx).show();
            pageHeight();
        }
																	  );



    });



    // Trigger default to open right content sesction

    //$('div.right_link a').eq(1).trigger('click');



    /********** End - Script for right menu - expand/collapse **********/

});


function waitawhile() {
    for (i = 0; i <= 1000; i++) {
        v = i;
    }
}

function rajkafunctionleft() {

    var rajoffset = document.getElementById('divFooterRaj');
    var r, bc, h, o, b, ao, bo;
    bc = document.getElementById('body_container').offsetHeight;
    h = document.getElementById('header').offsetHeight;
    r = document.getElementById('divFooterRaj').offsetHeight;
    b = document.body.clientHeight;
    bo = b - r;

    o = Math.ceil((bc + h+ 125) - r);
	
	if(o>bo)
		o = Math.ceil((bc + h + 125) - r);
	
    ao = Math.max(o, bo);
    rajoffset.style.top = ao + "px";
}

function rajkafunction() {

    var rajoffset = document.getElementById('divFooterRaj');
    var r, bc, h, o, b, ao, bo;
    bc = document.getElementById('body_container').offsetHeight;
    h = document.getElementById('header').offsetHeight;
    r = document.getElementById('divFooterRaj').offsetHeight;
    b = document.body.clientHeight;
    bo = b - r;

   	o = Math.ceil((bc + h + 125)  - r);
    
	if(o>bo)
		o = Math.ceil((bc + h + 125) - r);
		
	ao = Math.max(o, bo);
    rajoffset.style.top = ao + "px";

}

function rajkafunction2() {

    var rajoffset = document.getElementById('divFooterRaj');
    var r, bc, h, o, b, ao, bo;
    bc = document.getElementById('body_container').offsetHeight;
    h = document.getElementById('header').offsetHeight;
    r = document.getElementById('divFooterRaj').offsetHeight;
    b = document.body.clientHeight;
    bo = b - r;

    o = Math.ceil((bc + h - 27) - r);
    ao = Math.max(o, bo);
    rajoffset.style.top = bo + "px";
}

function pageHeight() {
    try {
        rajkafunction();
    }
    catch (err) { }
    return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null;
}


