/***********************************
   pkmedia.js - January, 2009 - v1.0
   ---------------------------------
   Commonly used Javascript funtions
 ***********************************/
var openDiv = 'none';

function revealDiv(divID){
	
	if(openDiv != 'none'){
		concealDiv(openDiv);
	}
	
	divToShow = document.getElementById(divID);
	divToShow.style.display = 'inline';
	
	openDiv = divID;
	
}

function concealDiv(divID){
	
	divToHide = document.getElementById(divID);
	divToHide.style.display = 'none';
}

function toggleDiv(divToHide,divToShow) {
	
		openDiv = divToHide;
		revealDiv(divToShow);
		openDiv = divToShow;
}

function swap_image(new_img) {
	var main_image = document.getElementById("main_image");
	main_image.src = new_img;
}

function dd_menu(state) {
	
	if(state == 'close' || state == '' || !state || state == null) {
		div = document.getElementById('menu_dd');
		div.style.display = 'none';
	} else if(state == 'open') {
		div = document.getElementById('menu_dd');
		div.style.display = 'inline';
		
	}
}

/******************************************************************************************
   DHTML/CSS Functions
******************************************************************************************/

/*  
   chgStyleTo() - changes the class of a page element
   --------------------------------------------------
   @param mouse_over => style for over state
   @param mouse_out => style for out state
   @param chg_to => style to switch to (will be equal to either mouse_over or mouse_out
*/
function chgStyleTo(chg_to,mouse_over,mouse_out,button) { 
	if(chg_to == mouse_over)
	{
		document.getElementById(button).className = mouse_over;
	}
	else if(chg_to == mouse_out)
	{
		document.getElementById(button).className = mouse_out;
	}
}


/*  
   chgObjectClass() - changes the class of a page element
   ------------------------------------------------------
   @param objectToChange => the id of the object / element to be changed 
   @param newClassName => the new style / class name
*/
function chgObjectClass(objectToChange,newClassName) { 

		document.getElementById(objectToChange).className = newClassName;

}

/******************************************************************************************
   Browser, Version, & Platform Detection
******************************************************************************************/

/*
   getBrowser() - detects various versions of Firefox, Safari, Ineternet Explorer & AOL
   ------------------------------------------------------------------------------------
   @param   no parameters
   @return  returns a string representing the client's browser's name and version
 */
function getBrowser(){
	
	var user_agent_hdr = navigator.userAgent;
	var browser = 'unknown';
	
	if(user_agent_hdr.match('Firefox/1.0')){
		browser = 'Firefox/1.0';
	} else if(user_agent_hdr.match('Firefox/1.5')) {
		browser = 'Firefox/1.5';
	} else if(user_agent_hdr.match('Firefox/1.6')) {
		browser = 'Firefox/1.6';		
	} else if(user_agent_hdr.match('Safari')) {
		if(user_agent_hdr.match('419') || user_agent_hdr.match('417') || user_agent_hdr.match('412')) {
			browser = 'Safari/2.0';
		} else if(user_agent_hdr.match('85') || user_agent_hdr.match('100') || user_agent_hdr.match('125') || user_agent_hdr.match('312')) {
			browser = 'Safari/1.0';
		}
	} else if(user_agent_hdr.match('MSIE 7.0')) {
		browser = 'MSIE 7.0';
	} else if(user_agent_hdr.match('MSIE 6.0')) {
		browser = 'MSIE 6.0';
	} else if(user_agent_hdr.match('MSIE 5.5')) {
		browser = 'MSIE 5.5';
	} else if(user_agent_hdr.match('MSIE 5.01')) {
		browser = 'MSIE 5.01';
	} else if(user_agent_hdr.match('MSIE 5')) {
		browser = 'MSIE 5.0';
	} else if(user_agent_hdr.match('MSIE 4.01')) {
		browser = 'MSIE 4.01';
	}
	
	if(browser == 'unknown') {
		browser = user_agent_hdr;
		return browser;
	} else {
		return browser;
	}
} 

/*
   getOS() - detects various versions of Firefox, Safari, and MSIE / AOL
   ---------------------------------------------------------------------------
   @param   no parameters
   @return  returns a string representing the client's platform and OS version
 */
function getOS(){
	
	var user_agent_hdr = navigator.userAgent;
	var os = 'unknown';
	
	if(user_agent_hdr.match('Windows NT 6.0')){
		os = 'Windows Vista';
	} else if(user_agent_hdr.match('Windows NT 5.1')) {
		os = 'Windows XP';
	} else if(user_agent_hdr.match('Windows NT 5.01') || user_agent_hdr.match('Windows NT 5.0')) {
		os = 'Windows 2000';		
	} else if(user_agent_hdr.match('Windows NT 4.0')) {
		os = 'Windows NT 4';
	} else if(user_agent_hdr.match('Windows 98')) {
		os = 'Windows 98';
	} else if(user_agent_hdr.match('Windows 95')) {
		os = 'Windows 95';
	} else if(user_agent_hdr.match('Macintosh')) {
		os = 'Mac OS X';
	} else if(user_agent_hdr.match('Mac_PowerPC')) {
		os = 'Mac OS X';
	} else if(user_agent_hdr.match('Mac OS X')) {
		os = 'Mac OS X';
	}
	
	return browser;
} 

/*
   resizeBrowserToScreen() - resizes the browser window to the max height and width of the screen
   ----------------------------------------------------------------------------------------------
 */
function resizeWindowToScreen() {
	screenWidth = document.documentElement.clientWidth;
	screenHeight = document.documentElement.clientHeight;
	resizeTo(screenWidth,screenHeight);
	moveTo(0,0);
}
