var video_id=0;
var playerwidth=0;

	if(document.all)
	var xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
	else
	var xMousePosMax = window.innerWidth+window.pageXOffset;

document.write('<script language="javascript" src="http://walkonsite.com/wos1/javascript/prototype.js"></script>');
document.write('<script language="javascript" src="http://walkonsite.com/wos1/javascript/scriptaculous.js"></script>');
document.write('<script language="javascript" src="http://walkonsite.com/wos1/javascript_cookies.js"></script>');
var resp=0;
//This function is used by the flash player to remove itself from the website
//returns nothing.
function removePlayer() {
	parentNode = document.getElementById("wosPlayer").parentNode;
	nodeToRemove = document.getElementById("wosPlayer");
	parentNode.removeChild(nodeToRemove);
}

function pausePlayer(){
		alert("Paused");
	}

function openclickPlayer(){
		alert("coming");
		//alert(url);
}

//This function is created to track player actions
function trackPlayer(action)
{
	//alert(action);
	//alert(video_id);
		var url = 'http://walkonsite.com/wos1/trackvideo.php';
		var pars = 'id=' + video_id + '&action=' + action;
		
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars, 
				onComplete: showTrackResponse
			});
}

function showTrackResponse(originalRequest)
	{
		//alert(originalRequest.responseText);
	}

function IsNumeric(strString)
   //  check for valid numeric strings 
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

//function that creates the player HTML

function createWosPlayer(id, w, h, location, flv, url, done, display, autoplay, hideplayer, videoeffect, delay, delay_time, display_count, second_video, display_hour) 
{
	var resp;
	video_id=id;
	playerwidth=w;
	//check_v_status(video_id);
	//alert("==>"+resp);

	if(resp=="0")
	{
		return;
	}

	if(display=="v")
	{
		if(Get_Cookie('visitor_once_'+id)=="yes")
		{
			//alert(Get_Cookie('visitor_once_'+id));
			return;
		}

		Set_Cookie( 'visitor_once_'+id, 'yes', 24, '/', '', '' );
	}
	else if(display=="x")
	{
		//Delete_Cookie('display_count_'+id, '/', '');
		//alert(display);
		if(IsNumeric(display_count))
		{
			//alert(display_count);
			//alert(Get_Cookie('display_count_'+id));

			var display_no = 1;
			if(Get_Cookie('display_count_'+id)!=null)
			{
				//alert(parseInt(Get_Cookie('display_count_'+id)));
				display_no = parseInt(Get_Cookie('display_count_'+id)) + 1;
				//alert(display_no);
				if(display_no > display_count)
				return;
			}
			Set_Cookie( 'display_count_'+id, display_no, 24, '/', '', '' );
		}
	}
	else if(display=="t")
	{
		if(IsNumeric(display_count) && IsNumeric(display_hour))
		{
			if(display_count>0 && display_hour>0)
			{
				if(Get_Cookie('display_hour_'+id)!=null)
				{
					var display_no = 1;
					if(Get_Cookie('display_count_'+id)!=null)
					{
						//alert(parseInt(Get_Cookie('display_count_'+id)));
						display_no = parseInt(Get_Cookie('display_count_'+id)) + 1;
						//alert(display_no);
						if(display_no > display_count)
						return;
					}
					Set_Cookie( 'display_count_'+id, display_no, 24, '/', '', '' );
				}
				else{
					Set_Cookie( 'display_hour_'+id, display_hour, display_hour, '/', '', '' );
				}
			}
		}
	}

	if(autoplay == null)
	{
		autoplay = true;	
	}
	
	if(hideplayer == null)
	{
		hideplayer = false;	
	}
	
	if(videoeffect == null)
	{
		videoeffect="";	
	}
	
	if(done == null)
	{
		done = "e";	
	}
	
	if(location == 'bl' || location == 'bc'){
		styleLocation = 'bottom:0px; left:0px;';	
	}
	if(location == 'br') {
		styleLocation = 'bottom:0px; right:0px;';
	}
	if(location == 'tr') {
		styleLocation = 'top:0px; right:0px;';
	}
	if(location == 'tl' || location == 'tc' || location == 'cc') {
		styleLocation = 'top:0px; left:0px;';
	}
	
	//create the HTML
	document.write('<div style="position:fixed; '+styleLocation+' z-index:99999999 !important; width:'+w+'px; height:'+h+'px;" id="wosPlayer">');
	/*document.write('<script language="javascript" src="http://walkonsite.com/wos1/wosplayer_js.js"></script>');*/
	document.write('<object id="wosPlayerObjectID" height="'+h+'" width="'+w+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">');
	document.write('<param value="http://walkonsite.com/wos1/Player.swf" name="movie"/>');
	document.write('<param value="flvsource='+flv+'&clickThruURL='+url+'&pos=bc&sw='+w+'&sh='+h+'&done='+done+'&autoplay='+autoplay+'&hideplayer='+hideplayer+'&videoside='+videoeffect+'&second_video='+second_video+'" name="FlashVars"/>');
	document.write('<param value="high" name="quality"/>');
	document.write('<param value="true" name="allowResize"/>');
	document.write('<param value="always" name="allowScriptAccess"/>');
	document.write('<param value="transparent" name="wmode"/>');
	document.write('<param value="true" name="menu"/>');
	document.write('<param value="true" name="swLiveConnect"/>');
	document.write('<embed height="'+h+'" align="middle" width="'+w+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" quality="high" loop="false" menu="true" allowresize="true" wmode="transparent" play="true" swliveconnect="true" name="wosPlayerEmbed" flashvars="flvsource='+flv+'&clickThruURL='+url+'&sw='+w+'&sh='+h+'&done='+done+'&autoplay='+autoplay+'&location=bc&hideplayer='+hideplayer+'&videoside='+videoeffect+'&second_video='+second_video+'" src="http://walkonsite.com/wos1/Player.swf"/>');
	document.write('</object>');
	document.write('</div>');


	if(location=='bc' || location=='tc'){
		document.getElementById("wosPlayer").style.left=xMousePosMax/2 - w/2 + 'px';
		document.onmousemove = alignplayertocenter;
	}
	if(location=='cc'){
		document.getElementById("wosPlayer").style.left=xMousePosMax/2 - w/2 + 'px';
		document.getElementById("wosPlayer").style.top=150 + 'px';
		document.onmousemove = alignplayertocenter;
	}
	if(delay=="delay" && delay_time!=0)
	{
		if(!document.all)
		{
			var time=delay_time * 1000;
			document.getElementById("wosPlayer").style.display="none";
			setTimeout("showplayer()",time);
		}
	}
	if(delay=="fadein" && delay_time!=0)
	{
		new Effect.Opacity("wosPlayer", { duration: delay_time, from: 0, to: 1.0 });
	}
	trackPlayer("load");

}
						
function showplayer()
{
	document.getElementById("wosPlayer").style.display="inline";
}

function alignplayertocenter(e)
{
	if(document.all)
	var xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
	else
	var xMousePosMax = window.innerWidth+window.pageXOffset;

		document.getElementById("wosPlayer").style.left=xMousePosMax/2 - playerwidth/2 + 'px';
}


// code for google analytics
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"));
try {
var pageTracker = _gat._getTracker("UA-12497634-1");
pageTracker._trackPageview();
} catch(err) {}
// code for google analytics