// JavaScript Document

//Writing out the favorite icon path and XML in the head
document.write('<link rel="alternate" type="application/rss+xml" title="PlayNC: News Feed" href="http://www.plaync.com/us/news/index.xml"/>');
document.write('<link rel="icon" href="http://www.plaync.com/us/favicon.ico" type="image/x-icon">');
document.write('<link rel="shortcut icon" href="http://www.plaync.com/us/favicon.ico" type="image/x-icon">');

function embed_png(img_path)
{
	var my_date = new Date();
	var my_style = (typeof(arguments[1]) != 'undefined') ? arguments[1] : '';
	
	var IMG = new Image();
		IMG.src = img_path;
	var unique_id = 'png' + my_date.getTime();
		IMG.unique_id = unique_id;
	
	document.write('<div id="' + unique_id + '"></div>');
	
	IMG.onload = function()
	{
		var output = '' +
			'<div style="width: ' + IMG.width + 'px; overflow: hidden; height: ' + IMG.height + 'px; ' + my_style + '">' +
			'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="800" id="image_loader" align="middle">' +
			'<param name="allowScriptAccess" value="sameDomain" />' +
			'<param name="movie" value="/us/images/image_loader.swf?nocache=' + unique_id + '" />' +
			'<param name="quality" value="high" />' +
			'<param name="wmode" value="transparent">' +
			'<param name="FlashVars" value="load_name=' + img_path + '" />' +
			'<embed wmode="transparent" FlashVars="load_name=' + img_path + '" src="/us/images/image_loader.swf?nocache=' + unique_id + '" quality="high" width="800" height="800" name="image_loader" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
			'</object>' +
			'</div>';	
		
		document.getElementById(this.unique_id).innerHTML = output;
	}
}
/*
embed_flash - returns a string or uses document.write to embed a flash movie.
	arguments:
	1)src: path to flash movie
	2)w: width of flash movie
	3)h: height of flash movie
	4)(optional) flash_vars: variables to pass as FlashVars (variablename=value&variable2=value2)
	5)(optional) return_string: if value is defined, output will be returned as a string.
*/
function embed_flash(src, w, h)
{
	var flash_vars = (typeof(arguments[3]) != "undefined") ? arguments[3] : '';
	var output = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + w + '" height="' + h + '">' +
		         '<param name="movie" value="' + src + '" />' +
				 '<param name="quality" value="high" />' +
				 '<param name="wmode" value="transparent" />' +
				 '<param name="showmenu" value="false" />' +
				 '<param name="FlashVars" value="' + flash_vars + '" />' +
				 '<embed src="' + src + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + w + '" height="' + h + '" wmode="transparent" showmenu="false" FlashVars="' + flash_vars + '"></embed>' +
				 '</object>';

	if(typeof(arguments[4]) != "undefined")
	{
		return output;
	} else {
		document.write(output);
	}

}
function game_nav()
{
	this.off = new Image();
	this.on = new Image();
	this.elements = {};
	
	this.add = function(text, href)
		{
			this.elements[text] = href;
		}
	this.output = function()
		{
			var output = '<div id="gameButtons">';
			for(var text in this.elements)
			{
				var docloc = document.location.href.replace(/\?.*/, '').replace(/index\.html/, '');
				if(docloc.indexOf(this.elements[text]) == (docloc.length - this.elements[text].length))
				{
					output += '<div class="gamebutton" style="background: url(' + this.on.src + ');">' + 
							  '<a href="' + this.elements[text] + '">' + text + '</a></div>';					
				} else {
					
					output += '<div class="gamebutton" style="background: url(' + this.off.src + ');">' + 
							  '<a href="' + this.elements[text] + '" ' +
							  ((this.elements[text].indexOf('http://') >= 0) ? ' target="_new" ' : '') +
							  'onmouseover="this.style.background=\'url(' + this.on.src + ')\';" ' +
							  'onmouseout="this.style.background=\'\';">' + text + '</a></div>';
				}
			}
			output += '<div class="clearBoth"></div></div>';
			return output;
		}
}

function swap_game_nav(obj)
{
	obj.style.background = (obj.style.background.indexOf('url') != -1) ? '' : 'url(' + game_nav_on.src + ')';
}

// this function is need to work around 
// a bug in IE related to element attributes
function hasClass(obj) {
	var result = false;
	if (obj.getAttributeNode("class") != null) {
	 result = obj.getAttributeNode("class").value;
	}
	return result;
}   

function stripe(id) {
	
	// the flag we'll use to keep track of 
	// whether the current row is odd or even
	var even = false;
	
	// if arguments are provided to specify the colours
	// of the even & odd rows, then use the them;
	// otherwise use the following defaults:
	var evenColor = arguments[1] ? arguments[1] : "#fff";
	var oddColor = arguments[2] ? arguments[2] : "#eee";
	
	// obtain a reference to the desired table
	// if no such table exists, abort
	var table = document.getElementById(id);
	if (! table) {return;}
	
	// by definition, tables can have more than one tbody
	// element, so we'll have to get the list of child
	// <tbody>s 
	var tbodies = table.getElementsByTagName("tbody");
	
	// and iterate through them...
	for (var h = 0; h < tbodies.length; h++) {
	
	 // find all the <tr> elements... 
	  var trs = tbodies[h].getElementsByTagName("tr");
	  
	  // ... and iterate through them
	  for (var i = 0; i < trs.length; i++) {
	
		// avoid rows that have a class attribute
		// or backgroundColor style
		if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) {
	
		 // get all the cells in this row...
		  var tds = trs[i].getElementsByTagName("td");
		
		  // and iterate through them...
		  for (var j = 0; j < tds.length; j++) {
		
			var mytd = tds[j];
	
			// avoid cells that have a class attribute
			// or backgroundColor style
			if (! hasClass(mytd) && ! mytd.style.backgroundColor) {
		
			  mytd.style.backgroundColor = even ? evenColor : oddColor;
			  
			}
		  }
		}
		// flip from odd to even, or vice-versa
		even =  ! even;
	  }
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

function nc_layer_set()
{
	this.y_scroll = 0;
	this.layers = (arguments.length > 0) ? arguments : new Array();
	this.cur_id = -1;
	this.show = function(id)
	{
		if(this.cur_id != -1)
		{
			document.getElementById(this.layers[this.cur_id]).style.display = '';
		}
		
		document.getElementById(this.layers[id]).style.display = 'block';
		scroll(0,this.y_scroll);
		this.cur_id = id;
	}
}
// Google Analytics External script

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));