/* Global Variables */
JS_DISABLED = "JSDisabled";

/* General Functions */
function printSpecial(url) 
{
	var guideContent = document.getElementById("GuideContent");
	if (guideContent != null)
	{
		var html = '';
		html += '<html>\n<head>\n' +
			'<style type="text/css">' +
			'body, h2, h3, td {font: normal x-small Verdana, Arial, Helvetica, sans-serif;}' +
			'h1 {font: bold small Verdana, Arial, Helvetica, sans-serif;}' +
			'</style>' +
			'</head>\n<body>\n<img src="../images-support/logo_print.gif" alt="CSA Logo" />\n';
		html += guideContent.innerHTML;
		html += '\n</body>\n</html>';
		var printWindow = window.open("","printSpecial");
		printWindow.document.open();
		printWindow.document.charset=document.charset;
		printWindow.document.write(html);
		printWindow.document.close();
	}
	else
	{
		alert("Could not find the GuideContent section in the HTML");
		return;
	}
}

function GetElement(id)
{
    return document.getElementById(id);
}

function AddEvent(obj, eventName, functionName)
{
    if(window.attachEvent) 
    {
        obj.attachEvent("on" + eventName, functionName);
    }
    
    if(window.addEventListener) 
    {
        obj.addEventListener(eventName, functionName, false);
    }
}

/* Start Get Element Function */
function GetElements(e)
{
    var targ;
    
	if (!e)
	{   
	    var e = window.event;
	}
	
	if (e.target)
	{ 
	    targ = e.target;
	}
	else if (e.srcElement)
	{
	    targ = e.srcElement;
	}
	
	if (targ.nodeType == 3) // defeat Safari bug
	{
		targ = targ.parentNode;
    }
    
    var paragraphId = NEXT_SUMMARY;
    
    if (targ.id.indexOf("Next") == -1)
    {
        paragraphId = PREVIOUS_SUMMARY;
    }
    
    var paragraph = GetElement(paragraphId);
    var helpText = GetElement(HELP_TEXT);
    
    return new Elements(paragraph, helpText);
}

function Elements(p, h)
{
    this.paraText = p;
    this.helpText = h;
}
/* End Get Element Function */

/* Specific Move to appropriate place */
function CheckJavaScriptValidity()
{
	var jsDisabled = GetElement(JS_DISABLED);
	jsDisabled.style.display = 'none';
}

function bookMark()
{
    if (document.all)
    {
		window.external.AddFavorite(location.href,document.title);
	}
    else
    {
		return alert('Please press Ctrl+D to bookmark this page.');
    }
}

function IsDocumentScroll()
{
	var pageDimensions = GetPageDimensions();
	    
	return document.body.scrollHeight == pageDimensions.y ? true : false;
}
			
function GetPageDimensions()
{
	var x,y;
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight;
                
	if (test1 > test2) // all but Explorer Mac
	{
		x = document.body.scrollWidth;
        y = document.body.scrollHeight;
	}
	else // Explorer Mac;
	//would also work in Explorer 6 Strict, Mozilla and Safari
	{
		x = document.body.offsetWidth;
		y = document.body.offsetHeight;
	}
                
	return new Point(x, y);
}
			

function GetElementDimensions(id)
{
	var x,y;
	try
	{
		var element = document.getElementById(id);
	}
	catch (e)
	{
		return false;
	}
	
	

		//else
		//{
		//alert("1 - " + element.offsetWidth);	
		//alert("2 - " + element.offsetHeight);
			
	x = element.offsetWidth;
	y = element.offsetHeight;
			
		//alert("3 - " + element.scrollWidth);	
		//alert("4 - " + element.scrollHeight);
						
		//}
		
	if (document.compatMode && document.compatMode != "BackCompat")
	{
		x = element.scrollWidth;
		y = element.scrollHeight;	
		//alert("3 - " + element.scrollWidth);	
		//alert("4 - " + element.scrollHeight);
	}
	



	return new Point(x, y);
}

			
function GetWindowDimensions()
{
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
                
	return new Point(x, y);
}
			
function Point(x,y)
{
	this.x = x;
	this.y = y;
}
