// JavaScript Document

/***** Start Toggle Login for Comments *****/
function opacity(id, opacStart, opacEnd, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function hideDivs(id){ document.getElementById(id).style.display="none"; }
function showDivs(id){ document.getElementById(id).style.display="block"; }

function toggleLogin(state){
	if(state == 'show'){
		changeOpac(0, 'log_box');
		showDivs('log_box');
		opacity('log_box', 0, 98, 300);
	} else {
		opacity('log_box', 98, 0, 300);
		setTimeout("hideDivs('log_box')",300);
	}
}
/***** End Toggle Login for Comments *****/

/***** Start Toggle Login for Comments *****/
function opacity(id, opacStart, opacEnd, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function hideDivs2(id){ document.getElementById(id).style.display="none"; }
function showDivs2(id){ document.getElementById(id).style.display="block"; }

function toggleLogin2(state){
	if(state == 'show'){
		changeOpac(0, 'log_box2');
		showDivs2('log_box2');
		opacity('log_box2', 0, 98, 300);
	} else {
		opacity('log_box2', 98, 0, 300);
		setTimeout("hideDivs2('log_box2')",300);
	}
}
/***** End Toggle Login for Comments *****/

/***** Start Search Drop Down box *****/
function searchOption(state)
{
document.getElementById('searchdrop').style.display=state;
}

function runSearch() {
	var searchChoice = document.searchform.searchtype[document.searchform.searchtype.selectedIndex].value;
	var searchText = document.searchform.KEY1.value;
	if (searchText == "") {
		if (searchChoice == "archive") window.location.href = "http://www.daily-chronicle.com/shared-content/search/index.php?search=advanced";
		if (searchChoice == "gallery") window.location.href = "http://www.daily-chronicle.com/shared-content/gallery/search.html";
		if (searchChoice == "classifieds") window.location.href = "http://www.daily-chronicle.com/classifieds/index.inn";
		if (searchChoice == "jobs") window.location.href = "http://www.thejobnetwork.com/RMExtFrames.asp?AffiliateId=397&Content=Search.asp";
		if (searchChoice == "web") window.location.href = "http://search.yahoo.com/web/advanced?ei=UTF-8";
	}
	else {
		if (searchChoice == "archive") window.location.href = "http://www.daily-chronicle.com/shared-content/search/index.php?search=go&o=0&q=" + escape(searchText);
		if (searchChoice == "gallery") window.location.href = "/shared-content/gallery/?search=1&n=10&a=All&keywords=" + escape(searchText);
		if (searchChoice == "classifieds") window.location.href = "http://www.daily-chronicle.com/classifieds/index.inn";
		if (searchChoice == "jobs") window.location.href = "http://www.thejobnetwork.com/Search.asp?AffiliateId=397&Content=Search.asp&Dest=employee.myCareer.init&whichHome=4&NoBackground=1&FirstSearch=1";
		if (searchChoice == "web") window.location.href = "http://search.yahoo.com/search?ei=UTF-8&p=" + escape(searchText);
	}
}
/***** End Search Drop Down box *****/

/***** Start tabs *****/
function toggle(num,tabId,int){
	var i = 1;
	while(i <= int){
		if(num!=1){
			document.getElementById(tabId+'1').className='null';
		}
		if(num == i){
			document.getElementById(tabId+i).className='selected';
			document.getElementById("div_"+tabId+i).style.display="block";
		} else {
			document.getElementById(tabId+i).className='null';
			document.getElementById("div_"+tabId+i).style.display="none";
		}
		i++;
	}
}
/***** End tabs *****/

/***** Start News Dashboard tabs *****/
currentshown=1;
function showDiv_news(thediv){
	
	document.getElementById('div_news'+currentshown).style.display='none';
	document.getElementById('div_news'+thediv).style.display='block';
	
	document.getElementById('tab_news'+currentshown).className = 'null';
	document.getElementById('tab_news'+thediv).className = 'selected';
	
	currentshown=thediv;
}
/***** News Tab Control ******/
function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function initTabs(){
	alert(document.getElementById('tab_news1').onclick);
	document.getElementById('tab_news1').onclick = tabClick(1);
	alert(document.getElementById('tab_news1'));
	document.getElementById('tab_news2').onclick = tabClick(2);
	document.getElementById('tab_news3').onclick = tabClick(3);
	document.getElementById('tab_news4').onclick = tabClick(4);
}

function tabClick(tabNum){
	showDiv(tabNum);
	controlTab('stop');
	return false;
}
/***** End News Tab Control *****/

/***** Start Top Five tabs *****/
currentshown=1;
function showDiv(thediv){
	
	document.getElementById('div_topfive'+currentshown).style.display='none';
	document.getElementById('div_topfive'+thediv).style.display='block';
	
	document.getElementById('tab_topfive'+currentshown).className = 'null';
	document.getElementById('tab_topfive'+thediv).className = 'selected';
	
	currentshown=thediv;
}

/***** Top Five Tab Control ******/
function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function initTabs(){
	alert(document.getElementById('tab_topfive1').onclick);
	document.getElementById('tab_topfive1').onclick = tabClick(1);
	alert(document.getElementById('tab_topfive1'));
	document.getElementById('tab_topfive2').onclick = tabClick(2);
	document.getElementById('tab_topfive3').onclick = tabClick(3);
	document.getElementById('tab_topfive4').onclick = tabClick(4);
}

function tabClick(tabNum){
	showDiv(tabNum);
	controlTab('stop');
	return false;
}
/***** End Top Five Tab Control *****/

/***** Start .PNG transparancy fix
Use in <HEAD> with DEFER keyword wrapped in conditional comments:
<!--[if lt IE 7]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->
*****/
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}
/***** End .PNG transparancy fix *****/

/***** Start Hide Select Drop Down box in IE *****/
//hide selects on page - copy code below
function hideSelects(action) { 
//documentation for this script at http://www.shawnolson.net/a/1198/hide-select-menus-javascript.html
//possible values for action are 'hidden' and 'visible'
if (action!='visible'){action='hidden';}
if (navigator.appName.indexOf("MSIE")) {
for (var S = 0; S < document.forms.length; S++){
for (var R = 0; R < document.forms[S].length; R++) {
if (document.forms[S].elements[R].options) {
document.forms[S].elements[R].style.visibility = action;
}
}
} 
}
}
/***** End Hide Select Drop Down box in IE *****/
