

function bookmark(url, title) {

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }


/*
	All Scripts Copyright 2006 theMediaLounge
*/
		var _osInt="";
		
		var _oT,_vD,_nH=100,_nTarg=0;//Scroll Globals
		var _nP=1;//Paging Globals
			
		function scroll(t,targ) {
		//	alert(_oInt);
			if(_osInt==""){
				_oT=document.getElementById(t);_nTarg=targ;
				_osInt=setInterval("shift()",5);
			}	
		}
		
		function shift() {
	//	alert("shift");
			if(parseInt(_oT.style.top)>_nTarg) {
				_oT.style.top=(parseInt(_oT.style.top)-5)+"px";
				if(parseInt(_oT.style.top)==(_nTarg)){clearInterval(_osInt);_osInt="";}
			//	alert(1)
			} else {
				_oT.style.top=(parseInt(_oT.style.top)+5)+"px";
				if(parseInt(_oT.style.top)==(_nTarg)){clearInterval(_osInt);_osInt="";}
				//alert(2)
			}
		}
		
		//create pagin buttons
		function pagecount(oT,nUI,nTotal,nLen,nHeight) {
			nT=(Math.ceil(nTotal/nLen));vHTML="";
			vHTML=vHTML + "<table cellpadding='0' cellspacing='0' align='right' ><tr>";
				for(i=1;i<(nT+1);i++) {
					if(i==_nP){ vClass="page_on"; } else { vClass="page_off"; }
						vHTML=vHTML + "<td class='" + vClass + "' id='oPage" + nUI + "_" + i + "' onclick=\"setpage("+i+",'oPage" + nUI + "_',"+nT+");scroll('"+oT+"',-"+(nHeight*(i-1))+")\">" + i + "</td>";
				}
			vHTML=vHTML + "</tr></table>";
			document.write(vHTML);
		}
		
		function setpage(p,nUI,t) {

			if(_osInt==""){
				for(i=1;i<(t+1);i++) {
					if(i==p) {
						document.getElementById(nUI+i).className="page_on";
					} else {
						document.getElementById(nUI+i).className="page_off";
					}
				}
			}
		}


function printpage(a, t) {
	if (a ==0) {
	window.print()
	} else {
	var printpage = window.open("/includes/printpage.asp?id="+a+"&t="+t, "print", 'height=600,width=600,scrollbars=yes,status=yes,resizable=yes');
	}
}

/* NAVIGATION */

	function navLoadSingle(section,lnk,nav) {
			try {
			
				// check if nav is a list
				section = section+1;
				
		
				// copy contents
				if (section > 1) {
					document.getElementById("section_"+section+"_nav").innerHTML = document.getElementById("n"+nav).innerHTML;
					// show section square
					document.getElementById("section_"+section).style.display = "block";
					document.getElementById("section_"+section+"_nav").style.display = "block";
					// use this to change the section colors later on
					section = section-1
				}
				
				// change the colors
				
				document.getElementById("nav_"+lnk).style.color = "black";
				document.getElementById("nav_"+lnk).style.fontWeight = "bold";
	
			} catch (e) {
				
			}

	}
	
	function navLoad(section,lnk,nav) {
	
	
	
		if (nav != '-1') {
			try {
			
				if (nav.split(',').length ==1) {
					
					navLoadSingle(section,lnk,nav);
				
				} else {
				
					// add 1 to section number to get starting section for nav to show
					startsection = section +1
					
					
					// get list of navs to show
					var arrNav = nav.split(',');
				
					for (i=0; i< arrNav.length; i++) {
					
						if (startsection > 1) {
						
		
							// copy contents
							document.getElementById("section_"+startsection+"_nav").innerHTML = document.getElementById("n"+arrNav[i]).innerHTML;
							
							// show section square
							document.getElementById("section_"+startsection).style.display = "block";
							document.getElementById("section_"+startsection+"_nav").style.display = "block";
						
							// add 1 to section to get next section container
							startsection = startsection+1
						}
						// change the colors
						
						document.getElementById("nav_"+lnk).style.color = "black";
						document.getElementById("nav_"+lnk).style.fontWeight = "bold";
	
					}
				}
	
			} 
			catch (e) {	
			//alert(e.message);
			}
		}
		
	}
	
	

	function nav(section,lnk,nav) {

		if (nav != '-1') {
			try {
			
				if (nav.split(',').length ==1) {
					
					navSingle(section,lnk,nav);
				
				} else {
				

				
					// add 1 to section number to get starting section for nav to show
					startsection = section+1
					
					// get list of navs to show
					var arrNav = nav.split(',');
					
					for (i=0; i< arrNav.length; i++) {
						
						if (startsection > 1) {
							
							// copy contents
							document.getElementById("section_"+startsection+"_nav").innerHTML = document.getElementById("n"+arrNav[i]).innerHTML;
							
							// show section square
							document.getElementById("section_"+startsection).style.display = "block";
							document.getElementById("section_"+startsection+"_nav").style.display = "block";
							
							// add 1 to section to get next section container
							startsection = startsection+1
						}
						
						hideSquares(startsection);
					}
				}
	
			} 
			catch (e) {
			}
			
			// change the colors
			color(section,lnk);
		}
		
	}

	function navSingle(section,lnk,nav) {

	
		if (nav != '-1') {
			try {
			
				section = section+1;
			
				// copy contents
				if (section > 1) {
					document.getElementById("section_"+section+"_nav").innerHTML = document.getElementById("n"+nav).innerHTML;
					// show section square
					document.getElementById("section_"+section).style.display = "block";
					document.getElementById("section_"+section+"_nav").style.display = "block";
					// use this to change the section colors later on
					section = section-1
				}
				
				hideSquares(section);
	
			} catch (e) {
			}
			
			// change the colors
			color(section,lnk);
		}
		
		
	}
	
	function hideSquares(section) {
		try {
			/* hide sections that are not being used*/
			a = section+2;
			for (var i=a;;i++) {
				if (i > 4) { 
					break;
				} else {
					document.getElementById("section_"+i+"_nav").style.display = "none";
					document.getElementById("section_"+i).style.display = "none";
				}				
			}
			
		} catch(e) {
		}
	
	}
	
	function color(section,lnk) {
	
	
	
		// this gets the parent element
		var parentElement = document.getElementById("section_" + section + "_nav");
	
		// loops through the children and isolates the A tag and changes the color and weight
		for (i=0;i<parentElement.firstChild.childNodes.length; i++) {
		
			// first firstChild = UL, second firstchild = LI then the A tags
			if (parentElement.firstChild.childNodes[i].firstChild.nodeName == "A") {
				parentElement.firstChild.childNodes[i].firstChild.style.color = "white";
				parentElement.firstChild.childNodes[i].firstChild.style.fontWeight = "normal";
			}
			
		}
	
		// we want this one to be black and bold
		document.getElementById("nav_" + lnk).style.color='black'; 
		document.getElementById("nav_" + lnk).style.fontWeight = "bold";
	}


