var moveThis;
var centerDivX;
var centerDivY;
var docArray = new Array();

var cImage = 0;
var stryImgArr;
var stryid;
			
//var lv1 = "-222px";
var lv2 = "-152px";
var rv = "16px";
	
var cDiv = '';
var hDiv = '';

var i;
var w;
var d;

var chkBrws = 'IE';

var macOSFlag = 0;
var divArray = new Array('extraLinkDiv','partLinkDiv','termsLinkDiv');
var subMenuArray = new Array('newsSubNav','sportsSubNav','entertainSubNav','businessSubNav');

function testfrom(form) 
{
	Ctrl = form.Email;
   	if (Ctrl.value == "" || Ctrl.value.indexOf ('@', 0) == -1)
	{
   		return (false);
   	} 
	else
    {
		if (Ctrl.value == "" || Ctrl.value.indexOf (' ', 0) == -1)
			return (true);
    	else
			return (false);          
	}
} 
	
function chkSpaces(wObject)
{
	var tvalue = '';
	
	switch (wObject.type)
	{
		case 'text':
			tvalue = stripChars(wObject);
			
			if (tvalue.length == 0)
			{
				try
				{
					alert(wObject.message);
				}
				catch (e) {}
				
				wObject.focus();
				return(false);
			}
			else
				return(true);		
			break;
			
		case 'select':
			if (wObject.options[wObject.selectedIndex].value == '')
			{
				try
				{
					alert(wObject.message);
				}
				catch (e){}
				
				wObject.focus();
				return(false);
			}
			break;
	}
}

function stripChars(wObject)
{
	var tvalue = '';
	
	for (var x=0;x<wObject.value.length;x++)
	{
		if (wObject.value.charAt(x) != ' ')
			tvalue = tvalue + wObject.value.charAt(x);
	}
	
	return(tvalue);
}

function showGaller(g,gtitle,gtype)
{
		if (!gtype)
		{
			gtype = 0;
		}
		
		window.open('http://www.heraldsun.com/tools/gallery/slideshow.cfm?g='+g+'&title='+gtitle+'&gtype='+gtype,'myWindow','scrollbars=yes,status=no,width=680,height=725,left=1,top=1,resizable=1');
		try
		{	
			myWindow.focus();
		}
		catch (e) {}
}


function apvDwd(pid,title,pl,t) 
{
	if(!pl) {pl='';}
		var w = window.open("http://video.ap.org/vws/search/aspx/ap.aspx?f="+pid+"&g="+title+"&p="+pl+"&t="+t,"apvDwd","width=788,height=598,status=1,scrollbars=1,resizable=1");
}

function submitObitForm()
{
	if (document.ObitSearchForm.ObitName.value != '')
		document.ObitSearchForm.submit();
	else
		alert("Please enter a name.");
}

function Modwin(fileName) {
     myFloater = window.open('','myWindow','scrollbars=no,status=no,width=270,height=200')
     if (fileName != 'DeleteUserForm')
		 myFloater.location.href = "http://www.heraldsun.com/userlogin/"+fileName;
	else
		myFloater.location.href = "http://www.heraldsun.com/tools/"+fileName+".cfm";
}

function NewWindow(stadiumName,myname, w, h, scroll) 
{
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		var pageName = "displaySection.cfm?Which="+myname+"&StadiumName="+stadiumName;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
		winName = window.open('', 'winName', winprops)
		winName.location.href = pageName;
		
		if (parseInt(navigator.appVersion) >= 4) { winName.window.focus(); }
}
		
function MM_openBrWindow(theURL,winName,features) 
{ //v2.0
	var u2 = 'http://www.heraldsun.com'+theURL;
  	window.open(u2,winName,features);
}
	
function win(fileName) 
{
     myFloater = window.open('','myWindow','scrollbars=yes,status=no,width=400,height=250');
     myFloater.location.href = fileName;
	 myFloater.focus();
}

