﻿// Date Created/Edited: 2 March 2009 | Script Dependencies: jquery-1.3.2.min.js | Lester Dong
// Page Var Dependencies: gloOverLinks(bool), gloParams(string||string), gloArgs(string)
var gloArgs, gloParams, gloOverLinks;
gloOverLinks = false;
function dropDownClickEvent_QL() { // drop down click events
	$('#ddULTopLeft').click(function() { 
	    toggleDropDown_QL();
	    gloOverLinks = true;
	});
	 $('#ddULTopRight').click(function() { 
        toggleDropDown_QL();
        gloOverLinks = true;
    });
}
function linksMouseOverEvent_QL() { // Mouseover effects on the links so they behave like 'drop-downs'
    var links = $('a.ddULLink');
    links.mouseover(function() { 
        links.removeClass('ddULLinkSelected');
        gloOverLinks = true;
    });
}
function linksCloseDropDownEvents_QL() {
    $('#ddULTopRight').mouseout(function() { gloOverLinks = false; });
	$('#ddULTopLeft').mouseout(function() { gloOverLinks = false; });
	$('a.ddULLink').mouseout(function() { gloOverLinks = false; });
}
function linksClickEvent_QL() { // loading click events on links 
    $('a.ddULLink').click(function() {
		$('#ddULLabel').html(this.innerHTML);
		toggleDropDown_QL();
	});
}
function toggleDropDown_QL() { // drop down toggler. Turns it on or off and adds relevant logic to make it behave like a normal 'drop down'
	var ddUL = $('#ddUL');
	if (ddUL.css('display') == 'block') { // when the UL is expanded
		$('#countryListTopLeft').addClass('countryLinkSelected');
		ddUL.hide();
	}
	else { // when the UL is NOT expanded
		$('#ddULTopLeft').removeClass('ddULLinkSelected');
		$('a.ddULLink').filter(':contains(' + $('#ddULLabel').text() + ')').addClass('ddULLinkSelected');
		ddUL.show();
	}		
}
function documentEvent_QL() {
    $(document).click(function() { 
        if (!gloOverLinks) { 
        	$('#ddUL').hide();
        	$('#countryListTopLeft').removeClass('countryLinkSelected');
        }
    });
}
$(document).ready(function(){ // Attaching triggers, events and methods to jQuery's 'PageLoad'.
    documentEvent_QL(); // adds document events to be attached to the page.
    linksMouseOverEvent_QL(); // adding mouse over effect of drop down items.
    linksClickEvent_QL(); // adding click trigger for selected items.
    linksCloseDropDownEvents_QL(); // adding events that cause variables to flag to close the drop down.
	dropDownClickEvent_QL(); // adding click triggers for the label and the arrow.
});