/* LOAD AN IMAGE AND DONT SHOW X IF IT DOES NOT EXIST */
	
		// timer variables
		var secs
		var timerID = null
		var timerRunning = false
		var delay = 1000
		// image object
		var pic = new Image()

		function showImage(imagename) {

			window.status = "Loading image..";
			pic.src="/images/" + imagename; 
			// run the timer
			secs = 1
			StartTheTimer()
			
		}

		// TIMER functions, this function stops the timer
		function StopTheClock()
		{
			if(timerRunning)
				clearTimeout(timerID)
			timerRunning = false
		}

		// This will run the timer and then check if the pic's readystate is complete, if not then it will not show the image
		function StartTheTimer()
		{
			if (secs==0)
			{
				StopTheClock()
		      
				if (pic.readyState == "complete") {
					document.getElementById("content_right").style.backgroundImage = 'url(' + pic.src + ')';
					document.getElementById("loader").innerHTML = ""
					window.status = "Done";
					c=2;
				}
			}
			else
			{
				secs = secs - 1;
				timerRunning = true;
				timerID = self.setTimeout("StartTheTimer()", delay);	
			}
		}

/* GET THE SCREEN SIZE AND MOVE THE SITE DIV TO CENTER WHENEVER THE SCREEN IS RESIZED*/

function getWindowSize() {

	var winW = 630, winH = 470;

	if (parseInt(navigator.appVersion)>3) {
 		if (navigator.appName=="Netscape") {
  			winW = window.innerWidth;
  			winH = window.innerHeight;
 		}
 		if (navigator.appName.indexOf("Microsoft")!=-1) {
  			winW = document.body.offsetWidth;
  			winH = document.body.offsetHeight;
			ie7 = document.documentElement.clientHeight;
 		}
	}
	

	if (winH == 0) {
	winH = ie7
	}
	if (winH == 0) {
	winH =520
	}

	/*
	width:696px;
	height:470px;
	*/
	
	var left = (winW-736)/2;
	var top = (winH-470)/2;

	var left = (winW-800)/2;
	var top = (winH-560)/2;

	if (top < 10) top = 10;
	if (left < 10) left = 10;
	
	
	//window.status = winW + " " + winH;
	document.getElementById("wrapper").style.left = parseInt(left)+"px";
	document.getElementById("wrapper").style.top = parseInt(top)+"px";
	
}
// This moves the site div when window resizes
window.onresize = getWindowSize;




/* START THE TIMER FOR ARGUMENT LENGTH */
TimeToChange = 3;
DelayValue = 1000;
i = 0;
function TimerScript(pagetogoto, TimeToChange)
  {
  window.status = i;
    if (i < TimeToChange) 
      {    
        setTimeout("TimerScript('" + pagetogoto + "','" + TimeToChange + "');",DelayValue);
        i++;
      }
    else
      {
        i = 0
		location.href=pagetogoto;
      };
  };



