/**
 *Author: Jerome S. Conde
 *UI Developer
 *Impact Proximity
 */


/**
*SideNavigation handler
*/
function SideNavigation(){
	var nav = ip$.getID("Navigation2");
	if(nav){
		var uls = nav.getElementsByTagName("UL");
		for(var i=0;i<uls.length;i++){
			var x = uls[i].parentNode;
			if(!(/\bactive\b/.test(x.className) || /\bSelected\b/.test(x.className))){
				x.onmouseover = function(){
					this.className += " SfNode";
				}
				x.onmouseout = function(){
					this.className = this.className.replace("SfNode","");
				}
			}
		}
	}
}

/**
*External Link Handler
*/
function ExternalLinkHandler(){
	var As = document.getElementsByTagName("A");
	for(var i=0,j=As.length;i<j;i++){
		if(/external/.test(As[i].rel)){
			As[i].onclick = function(){
					window.open(this.href,"Popup");
				return false;
			}
		}
	}
}


/**
*Toggle effect for contact list
*/
function directoryHandler(){
	var directory = ip$.getClass(document,"Directory");
	if(directory.length){
		var LIs = directory[0].getElementsByTagName("LI");
		for(var i=0;i<LIs.length;i++){
			var x = LIs[i].getElementsByTagName("A")[0];
			if(x){
				x.onclick = function(){
					toggle(this.parentNode.getElementsByTagName("DIV")[0]);
					return false;
				}
			}
		}
		/*hide all DIVs*/
		for(var i=0;i<LIs.length;i++){
			var y = LIs[i].getElementsByTagName("DIV")[0];
			if(y) y.style.display = "none";
		}
	}
	
}
/*Function to toggle visibility of an DOM object*/
function toggle(oTarget){
	if(oTarget){
		if(oTarget.style.display == "none") oTarget.style.display = "block";
		else oTarget.style.display = "none";
	}
}

/**
 *Execute handlers after the document is loaded
 */
function executeHandlers(){
	ip$.assignFirstAndLastChild();
	//ip$.sfNode("Navigation1");
	//SideNavigation();
	ExternalLinkHandler();
	directoryHandler();
	/** Fix for IE6 bg flicker **/
	var m = document.uniqueID /*IE*/ && document.compatMode /*>=IE6*/ && !window.XMLHttpRequest /*<=IE6*/ && document.execCommand;
	if(!!m){ m("BackgroundImageCache", false, true) /* = IE6 only */ }
}

function popup (URL, Width, Height, Scrollable, Resizable){
	Popup(URL, Width, Height, Scrollable, Resizable);
}
function Popup (URL, Width, Height, Scrollable, Resizable)
{
	try
	{
		var Popup;
		Popup = window.open(URL, "Popup", "width = " + Width + ", height = " + Height + ", top = " + ((screen.height - Height) / 2) + ", left = " + ((screen.width - Width) / 2) + ", resizable = " + (Resizable ? "yes" : "no") + ", scrollbars = " + (Scrollable ? "yes" : "no") + ", status = no");
		if(parseInt(navigator.appVersion)>=4)
		 {	
		  Popup.window.focus();
		 }
	}
	catch (ExceptionObject)
	{
		alert("Your browser or a piece of software installed on your\ncomputer appears to be blocking popups on this page.\n\nPlease enable popups and refresh this page to continue.");
	}
	return false;
}

/// <summary>
/// <summary>
///  Generate random numbers for flash animation
/// </summary>

function GetRandom(maxRange)
{
    var RanNumber= Math.floor(Math.random()*maxRange);
    return RanNumber + 1;
}

function btdc(){
	window.open("bdtc2010.html", "Popup", "width=810, height=650, resizable = 0, scrollbars =1, status = 0");	
}
function btdc1(URL){
	window.open(URL, "Popup", "width=810, height=650, resizable = 0, scrollbars =1, status = 0");	
}
