<!--
/*-----------------------------------------------------------------------------
Filename: MiscLib.js
Author: Matthew Marcus

Description: Miscellaneous javascript functions for Songwriters Live

Copyright Songwriters Live, January 2004
All Rights Reserved
-----------------------------------------------------------------------------*/


//-----------------------------------------------------------------------------
// New_Browser_Window(sURL)
//
// Function to open new browser window and direct to new URL.
//
// sRL = URL to be opened.
// iWidth = Width of opened window.
// iHeight = Height of opened window
//
// Developed by Matthew Marcus
//-----------------------------------------------------------------------------
function New_Browser_Window(sURL, iWidth, iHeight)
{
	var w = 640;
	var h = 480;

	if (iWidth == "" || iWidth == null) {
		iWidth = 640;
	}
	
	if (iHeight == "" || iHeight == null) {
		iHeight = 480;
	}
	
	if (document.all) {
		/* Internet Explorer */
//		w = document.body.clientWidth;
//		h = document.body.clientHeight;
		w = screen.availWidth;
		h = screen.availHeight - 100;
	} else {
		/* Netscape */
		w = window.innerWidth;
		h = window.innerHeight;
	}
	
	var leftPos = (w-iWidth)/2;
	var topPos = (h-iHeight)/2;
	
	if (document.all) {
		// Account for bars shown
		iHeight = iHeight - 70;
	}

	window.open(sURL,"","dependant=no,height=" + iHeight + ",width=" + iWidth + ",menubar=yes,personalbar=yes,resizable=yes,screenX=" + leftPos + ",screenY=" + topPos + ",left=" + leftPos + ",top=" + topPos + ",scrollbars=yes,status=yes,toolbar=yes,location=yes");
}