function chkMail(wObject)
{
	if (wObject.value.indexOf('@') == -1 || wObject.value.indexOf('.') == -1)
	{
		alert("Please enter a valid email address.");
		wObject.focus();
		return(false);
	}
	else
	{
		if (wObject.value.indexOf(";") != -1)
		{
			alert("Multiple e-mail addresses are not allowed.");
			return(false);
		}
		else
		{
		  if (wObject.value.indexOf("@aol.com") != -1)
		  {
		  	alert("AOL email addresses are not allowed in the to field.  Please manually send this article.");
		  	return(false);
		  }
		}
	}  
	
	
	return(true);
}

function doBrswChk()
{

	if (navigator.userAgent.indexOf('Firefox') != -1)
	{
		chkBrws = 'Firefox';
	}
	else
	{
		if (navigator.userAgent.indexOf('Opera') != -1)
		{
			chkBrws = 'Opera';
		}
	}
}


function hideVideoSection(vact)
{
	try
	{	
		getDocObj('videodiv').style.visibility = vact;
	}
	
	catch (e) {}
}

function expandDiv(wObj)
{
	
	divLoc = getDocObj(wObj);
		
	if (divLoc.style.visibility == 'visible' || divLoc.style.visibility == '')
	{
		divLoc.style.position = "absolute";
		divLoc.style.visibility = "hidden";
	}
	else
	{
		divLoc.style.position = "relative";
		divLoc.style.visibility = "visible";
	}
	
	
}
	
function resetDivs(y)
{
	try
	{
	if (cDiv == '')
		return(false);
	else
	{		
		var divLoc;
		
		for (var x=0;x<divArray.length;x++)
		{
			divLoc = getDocObj(divArray[x]);
		
			if (divLoc.style.left != y)
			{
				if (cDiv==divLoc)
					cDiv='';
				
				divLoc.style.left = y;
				
			}	
			divLoc.style.zIndex = 1;	
			
			hideVideoSection('visible');
		}
	}	
	}
	
	catch (e) {}
}

function resetSubNavs()
{
	for (var p=0;p <subMenuArray.length;p++)
	{
		try
		{
			divLoc = getDocObj(subMenuArray[p]);
			divLoc.style.visibility = 'hidden';
		}
		catch (e) {}
	}
	
	hideVideoSection('visible');
}


function disableTopAd()
{
	try
	{
			
		setTimeout('hideDiv("adDiv1")','20000');
		
	}
	catch (e){}
		

}

function swapClass(tb,cn)
{
	tb.className = cn;

}

function showSubMenu(x)
{

	resetSubNavs();
	hideVideoSection('hidden');
	
	if (x)
	{
		divLoc = getDocObj(x);
		divLoc.style.visibility = 'visible';
	}	
		
}

function navScrollFunc()
{
	
	if (i <eval(w-10))
	{
		i = i+10;
		
		d.style.zIndex = 2;		
		d.style.left = i+'px';
		setTimeout('navScrollFunc()','1');
	}
	else
	{
		
		cDiv = d;
		d.style.left = rv;
		return(true);
	}
}

function showNavDiv(x)
{
	var divLoc;
	
	try
	{
		//retract divs
		resetDivs(lv2);
		divLoc = getDocObj(x);
		
		if (cDiv != divLoc)
		{
			resetSubNavs();
			//Expand Divs
			divLoc.style.zIndex = 2;	
			cDiv = divLoc;
		
			//i=parseInt(divLoc.style.left);
			i=parseInt(lv2);
			w=parseInt(rv);
			d=divLoc;
			hideVideoSection('hidden');
			
			//navScrollFunc();
			d.style.left = rv;
			
		}
	}
	
	catch (e) {}
	
}
	
	
function chgBG(w,x)
{
	try
	{
		w.style.background = x;
	}
	
	catch (e){}
}

function hideDiv(w)
{
	try
	{
		getDocObj(w).style.visibility = 'hidden';
		getDocObj('logo').src='http://www.heraldsun.com/images/hscom/hslogoL.gif';
		getDocObj('srchDiv').style.visibility = 'visible';
	}
	
	catch (e){}
}

