var oas = 'http://ads.mgnetwork.com/RealMedia/ads/';
var RN = new String (Math.random());
var RNS = RN.substring (2,11);

function DisplayOasAd (position) {
	var oaspage = sitepage + '/1' + RNS + '@' + position;
	if (_version < 11) {
		document.write ('<a href="' + oas + 'click_nx.ads/' + oaspage + '" target="_top"><img src="' + oas + 'adstream_nx.ads/' + oaspage + '" border="0"></a>');
	}
	else {
		document.write ('<script language="JavaScript1.1" src="' + oas + 'adstream_jx.ads/' + oaspage + '"><\/script>');
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function addIEFavorite() {
	if (window.external) {
		external.AddFavorite(location.href, 'WKRG.com')
	}
	else {
		alert("Oops, your browser doesn't support this feature.\n" +
		"If you are using Netscape Navigator, click Bookmarks\n" +
		"and then Add Bookmark to add this site to your favorites.");
	}
}

function Vote() {
	isChecked = false;
	targetWin = "pollpage";
	for( i = 0; i < document.voteform.ITEM1.length; i++ ) {
		if (document.voteform.ITEM1[i].checked) {
			isChecked = true;
		}
	}
	if(isChecked) {
		window.open("", targetWin,"toolbar=no,scrollbars=yes,directories=no, status=no,menubar=no,resizable=no,width=400,height=400")
		document.voteform.target = targetWin;
		document.voteform.submit();
	}
	else {
		alert("Sorry, but you forgot to vote\nPlease try again");
	}
}

function createWindow(pageURL,wWidth,hHeight,sScroll) {
	window.open(pageURL, "secondWindow", "toolbar=no,scrollbars=" + sScroll + ",directories=no, status=no,menubar=no,resizable=no,width=" + wWidth + ",height=" + hHeight)
}

function openPic(picURL,wWidth,hHeight) {
            window.open(picURL,"popUp","resizable=no,scrollbars=yes,menubar=no,toolbar=no,width=" + wWidth + ",height=" + hHeight);

}

function bind(algebra,alchemy,year) {
	algebra += ' ';
	var pump = algebra.length;
	var quality = 0;
	var coal = '';
	for(var conception = 0; conception < pump; conception++) {
		quality = 0;
		while(algebra.charCodeAt(conception) != 32) {
			quality = quality * 10;
			quality = quality + algebra.charCodeAt(conception)-48;
			conception++;
		}
		coal += String.fromCharCode(hit(quality,alchemy,year));
	}
	parent.location = 'm'+'a'+'i'+'l'+'t'+'o'+':'+coal;
}
function draw(crust,difference,example) {
	crust += ' ';
	var energy = crust.length;
	var entropy = 0;
	for(var sword = 0; sword < energy; sword++) {
		entropy = 0;
		while(crust.charCodeAt(sword) != 32) {
			entropy = entropy * 10;
			entropy = entropy + crust.charCodeAt(sword)-48;
			sword++;
		}
		document.write('&');
		document.write('#');
		document.write(hit(entropy,difference,example));
	}
}
function hit(physicist,hero,labyrinth) {
	if (labyrinth % 2 == 0) {
		male = 1;
		for(var world = 1; world <= labyrinth/2; world++) {
			minute = (physicist*physicist) % hero;
			male = (minute*male) % hero;
		}
	} else {
		male = physicist;
		for(var moss = 1; moss <= labyrinth/2; moss++) {
			minute = (physicist*physicist) % hero;
			male = (minute*male) % hero;
		}
	}
	return male;
}

function popGameHouse(url, w, h) {
	var madURL = url;
	var x, y, winStr;
	x=0; y=0;
 	self.name="opener";
	winStr = "height="+h+",width="+w+",screenX="+x+",left="+x+",screenY="+y+",top="+y+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0";
	lilBaby = window.open(madURL, "_blank", winStr);
}

function launchPlaytoniumJigsaw(v) {
  // v = vendor id <--- optional, defaults to ""
  if (typeof v == "undefined") { v = ""; }
  w = 640;
  h = 480;
  theURL = "http://playtonium.com/jigsaw/vjs.php?v=" + v;
  winName = "vjigsaw";
  features = "toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes";
  winW = Math.min(w, window.screen.availWidth);
  winH = Math.min(h, window.screen.availHeight);
  sX = parseInt(window.screen.availLeft);
  sY = parseInt(window.screen.availTop);
  lt = ",left=" + sX + ",top=" + sY + ",screenX=" + sX + ",screenY=" + sY + ",";
  features = features + lt + "width=" + winW + ",height=" + winH;
  winRef = window.open(theURL,winName,features);
}

function launchPlaytoniumWordsense(v) {
  // v = vendor id <--- optional, defaults to ""
  if (typeof v == "undefined") { v = ""; }
  w = 600;
  h = 440;
  theURL = "http://playtonium.com/wordsense/vws.php?v=" + v;
  winName = "vws";
  features = "toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes";
  winW = Math.min(w, window.screen.availWidth);
  winH = Math.min(h, window.screen.availHeight);
  sX = parseInt(window.screen.availLeft);
  sY = parseInt(window.screen.availTop);
  lt = ",left=" + sX + ",top=" + sY + ",screenX=" + sX + ",screenY=" + sY + ",";
  features = features + lt + "width=" + winW + ",height=" + winH;
  winRef = window.open(theURL,winName,features);
}

 function MM_openBrWindow(theURL,winName,features) { //v1.2
 newWin = window.open(theURL,winName,features);
 newWin.focus()
}

function flaResize (val) {
	//alert(val);
	var target = document.getElementById('fla_table');
	target.setAttribute("height", val);
}

var today = new Date();
var hour = today.getHours();
var dayofweek = today.getDay();

function displayHeader() {
  if(dayofweek >= 1 && dayofweek < 6) {

 	if (hour >= 5 && hour < 7) {
		document.header.src = "http://media.mgbg.com/wkrg/images/v2/head-mornings.jpg"
	}
	else if (hour >= 12 && hour < 13) {
		document.header.src = "http://media.mgbg.com/wkrg/images/v2/head-noon.jpg"
	}
	else if (hour >= 17 && hour < 18) {
		document.header.src = "http://media.mgbg.com/wkrg/images/v2/head-five.jpg"
	}
    else if (hour >= 18 && hour < 19) {
		document.header.src = "http://media.mgbg.com/wkrg/images/v2/head-ten.jpg"
	}
	else if (hour >= 22 && hour < 23) {
		document.header.src = "http://media.mgbg.com/wkrg/images/v2/head-ten.jpg"
	}
	else {
		document.header.src = "http://media.mgbg.com/wkrg/images/v2/head.jpg"
	}

  }

  else {
		document.header.src = "http://media.mgbg.com/wkrg/images/v2/head-weekend.jpg"
  }
}



var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function quickPollv3_DoFSCommand(command, args) {
  var quickPollv3Obj = InternetExplorer ? quickPollv3 : document.quickPollv3;
	if (command == "flaResize") {
		flaResize(args);
	}
}
// Hook for Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
	  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub quickPollv3_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call quickPollv3_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}

var x = 900;
var y = 1;
var now;

function startClock()
{
	x = x-y;
 	document.form1.clock.value = x;
 	if (x <= 1) reload();
 		timerID = setTimeout("startClock()",1000);
}

function reload()
{
	now = new Date();
	var camImg = "http://media.mgbg.com/wnct/images/towercam.jpg" + "?" + now.getTime();
	document.campicture.src = camImg;
	x = 60;
	document.form1.clock.value = x;
}

function writeShortDate() {
	var todaysDate = new Date();
	var thisMonth = todaysDate.getMonth();
	if (thisMonth == 0) {month = "January"};
	if (thisMonth == 1) {month = "February"};
	if (thisMonth == 2) {month = "March"};
	if (thisMonth == 3) {month = "April"};
	if (thisMonth == 4) {month = "May"};
	if (thisMonth == 5) {month = "June"};
	if (thisMonth == 6) {month = "July"};
	if (thisMonth == 7) {month = "August"};
	if (thisMonth == 8) {month = "September"};
	if (thisMonth == 9) {month = "October"};
	if (thisMonth == 10) {month = "November"};
	if (thisMonth == 11) {month = "December"};
	document.write(month + ' ' + todaysDate.getDate() + ', ' + todaysDate.getYear());
}
