$(document).ready(function() {

    $("img:regex(id, .*_btn)").hover(
		function() {
		    this.src = this.src.replace("_n", "_r");
		},
		function() {
		    this.src = this.src.replace("_r", "_n");
		}
	);

    var pathname = window.location.pathname;
    if (pathname.match("index")) {
        $("#index_btn").unbind();
        $("#index_btn").attr("src", "WorkArea/images/hota/home_r.gif");
        $(".footer").css({ 'margin-left': '0' });
        //alert(pathname);
    } else if (pathname.match("general")) {
        $("#general_btn").unbind();
        $("#general_btn").attr("src", "WorkArea/images/hota/aboutLiveOn_r.gif");
        //alert(pathname);
    } else if (pathname.match("organ")) {
        $("#organ_btn").unbind();
        $("#organ_btn").attr("src", "WorkArea/images/hota/organDonation_r.gif");
        $(".dropdown").css({ 'display': 'block' });
    } else if (pathname.match("stories")) {
        //alert(pathname);
        $("#stories_btn").unbind();
        $("#stories_btn").attr("src", "WorkArea/images/hota/hotaStories_r.gif");
        $(".footer").css({ 'margin-left': '0' });
        //alert(pathname);
    } else if (pathname.match("help")) {
        $("#helpus_btn").unbind();
        $("#helpus_btn").attr("src", "WorkArea/images/hota/helpUs_r.gif");
        //alert(pathname);
    } else if (pathname.match("resources")) {
        $("#resources_btn").unbind();
        $("#resources_btn").attr("src", "WorkArea/images/hota/resources_r.gif");
        $("#resources_img").unbind();
        $("#resources_img").attr("src", "WorkArea/images/hota/tvc_r.jpg");
        $(".resources_sub").css({ 'display': 'inline-block' });
    } else if (pathname.match("media.aspx")) {
        
            $("#resources_img4").unbind();
            $("#resources_img4").attr("src", "WorkArea/images/hota/other_r.jpg");
            $(".resources_sub").css({ 'display': 'inline-block' });
            $("#resources_btn").unbind();
            $("#resources_btn").attr("src", "WorkArea/images/hota/resources_r.gif");
            document.title = "Archived Resources";

    }

    //alert(pathname);

    var url = window.location.href;

    var currentID = getParameter(url, 'id');
    //alert(currentID);
    switch (currentID) {
        case "852":
            $("#organ_btn_img1").unbind();
            $("#organ_btn_img1").attr("src", "WorkArea/images/hota/hota_r.jpg");
            $(".organ_sub").css({ 'display': 'inline-block' });
            document.title = "Organ Donation - HOTA";
            break;

        case "854":
            $("#organ_btn_img2").unbind();
            $("#organ_btn_img2").attr("src", "WorkArea/images/hota/mtera_r.jpg");
            $(".organ_sub").css({ 'display': 'inline-block' });
            document.title = "Organ Donation - MTERA";
            break;

        case "850":
            $("#organ_btn_img3").unbind();
            $("#organ_btn_img3").attr("src", "WorkArea/images/hota/facts_r.jpg");
            $(".organ_sub").css({ 'display': 'inline-block' });
            document.title = "Organ Donation - Facts";
            break;

        case "848":
            $("#organ_btn_img4").unbind();
            $("#organ_btn_img4").attr("src", "WorkArea/images/hota/donation_r.jpg");
            $(".organ_sub").css({ 'display': 'inline-block' });
            document.title = "Organ Donation - Donation";
            break;

        case "856":
            $("#organ_btn_img5").unbind();
            $("#organ_btn_img5").attr("src", "WorkArea/images/hota/transplant_r.jpg");
            $(".organ_sub").css({ 'display': 'inline-block' });
            document.title = "Organ Donation - Transplant";
            break;

        case "882":
            $("#resources_img1").unbind();
            $("#resources_img1").attr("src", "WorkArea/images/hota/radio_r.jpg");
            $(".resources_sub").css({ 'display': 'inline-block' });
            $("#resources_btn").unbind();
            $("#resources_btn").attr("src", "WorkArea/images/hota/resources_r.gif");
            document.title = "Live On Radio Capsules";
            break;

        case "884":
            $("#resources_img2").unbind();
            $("#resources_img2").attr("src", "WorkArea/images/hota/print_r.jpg");
            $(".resources_sub").css({ 'display': 'inline-block' });
            $("#resources_btn").unbind();
            $("#resources_btn").attr("src", "WorkArea/images/hota/resources_r.gif");
            document.title = "Live On Print Advertisements";
            break;


        case "878":
            $("#resources_img3").unbind();
            $("#resources_img3").attr("src", "WorkArea/images/hota/info_r.jpg");
            $(".resources_sub").css({ 'display': 'inline-block' });
            $("#resources_btn").unbind();
            $("#resources_btn").attr("src", "WorkArea/images/hota/resources_r.gif");
            document.title = "HOTA Information Booklet";
            break;



        /*------ HOTA Stories section -------*/ 
        case "888":
            $("#story1").unbind();
            $("#story1").attr("src", "Workarea/images/hota/1_r.gif");
            break;

        case "904":
            $("#story2").unbind();
            $("#story2").attr("src", "Workarea/images/hota/2_r.gif");
            break;

        case "906":
            $("#story3").unbind();
            $("#story3").attr("src", "Workarea/images/hota/3_r.gif");
            break;

        case "908":
            $("#story4").unbind();
            $("#story4").attr("src", "Workarea/images/hota/4_r.gif");
            break;

        case "910":
            $("#story5").unbind();
            $("#story5").attr("src", "Workarea/images/hota/5_r.gif");
            break;

        case "912":
            $("#story6").unbind();
            $("#story6").attr("src", "Workarea/images/hota/6_r.gif");
            break;

        case "914":
            $("#story7").unbind();
            $("#story7").attr("src", "Workarea/images/hota/7_r.gif");
            break;

        case "916":
            $("#story8").unbind();
            $("#story8").attr("src", "Workarea/images/hota/8_r.gif");
            break;

        case "918":
            $("#story9").unbind();
            $("#story9").attr("src", "Workarea/images/hota/9_r.gif");
            break;

        case "890":
            $("#story10").unbind();
            $("#story10").attr("src", "Workarea/images/hota/10_r.gif");
            break;

        case "892":
            $("#story11").unbind();
            $("#story11").attr("src", "Workarea/images/hota/11_r.gif");
            break;

        case "894":
            $("#story12").unbind();
            $("#story12").attr("src", "Workarea/images/hota/12_r.gif");
            break;

        case "896":
            $("#story13").unbind();
            $("#story13").attr("src", "Workarea/images/hota/13_r.gif");
            break;

        case "898":
            $("#story14").unbind();
            $("#story14").attr("src", "Workarea/images/hota/14_r.gif");
            break;

        case "900":
            $("#story15").unbind();
            $("#story15").attr("src", "Workarea/images/hota/15_r.gif");
            break;

        case "902":
            $("#story16").unbind();
            $("#story16").attr("src", "Workarea/images/hota/16_r.gif");
            break;

        //default: ; 
    }

});


function getParameter(queryString, parameterName) {
    // Add "=" to the parameter name (i.e. parameterName=value)
    var parameterName = parameterName + "=";
    if (queryString.length > 0) {
        // Find the beginning of the string
        begin = queryString.indexOf(parameterName);
        // If the parameter name is not found, skip it, otherwise return the value
        if (begin != -1) {
            // Add the length (integer) to the beginning
            begin += parameterName.length;
            // Multiple parameters are separated by the "&" sign
            end = queryString.indexOf("&", begin);
            if (end == -1) {
                end = queryString.length
            }
            // Return the string
            return unescape(queryString.substring(begin, end));
        }
        // Return "null" if no parameter has been found
        return "null";
    }
}	

/*
	function testtest(tempstr) {
		alert(tempstr);
	}
*/