function pageJump(w,wObj)
{
	
	var objForm = eval('document.'+wObj);
	objForm.sRow.value = w;
	objForm.submit(); 
}

function grabObj(w)
{

}

function GetDropMenu(wMenu,wValue)
{	

	var tMenu = eval(wMenu);
	
	for (var x=0;x < tMenu.length;x++)
	{
		if (tMenu.options[x].value == wValue)
		{
			tMenu.selectedIndex = x;
			tMenu.options[x].text = tMenu.options[x].text;
		}	
	}
	
}

function GetCookieVal(cookiename){}
	
//Assigns doc object
function getDocObj(wDiv)
{
	try
	{
		if (document.all)
			return(document.all[wDiv]);
		else
			return(document.getElementById(wDiv));
	}
	
	catch (e) {}
}
		
//Preloads Images
function preImage()
{
	if (document.images)
	{
		try
		{
			var imgObj = new Array(document.images.length);
			for (var x=0;x<document.images.length;x++)
			{
				try
				{
					imgObj[x] = new Image();
					imgObj[x].src = document.images[x].src;
				}
				catch (e) {}
			}
		}
		
		catch (i) {}
	}
}

function detectDocState()
{
	try
	{
		if (document.readyState)
		{	 
			document.onreadystatechange=function(){if (this.readyState == 'complete') balAdStry();}
		}
		else
		{
			if (document.addEventListener) 
			{
				document.addEventListener("DOMContentLoaded", balAdStry(), false);
			}
		}
	}
	catch (e) {}

}

//Balances story div with ads
function balAdStry()
{
	try
	{
		if (getDocObj('adDiv2').clientHeight > getDocObj('storyDiv').clientHeight)
		{
			try	
			{
				getDocObj('storyDiv').style.height = getDocObj('adDiv2').clientHeight;
			}
			catch (f) {}
		}
		
		try 
		{
			getDocObj('navbardiv').style.height = getDocObj('storyDiv').clientHeight;
		}
		catch (g) {}
	}
	catch (e) {}
}

function setstryImgArr(imglist,imgStry)
{
	stryImgArr = imglist.split(',');
	stryid = imgStry;
}
			
function showImgArr(nNav)
{	
	var apImgPath = 'http://hosted.ap.org/photos/';
	
	switch (nNav)
	{
		case 'N':
			cImage +=1;
			break;
		default:
			cImage -=1;
			break;
	}
				
	if (cImage == stryImgArr.length)
		cImage = 0;
	else
	{
		if (cImage < 0)
			cImage = eval(stryImgArr.length-1);
	}
				
	document.images['APImageShow'].src=apImgPath + stryImgArr[cImage].charAt(0) + '/'+stryImgArr[cImage]+'-medium.jpg';
}
			
function OpnSlideShow(wShow)
{
	window.open(wShow,'slideshow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width='+screen.availWidth+',height='+screen.availHeight);
	
}


function loadAdPos(adlen)
{
	for (var x=1;x<=adlen;x++)
	{	
		try
		{
			getDocObj('BannerDiv'+x).innerHTML = getDocObj('LoadBanner'+x).innerHTML;
		}
		catch (e) {}
	}
}


function ResetBttDiv()
{	
	try
	{
		var mch;
		
		if (getDocObj('leftcoldiv').clientHeight > getDocObj('rightcoldiv').clientHeight)
			mch = parseInt(getDocObj('leftcoldiv').clientHeight);
		else
			mch = parseInt(getDocObj('rightcoldiv').clientHeight);
			
			getDocObj('bottomad').style.top = mch;
			getDocObj('bodycontent').style.height = eval(mch+50);
	}
			
	catch (e) {}
}

function RptAbse(wPst,wStry,wPg)
{
	var agree = confirm('This comment will be requested to be removed from the site.\n It will be reviewed, and if it does not comply will be removed.\n\nContinue?');
	if (agree)
		document.location.href='/newspost/index.cfm?reportoff='+wPst+'&post='+wStry+'&pg='+wPg;
	

}