/* ================================================================ 
This copyright notice must be untouched at all times.

The original version of this scriptt and the associated (x)html
is available at http://www.stunicholls.com/menu/pro_dropline_5.html
Copyright (c) 2005-2008 Stu Nicholls. All rights reserved.
This script and the associated (x)html may be modified in any 
way to fit your requirements.
=================================================================== */


	var getEls = document.getElementById('menu').getElementsByTagName("LI");
	var getListElts = document.getElementById('submenus').getElementsByTagName("UL");
	var getListEltssub = document.getElementById('submenus').getElementsByTagName("LI");

	var getAgn = getEls;

	var Todel;

	var cntr = 0;
	
	for (var i=0; i<getEls.length; i++) {
	    getEls[i].onmouseover = function() {
	        clearTimeout(Todel);
	        cntr = 0;
	        for (var i = 0; i < getListElts.length; i++) {
	            getListElts[i].className = "none";
	        }

	        for (var z = 0; z < getAgn.length; z++) {


	            getAgn[z].className = '';

	        }




	        this.className = this.className == 'clicked' ? '' : 'clicked';

	        for (var z = 0; z < getAgn.length; z++) {
	            if (this.id != getAgn[z].id) {
	                getAgn[z].className = '';
	            }

	            if (getAgn[z].id == uniid) {
	                getAgn[z].className = 'clicked';
	            }
	        }


	        ulId = this.id.replace("li", "ul");
	        document.getElementById(ulId).className = document.getElementById(ulId).className == 'yes' ? 'none' : 'yes';

	        for (var i = 0; i < getListElts.length; i++) {
	            if (ulId != getListElts[i].id && getListElts[i].className == "yes") {
	                getListElts[i].className = "none";
	            }
	        }





	    }	    


		
		
}

function mouseovr() {
    
    for (var j = 0; j < getListEltssub.length; j++) {
        getListEltssub[j].onmouseover = function() {
        clearTimeout(Todel);
            cntr = cntr + 1;
            

        }
    }

    
   
}



for (var j = 0; j < getListEltssub.length; j++) {
    getListEltssub[j].onmouseout = function() {
    Todel = setTimeout("mouseut()", 2000)   

    }
}


for (var i = 0; i < getEls.length; i++) {
    getEls[i].onmouseout = function() {
        
        mouseovr();
        if (cntr == 0) {
          
            Todel = setTimeout("mouseut()", 2000)
        }

    }
}    

function mouseut() {


        //alert("hello");


        for (var i = 0; i < getListElts.length; i++) {
            getListElts[i].className = "none";
        }

        for (var z = 0; z < getAgn.length; z++) {


            getAgn[z].className = '';

        }



        for (var z = 0; z < getAgn.length; z++) {


            if (getAgn[z].id == uniid) {
                getAgn[z].className = 'clicked';
            }
        }

        uniid1 = uniid.replace("li", "ul");
        for (var i = 0; i < getListElts.length; i++) {
            if (uniid1 == getListElts[i].id) {
                getListElts[i].className = "yes";
            }
        }




    }
    

//}
   
     
    var uniid = "";
    var uniid1 = "";
    var uniids = "";
   



var urlParams = decodeURI( window.location.search.substring(1) ); //MySideNOTE: do not use unescape() for URI, use decodeURI()

//if no querystring, return null


var pairs = urlParams.split("&");


for(var value in pairs) {




var equalsignPosition = pairs[value].indexOf("=");
//alert(pairs[value]);

if (pairs[value]=="systemid=9")
{
    uniids = "9";
    
}
if (pairs[value] == "systemid=10") {
    uniids = "10";

}


}

if ((window.location.href == "http://www.tvguide.co.uk/")||(window.location.href == "www.tvguide.co.uk")) {

    
  var  ulid1 = "li_1";
    uniid = ulid1;

    $("#" + ulid1).attr("class", "clicked");
    ulid1 = ulid1.replace("li", "ul");
    $("#" + ulid1).attr("class", "yes ");


}

else {

    if (window.location.pathname == "/default.asp") {


        if (uniids == "") {



            var ulid1 = "li_1";
            uniid = ulid1;

            $("#" + ulid1).attr("class", "clicked");
            ulid1 = ulid1.replace("li", "ul");
            $("#" + ulid1).attr("class", "yes ");


        }
        if (uniids == "9") {



            var ulid1 = "li_3";
            uniid = ulid1;

            $("#" + ulid1).attr("class", "clicked");
            ulid1 = ulid1.replace("li", "ul");
            $("#" + ulid1).attr("class", "yes ");


        }
        if (uniids == "10") {



            var ulid1 = "li_4";
            uniid = ulid1;

            $("#" + ulid1).attr("class", "clicked");
            ulid1 = ulid1.replace("li", "ul");
            $("#" + ulid1).attr("class", "yes ");


        }

    }



    else {

        var index1 = $("#menu li").index($("li:has(a[href=" + window.location.pathname + "])"));
        //var index1 = $("#menu li").index($("li:has(a[href=" + window.location.href + "])"));

        if (index1 >= 0) {



            var ulid1 = $("#menu  li:eq(" + index1 + ")").attr('id');
            uniid = ulid1;
            $("#" + ulid1).attr("class", "clicked");
            ulid1 = ulid1.replace("li", "ul");
            $("#" + ulid1).attr("class", "yes ");

        }

        var index = $("#submenus ul li").index($("li:has(a[href=" + window.location.pathname + "])"));
        //var index = $("#submenus ul li").index($("li:has(a[href=" + window.location.href + "])"));

        if (index >= 0) {



            var ulid1 = $("#submenus ul li:eq(" + index + ")").parent().attr('id');



            //$("#submenus ul li:eq(" + index + ")").css({ "color": "#8cd9f8" });
            //$("#submenus ul li a:eq(" + index + ")").addClass("menuhighlight");
            $("#submenus ul li a:eq(" + index + ")").css({ "color": "#8cd9f8" });



            $("#" + ulid1).attr("class", "yes ");
            //$("#" + ulid1).attr("class", "sub");



            ulid1 = ulid1.replace("ul", "li");

            uniid = ulid1;
            $("#" + ulid1).attr("class", "clicked");


        }





        if ((index1 < 0 && index < 0)) {

            if (window.location.pathname == "/storydetail.asp") {

                ulid1 = "li_8";
                uniid = ulid1;

                $("#" + ulid1).attr("class", "clicked");
                ulid1 = ulid1.replace("li", "ul");
                $("#" + ulid1).attr("class", "yes ");
            }

            else {


                ulid1 = "li_1";
                uniid = ulid1;

                $("#" + ulid1).attr("class", "clicked");
                ulid1 = ulid1.replace("li", "ul");
                $("#" + ulid1).attr("class", "yes ");
            }

        }


    }

}	










//}	
	$.noConflict();
	jQuery.noConflict(true);
	
	
	
	