// --------------------------------------------------------------------------------
// New_Slim_Browser_Window(sURL, iWidth, iHeight)
//
// Function to open new browser window (without toolbar, scrollbars, menubar, etc) and direct to new URL.
//
// sRL = URL to be opened.
// iWidth = Width of opened window.
// iHeight = Height of opened window
//
// Developed by Matthew Marcus
// --------------------------------------------------------------------------------
function New_Slim_Browser_Window(sURL, iWidth, iHeight){
	var w = 640;
	var h = 480;

	if (iWidth == "" || iWidth == null) {
		iWidth = 640;
	}
	
	if (iHeight == "" || iHeight == null) {
		iHeight = 480;
	}
	
	if (document.all) {
		/* Internet Explorer */
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
		
		if (w == 0 || h == 0) {
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	} else {
		/* Netscape */
		w = window.innerWidth;
		h = window.innerHeight;
	}

	var leftPos = (w-iWidth)/2;
	var topPos = (h-iHeight)/2;

	window.open(sURL,"","dependant=yes,height=" + iHeight + ",width=" + iWidth + ",menubar=no,personalbar=no,resizable=no,screenX=" + leftPos + ",screenY=" + topPos + ",left=" + leftPos + ",top=" + topPos + ",scrollbars=no,status=no,toolbar=no,location=no");
}

// ----------------------------------------------------------------------------
// New_Resizable_Browser_Window(sURL, iWidth, iHeight)
//
// Function to open new resizable browser window (without toolbar, scrollbars, 
// menubar, etc) and direct to new URL.
//
// sRL = URL to be opened.
// iWidth = Width of opened window.
// iHeight = Height of opened window
//
// Developed by Matthew Marcus
// ----------------------------------------------------------------------------
function New_Resizable_Browser_Window(sURL, iWidth, iHeight)
{
	var w = 640;
	var h = 480;

	if (iWidth == "" || iWidth == null) {
		iWidth = 640;
	}
	
	if (iHeight == "" || iHeight == null) {
		iHeight = 480;
	}
	
	if (document.all) {
		/* Internet Explorer */
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
		
		if (w == 0 || h == 0) {
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	} else {
		/* Netscape */
		w = window.innerWidth;
		h = window.innerHeight;
	}

	var leftPos = (w-iWidth)/2;
	var topPos = (h-iHeight)/2;

	window.open(sURL,"","dependant=yes,height=" + iHeight + ",width=" + iWidth + ",menubar=no,personalbar=no,resizable=yes,screenX=" + leftPos + ",screenY=" + topPos + ",left=" + leftPos + ",top=" + topPos + ",scrollbars=yes,status=no,toolbar=no,location=no");
}

// --------------------------------------------------------------------------------
// New_Toolbar_Browser_Window(sURL, iWidth, iHeight)
//
// Function to open new resizable browser window (with toolbar only)
// and direct to new URL.
//
// sRL = URL to be opened.
// iWidth = Width of opened window.
// iHeight = Height of opened window
//
// Developed by Matthew Marcus
// --------------------------------------------------------------------------------
function New_Toolbar_Browser_Window(sURL, iWidth, iHeight){
	var w = 640;
	var h = 480;

	if (iWidth == "" || iWidth == null) {
		iWidth = 640;
	}
	
	if (iHeight == "" || iHeight == null) {
		iHeight = 480;
	}
	
	if (document.all) {
		/* Internet Explorer */
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
		
		if (w == 0 || h == 0) {
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	} else {
		/* Netscape */
		w = window.innerWidth;
		h = window.innerHeight;
	}

	var leftPos = (w-iWidth)/2;
	var topPos = (h-iHeight)/2;

	window.open(sURL,"","dependant=yes,height=" + iHeight + ",width=" + iWidth + ",menubar=no,personalbar=no,resizable=yes,screenX=" + leftPos + ",screenY=" + topPos + ",left=" + leftPos + ",top=" + topPos + ",scrollbars=yes,status=no,toolbar=yes,location=no");
}

// --------------------------------------------------------------------------------
// New_Wait_Window(sURL, iWidth, iHeight, sWindowName)
//
// Function to open new browser window (without toolbar, scrollbars, menubar, etc) and direct to new URL.  Also returns Object pointer to Window.
//
// sRL = URL to be opened.
// iWidth = Width of opened window.
// iHeight = Height of opened window
// sWindowName = Name of opened window
//
// Developed by Matthew Marcus
// --------------------------------------------------------------------------------
function New_Wait_Window(sURL, iWidth, iHeight, sWindowName){
	var w = 640;
	var h = 480;

	if (iWidth == "" || iWidth == null) {
		iWidth = 640;
	}
	
	if (iHeight == "" || iHeight == null) {
		iHeight = 480;
	}
	
	if (document.all) {
		/* Internet Explorer */
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
		
		if (w == 0 || h == 0) {
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	} else {
		/* Netscape */
		w = window.innerWidth;
		h = window.innerHeight;
	}

	var leftPos = (w-iWidth)/2;
	var topPos = (h-iHeight)/2;

	if (sWindowName == "" || sWindowName == null) {
		sWindowName = "";
	}

	wWindow = window.open(sURL,sWindowName,"dependant=yes,height=" + iHeight + ",width=" + iWidth + ",menubar=no,personalbar=no,resizable=no,screenX=" + leftPos + ",screenY=" + topPos + ",left=" + leftPos + ",top=" + topPos + ",scrollbars=no,status=no,toolbar=no,location=no,copyhistory=no");
	
	return wWindow;
}

// --------------------------------------------------------------------------------
// Enlarge_Image(sImageURL, iWidth, iHeight)
//
// Function to open new browser window containing enlarged image.
//
// sImageURL = URL of image to be opened.
// iWidth = Width of opened window.
// iHeight = Height of opened window
//
// Developed by Matthew Marcus
// --------------------------------------------------------------------------------
function Enlarge_Image(sImageURL, iWidth, iHeight){
	var w = 640;
	var h = 480;

	if (iWidth == "" || iWidth == null) {
		iWidth = 640;
	}
	
	if (iHeight == "" || iHeight == null) {
		iHeight = 480;
	}
	
	if (document.all) {
		/* Internet Explorer */
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
		
		if (w == 0 || h == 0) {
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	} else {
		/* Netscape */
		w = window.innerWidth;
		h = window.innerHeight;
	}

	var leftPos = (w-iWidth)/2;
	var topPos = (h-iHeight)/2;

	window.open(sImageURL,"","dependant=yes,height=" + iHeight + ",width=" + iWidth + ",menubar=no,personalbar=no,resizable=no,screenX=" + leftPos + ",screenY=" + topPos + ",left=" + leftPos + ",top=" + topPos + ",scrollbars=no,status=no,toolbar=no,location=no");
}

// --------------------------------------------------------------------------------
// Image_On(sImage)
//
// Function to turn image "on" when rolled over.
//
// sImage = Image to turn on.
//
// Developed by Matthew Marcus
// --------------------------------------------------------------------------------
function Image_On(sImage) {
	if (document.images) {
		document[sImage].src = eval(sImage + "_on.src");
	}
}

// --------------------------------------------------------------------------------
// Image_Off(sImage)
//
// Function to turn image "off" when rolled off.
//
// sImage = Image to turn off.
//
// Developed by Matthew Marcus
// --------------------------------------------------------------------------------
function Image_Off(sImage) {
	if (document.images) {
		document[sImage].src = eval(sImage + "_off.src");
	}
}

// --------------------------------------------------------------------------------
// Strip_Whitespace(sString)
//
// Function to strip whitespace characters from string
//
// sString = string to strip whitespace characters.
//
// Developed by Matthew Marcus
// --------------------------------------------------------------------------------
function Strip_Whitespace(sString){
	var sStringNew = new String(sString);
	var sReturn = new String();
	var whitespace = " \t\n\r";
	var iCount;

	// Search through string's characters one by one.
	for (iCount=0; iCount<sStringNew.length; iCount++)	{   
		// Check that current character isn't whitespace.
		var cCharacter = sStringNew.charAt(iCount);
		if (whitespace.indexOf(cCharacter) == -1) {
			sReturn += cCharacter;
		}
	}
	
	return sReturn;
}

// --------------------------------------------------------------------------------
// FormatSQL(sString, sChoice)
//
// Purpose: To replace "'" or """ with "''" for building proper SQL statement.
//
// Developed by Matthew Marcus
// --------------------------------------------------------------------------------
function FormatSQL(sString, sChoice) {
	var sReturn = "";
	var sExpn;
	
	switch (sChoice){
		case "1":
			sExpn = /'/gi;
			break;
		case "2":
			sExpn = /"/gi;
			break;
	}
	
	if (sString != "")
		sReturn = sString.replace(sExpn, "''");
	
	return sReturn;
}


//-----------------------------------------------------------------------------
// Email_Username_Password
//-----------------------------------------------------------------------------
function Email_Username_Password() 
{
   if(confirm("Are you sure you want to email this employee their username and password?"))
   {
      self.location='/hr/php/email_username_password.php?employee_id=<? echo $employee_id ?>'
   }
}


// -->