var imgWindow;
imgWindow=null;
var ns = (!document.all && document.getElementById);
var submitCount=0;
function checkAllRows(frm,objName,status)
{
	for(i=0;i<frm.elements.length;i++)
	if(frm.elements[i].name==objName &&  frm.elements[i].type=='checkbox')
	{
	   frm.elements[i].checked=status;
	}
}
function isCheckAllRows(frm,objName,objSel) 
{
   var checkedAll=true;
   for(i=0;i<frm.elements.length;i++)
	if(frm.elements[i].name==objName &&  frm.elements[i].type=='checkbox')
	{
	   if(frm.elements[i].checked==false && checkedAll==true)
	   {
	     checkedAll=false;
	   }
	}
	objSel.checked=checkedAll;
}
function isSelectedCheckbox(frm,objName) 
{
   for(i=0;i<frm.elements.length;i++)
	if(frm.elements[i].name==objName &&  frm.elements[i].type=='checkbox')
	{
	   if(frm.elements[i].checked==true)
	   {
	     return true;
	   }
	}
	return false;
}
function existsControl(frm,objName,type) 
{
   for(i=0;i<frm.elements.length;i++)
	if(frm.elements[i].name==objName &&  frm.elements[i].type==type)
	{
	     return true;
	}
	return false;
}
function delAlert(msg)
{
	 if(confirm(msg+ "\n\nAre you sure you want to delete?")==true)
 	{
	  return confirm('DO YOU WANT TO DELETE?')
 	}
	  return false; 
}
function EnlargedView(pageUrl, width, height)
{
	width+=60;
	height+=100;
	var w=(width>=screen.width?screen.width-60:(width<520?520:width));
	var h=(height>=screen.height?screen.height-60:height);
	var top=(height>=screen.height?0:20);
	if (screen.height<700)
	{
		h=screen.height-60;
		top=0;
	}
	window.open(pageUrl, 'view_enlarged', 'width='+w+',height='+h+',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,top='+top+',left=20');
}
//disable submit buttons after form submit
function disableSubmit(the_form)
{
	for (i=0; i < the_form.elements.length; i++)
	{
		if (the_form.elements[i].type == "submit")
		{
			the_form.elements[i].disabled = true;
		}
	}
}

//check for 1 time submit button
function checkSubmitCount(frm)
{
	submitCount++;
	if (submitCount==1)
	{
	   disableSubmit(frm);
	   return true;
	}
	return false;
}

function addToFavorites(url) 
{ 
   window.open(url, 'addtofavorites', 'width=490,height=320,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes,top=20,left=20');
}

function startSlideShow(pageUrl, width, height)
{
	width+=60;
	height+=100;
	var w=(width>=screen.width?screen.width-60:(width<520?520:width));
	var h=(height>=screen.height?screen.height-60:height);
	var top=(height>=screen.height?0:20);
	if (screen.height<700)
	{
		h=screen.height-60;
		top=0;
	}
	window.open(pageUrl,'slideshow','width='+w+',height='+h+',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,top='+top+',left=20');
}
function hideLayer(layerId){ 
	if (document.all) { document.all[layerId].style.visibility = "hidden"; } 
	if(document.layers){ document.layers[layerId].visibility = "hide";} 
	if(document.getElementById) {document.getElementById(layerId).style.visibility='hidden';} 
}
function showLayer(layerId) { 
	if (document.all) { document.all[layerId].style.visibility = "visible";} 
	if(document.layers) { document.layers[layerId].visibility = "show" ;} 
	if(document.getElementById) {document.getElementById(layerId).style.visibility='visible';} 
}
function openWin(theURL,winName,features) 
{
  	window.open(theURL,winName,features);
}

function OpenPreviewWindow(targetPage, formName){
	
	now = new Date  
	
	//Open the window first 	
   	openWin('','preview','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=680,height=400')
   		
   	//Now submit form to the new window
   	formName.action = targetPage + "?ID=" + now.getTime();
	formName.target = "preview";
	formName.submit();
}
//************************************Focus on form controls*******************************
function elementFocus()
	{
		slct = document.getElementsByTagName('select');
		tArea = document.getElementsByTagName('textarea');
		input = document.getElementsByTagName('input');

    for (i = 0; i < input.length; i++)
    {
        if(input[i].type == "text" || input[i].type == "password" || (input[i].type == "file" && !ns))
		{
			input[i].onfocus = new Function("if(this.focus){if(this.id=='pghdusername' && this.value=='Username'){this.value='';}else if(this.id=='pghdpassword' && this.value=='Password'){this.value='';}else if(this.id=='pghdtalentid' && this.value=='Talent ID'){this.value='';}this.className = 'focus';}");
			input[i].onblur = new Function("if(this.blur){if(this.id=='pghdusername' && this.value==''){this.value='Username';}else if(this.id=='pghdpassword' && this.value==''){this.value='Password';}else if(this.id=='pghdtalentid' && this.value==''){this.value='Talent ID';}this.className = '';}");
    	}		
	}
	
	for (i = 0; i < tArea.length; i++)
    {
        tArea[i].onfocus = new Function("if(this.focus){this.className = 'focus'}");
		tArea[i].onblur = new Function("if(this.blur){this.className = ''}");
    }
	
	// this actually highlights the OPTION rather than the whole SELECT in MSIE6.0
	
   for (i = 0; i < slct.length; i++)
    {
        slct[i].onfocus = new Function("if(this.focus){this.className = 'focus'}");
	slct[i].onblur = new Function("if(this.blur){this.className = ''}");
    }
}
//***************************************MUltiple Onloads*********************************
// Browser Detection
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

// Body onload utility (supports multiple onload functions)
var gSafeOnload = new Array();
function SafeAddOnload(f)
{
	if (IEmac && IE4)  // IE 4.5 blows out on testing window.onload
	{
		window.onload = SafeOnload;
		gSafeOnload[gSafeOnload.length] = f;
	}
	else if  (window.onload)
	{
		if (window.onload != SafeOnload)
		{
			gSafeOnload[0] = window.onload;
			window.onload = SafeOnload;
		}		
		gSafeOnload[gSafeOnload.length] = f;
	}
	else
		window.onload = f;
}
function SafeOnload()
{
	for (var i=0;i<gSafeOnload.length;i++)
	gSafeOnload[i]();
}
SafeAddOnload(elementFocus);
function coming_soon()
{
	alert("Coming soon...");
	return false;
}