/* HIGHLIGHT THE LINK WHICH HAS A HREF THE SAME AS PAGE NAME */
function highlight() {

	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	
	var arrTags = document.getElementsByTagName("A");
	
	for (i=0; i< arrTags.length; i++) {
	
		aPath = arrTags[i].href;
		aPage = aPath.substring(aPath.lastIndexOf('/') + 1);
	
		if (aPage == sPage) {
			
			current = arrTags[i].id;
			if (current.indexOf("nav") == -1) {
				arrTags[i].style.fontWeight = "bold";
				arrTags[i].style.color = "white";
				break;
			}
		}
		
		
	}

}

/*

	| Author:			James Haley
	| Date:				30/11/2005
*/

	// Init Scroller
	// Initiate the scroller module and set global variables
	/////////////////////////////////////////////////////////
		
		var _oN,_oNIS,_oInt; //Global objects: Div: News, Div: Inner News; Object: Interval
		var _nSW; //Total Scrollwidth - width of the content within the inner Div
		var _nW; //Wisth of the div object
		var _nSTarg; // The position we want the scroller to be in before it repeats
		var _bS=false; //The master Scroll Boolean, this determines whether the scroller should scroll or not
		var _nS=20; //The speed at which the scroller scrolls (msecs)
		var _sP=_nW; // Start position of the news scroller (JW)
		
		function init_s(oN,oNIS) {
			
						
			_oN=document.getElementById(oN);
			_oNIS=document.getElementById(oNIS);
			_nSW=_oN.scrollWidth;_nSTarg=("-"+_nSW);
			_nW=parseInt(_oN.style.width);
			
			if (readCookie("tdg") > 0) {
				_oNIS.style.left=readCookie("tdg")+"px";
			}
			
			_oInt = setInterval("s()",_nS);
		}
		
		
	// Run Scroll
	// Scroll the contents of the DIV
	/////////////////////////////////////////////////////////
		
		function s() {
			if(!_bS){
				if(parseInt(_oNIS.style.left)>parseInt(_nSTarg)){
					newPos = (parseInt(_oNIS.style.left)-1);
					_oNIS.style.left=newPos+"px";
					//updatecookie("tdg",(parseInt(_oNIS.style.left)-1));
				} else {
					_oNIS.style.left=_nW+"px";
					//updatecookie("tdg",_nW);
				}
			}else{alert('stop_s()')}
		}
		
		
	// Stop/Start Scroll
	// Stops the Scroller by Clearing the interval object
	/////////////////////////////////////////////////////////	
		
		function stop_s() {
			clearInterval(_oInt);
			_oInt=null;
		}
		
		function start_s() {
			_oInt = setInterval("s()",_nS);
		}
		
		
		
// SHOW ARTICLE LAYERS WHEN TEXT HAS BREAKS
function articleshow(a) {

	var divs = document.getElementsByTagName("div");
	for (i=0;i<divs.length;i++) {

		if (divs[i].id.substring(0,3) == "art") {
			if (divs[i].id != "art"+a) {
			divs[i].style.display = "none";
			}
		}
	
	}

	var keep = document.getElementById("art"+a)
	keep.style.display = "block";

}

// store last position of the news //
function updatecookie(cookiename,value) {
	var theclip = readCookie(cookiename);
	if (theclip == "not exists") {
		window.status = "cookie does not exist";
	} else {
		var the_cookie = cookiename+"=" + value;
		document.cookie = the_cookie + "; path=/;"
	}
}


// read cookie//
function readCookie(cookiename) {

	var the_cookie = document.cookie;
	var broken_cookie = the_cookie.split(";");
	
	for (var i=0; i < broken_cookie.length; i++) {
	
		strStripped = stripSpaces(broken_cookie[i],3)
		strStripped = Left(strStripped, 3)
	

		if (strStripped == cookiename) {
		
		var the_set = broken_cookie[i];
		var the_set = the_set.split("=");
		the_first = stripSpaces(the_set[0]);
		
			if (the_first == cookiename) {
				var the_items = the_set[1];
				if (the_items) {
				the_set = the_items;
				} else {
				the_set = 0
				}
			} else {
				var the_set = 0;
			}
		i = broken_cookie.length;
		} else {
			var the_set = "not exists";
		}
	}
	return (the_set);
}

function stripSpaces(thestring){
  var mytext = new String("");
  mytext = thestring;
  while (mytext.charAt(0) == ' ') {
    mytext = mytext.substring(1,mytext.length);
  };
  while (mytext.charAt(mytext.length - 1) == ' ') {
    mytext = mytext.substring(0, (mytext.length - 1));
  };
  return mytext;
};

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
