﻿/* ------------------------------------------------------------------------------ */

/* Find first textbox on page and set the focus */

function SetFocus()

{

	var obj_elements      = null;

	var str_originalValue = "";



	try

	{

		if(document.getElementsByTagName)

		{

			obj_elements = document.getElementsByTagName("input");

			

			if(obj_elements)

			{

				for(var int_i = 0; int_i < obj_elements.length; int_i++)

				{			

					if(obj_elements[int_i].getAttribute('type') == "text" && obj_elements[int_i].id != "SiteSearchFormText")

					{

						str_originalValue = obj_elements[int_i].value;

						

						obj_elements[int_i].value = "";

						obj_elements[int_i].focus();

						obj_elements[int_i].value = str_originalValue;



						break;

					}

				}

			}

		}

	}

	catch(error)

	{

		// do nothing

	}

}



/* ------------------------------------------------------------------------------ */

function Redirect(str_url)

{

	try

	{

		if(pg)

			pg.show();

	

		document.location.href = str_url;

	}

	catch(error)

	{

		// do nothing

	}

}



/* ------------------------------------------------------------------------------

Sample: 

<a href="javascript:OpenWin('http://myCompany.com',600,600,1 ,1 ,1 ,1 ,1 ,1 ,10 ,10);">Link text here</a> 



str_url	- The URL of the page to open. 

int_w	- The width of the window in pixels. 

int_h	- The height of the window in pixels (doesn't include menubars). 

int_tb	- Toolbar visible?		1 = yes, 0 = no. 

int_stb	- Status bar visible?	1 = yes, 0 = no. 

int_l	- Linkbar visible?		1 = yes, 0 = no. 

int_mb	- Menubar visible?		1 = yes, 0 = no. 

int_sb	- Scrollbars visible?	1 = yes, 0 = no. 

int_rs	- Resizable window?		1 = yes, 0 = no. 

int_x	- The horizontal position of the window from the left of the screen. 

int_y	- The vertical position of the window from the top of the screen.

*/

function OpenWin(

	 str_url

	,int_w

	,int_h

	,int_tb

	,int_stb

	,int_l

	,int_mb

	,int_sb

	,int_rs

	,int_x

	,int_y)

{

	var str_tb, str_stb, str_l, str_mb, str_sb, str_rs, temp, win



	try

	{

		str_tb  = (int_tb)  ? 'yes' : 'no';

		str_stb = (int_stb) ? 'yes' : 'no'; 

		str_l   = (int_l)   ? 'yes' : 'no'; 

		str_mb  = (int_mb)  ? 'yes' : 'no'; 

		str_sb  = (int_sb)  ? 'yes' : 'no';

		str_rs  = (int_rs)  ? 'yes' : 'no';

		

		// Check for firefox

		temp = (document.layers) ? ',screenX=' + int_x + ',screenY=' + int_y : ',left=' + int_x + ',top=' + int_y;

		

		win = window.open(

			   str_url, 

			  'win'          + new Date().getTime(),

			  'width='       + int_w + 

			  ',height='     + int_h + 

			  ',toolbar='    + str_tb + 

			  ',status='     + str_stb +

			  ',links='		 + str_l + 

			  ',menubar='    + str_mb + 

			  ',scrollbars=' + str_sb + 

			  ',resizable='  + str_rs + temp);

		

		win.focus();

	}

	catch(error)

	{

		// do nothing

	}

}



function OpenWinModal(

	 str_url

	,int_w

	,int_h

	,int_tb

	,int_stb

	,int_l

	,int_mb

	,int_sb

	,int_rs

	,int_x

	,int_y)

{

	var returnValue = null;



	if(window.showModalDialog)

	{

		try

		{

			returnValue = window.showModalDialog(

				   str_url, 

				  '',

				  'dialogWidth:'   + int_w + 'px' + 

				  ';dialogHeight:' + int_h + 'px' +

				  ';center:'       + 'yes' + 

				  ';dialogHide:'   + 'no' +

				  ';edge:'		   + 'raised' + 

				  ';status:'       + 'yes' + 

				  ';scroll:'       + 'yes' + 

				  ';resizable:'    + 'yes');

				  

			return returnValue;

		}

		catch(error)

		{

			// do nothing

		}

	} 

	else 

	{

		OpenWin(

			 str_url

			,int_w

			,int_h

			,int_tb

			,int_stb

			,int_l

			,int_mb

			,int_sb

			,int_rs

			,int_x

			,int_y);

	}

} 



/* ---------------------------------------- */

/* Disable Enter key press */

var gbl_isKeyPressed = false;

var nav = window.Event ? true : false;

if(nav) 

{ 

	window.captureEvents(Event.KEYDOWN); 

	window.onkeydown = NetscapeEventHandler_KeyDown; 

} 

else 

	document.onkeydown = MicrosoftEventHandler_KeyDown;



function NetscapeEventHandler_KeyDown(e) 

{

	gbl_isKeyPressed = true;

	if (e.which == 13 && e.target.type != 'textarea' && e.target.type != 'submit') 

		return false;

	else

		return true;

} 



function MicrosoftEventHandler_KeyDown()

{

	gbl_isKeyPressed = true;

	if (event.keyCode == 13 && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit') 

		return false; 

	else

		return true;

}



function OpenDoc(str_path)

{

	OpenWin(str_path,600,600,0 ,1 ,1 ,0 ,1 ,1 ,10 ,10); 

}



function OpenLink(str_link)

{

	OpenWin(str_link,600,600,0 ,1 ,1 ,0 ,1 ,1 ,10 ,10); 

}



function Encode(str_origin)

{

     var str_encoded = escape(str_origin);

     str_encoded = str_encoded.replace(/\?/g,"%3F");

     str_encoded = str_encoded.replace(/=/g,"%3D");

     str_encoded = str_encoded.replace(/&/g,"%26");

     str_encoded = str_encoded.replace(/@/g,"%40");

     

     return str_encoded;

}



