// always-include-ie.js  Copyright 1998-2001 PaperThin, Inc. All rights reserved.

bName = navigator.appName;
bVer = parseInt(navigator.appVersion);

var bCanRollover=0
if ((bName == "Netscape" && bVer >= 3) ||
	 (bName == "Microsoft Internet Explorer" && bVer >= 4))
	bCanRollover=1;

function ImageSet(imgID,newTarget)
{
	if (bCanRollover)
		document[imgID].src=newTarget;
}
function clearStatus()
{
	window.status = "";
}
function setStatbar(statbar)
{
	var strStatbar=unescape(statbar);
	window.status=strStatbar;
}
function onLoadComplete()
{
	if( menus_included == 1 )
		document.onmouseover = document_mouseover;	// defined in menu_ie.js
}
function HandleLink(parentID,link) 
{
	// links are in one of the following formats:
	// 		cpe_60_0,CP___PAGEID=100
	// 		CPNEWWIN:WindowName^params@CP___
	// 			CPNEWWIN:child^top=110:left=130:ww=140:hh=150:tb=1:loc=1:dir=0:stat=1:mb=1:sb=1:rs=1@CP___PAGEID=3811,Adv-Search-2.cfm,1
	if( jsPageAuthorMode == 0 )
	{
		windowname = "";
		windowparams = "";

		// "CPNEWWIN:" & NewWindowName & "^" & params & "@" & linkStruct.LinkURL; 
		pos = link.indexOf("CPNEWWIN:");
		if (pos != -1)
		{
			pos1 = link.indexOf ("^");
			windowname = link.substring (pos+9, pos1);
			pos2 = link.indexOf ("@");
			windowparams = link.substring (pos1 + 1, pos2);
			link = link.substring (pos2 + 1, link.length);
		}

		if (link.indexOf ("CP___") != -1)
		{
			if (windowname == "")
				window.location = jsDlgLoader + "?url=/commonspot/utilities/handle-link.cfm&thelink=" + link;
			else
			{
				urltoopen = jsDlgLoader + "?url=/commonspot/utilities/handle-link.cfm&thelink=" + link;
				windowparams = FormatWindowParams(windowparams);
				window.open (urltoopen, windowname, windowparams);
			}
		}
		else
		{
			if (windowname == "")
				window.location = link;
			else
			{
				windowparams = FormatWindowParams(windowparams);
				window.open (link, windowname, windowparams);
			}
		}
	}
	else if( jsSessionPreviewON == 1 )
	{
		previewLink(link);
	}
	else
	{
		document.all[parentID].click();
	}
}
function doWindowOpen(href,name,params)
{
	window.open (href, name, params);
}

// 	CPNEWWIN:child^top=110:left=130:ww=140:hh=150:tb=1:loc=1:dir=0:stat=1:mb=1:sb=1:rs=1@CP___PAGEID=3811,Adv-Search-2.cfm,1
function FormatWindowParams(windowparams)
{
	if( windowparams.indexOf(":loc=") != -1 || windowparams.indexOf(":ww=") != -1 || windowparams.indexOf(":hh=") != -1 || 
	    windowparams.indexOf(":left=") != -1 || windowparams.indexOf(":top=") != -1 )
	{
		windowparams = substringReplace(windowparams,':left=',',left=');
		windowparams = substringReplace(windowparams,'left=','left=');
		windowparams = substringReplace(windowparams,':ww=',',width=');
		windowparams = substringReplace(windowparams,'ww=','width=');		
		windowparams = substringReplace(windowparams,':hh=',',height=');
		windowparams = substringReplace(windowparams,'hh=','height=');
		windowparams = substringReplace(windowparams,':loc=',',location=');
		windowparams = substringReplace(windowparams,'loc=','location=');
		windowparams = substringReplace(windowparams,':dir=',',directories=');
		windowparams = substringReplace(windowparams,'dir=','directories=');
		windowparams = substringReplace(windowparams,':tb=',',toolbar=');
		windowparams = substringReplace(windowparams,'tb=','toolbar=');
		windowparams = substringReplace(windowparams,':stat=',',status=');
		windowparams = substringReplace(windowparams,':mb=',',menubar=');
		windowparams = substringReplace(windowparams,':sb=',',scrollbars=');
		windowparams = substringReplace(windowparams,':rs=',',resizeable=');
	}
	return windowparams;
}
function substringReplace(source,pattern,replacement)
{
	var pos = 0;
	var target="";
	while ((pos = source.indexOf(pattern)) != (-1))
	{
		target = target + source.substring(0,pos) + replacement;
		source = source.substring(pos+pattern.length);
		pos = source.indexOf(pattern);
	}
	return (target + source);
}
// handle scheduled element links
function show_sched_element(eid)
{
	evalCol = String(self.element_collection);
	dispFlag = false;
	if ( evalCol != 'undefined' )
	{		
		for(i=0;i<self.element_collection.length;i++)
		{
			sp = 'sched_elements_' + self.element_collection[i].id;
			obj = document.all.item(sp);
			//alert(sp);
			if ( self.element_collection[i].id == eid && obj != null)
			{
				dispFlag = true;
				if ( obj.length >= 0 )
				{
					for(z=0;z<obj.length;z++)
					{
						obj(z).style.display = 'block';
					}
				}
				else 
					document.all(sp).style.display = 'block';
			}
			else if ( obj != null )
			{
				if ( obj.length >= 0 )
				{	
					for(z=0;z<obj.length;z++)
					{
						obj(z).style.display = 'none';
					}
				}
				else
					document.all(sp).style.display = 'none';
			}
		}
	}
	
	if ( !dispFlag )
		alert("You do not have access to the requested element.")
}



