// View History Cookie Functions
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (c_name) {
	if (document.cookie.length>0)
	  {	  
	  c_start=document.cookie.toUpperCase().indexOf(c_name.toUpperCase() + "=")
	  if (c_start!=-1)
	    { 
	    c_start=c_start + c_name.length+1 
	    c_end=document.cookie.indexOf(";",c_start)
	    if (c_end==-1) c_end=document.cookie.length
	    return unescape(document.cookie.substring(c_start,c_end))
	    } 
	  }
	return ""
}

function SetCookie (name, value, dayValue) {
	var expDays = dayValue;
	var exp = new Date();
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +";expires=" + exp +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}

// Present Video Player Function

function showVideoPlayer (ASXpath, vidPath, beginTime, videoDuration, vidWidth, vidHeight, vidFormat, targetDiv, playerName) {
	
	
	var vidObj = "";
	
	vidObj += '<OBJECT ID='+playerName+' NAME=player WIDTH='+vidWidth+' HEIGHT='+vidHeight+' classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">';
	vidObj += '<PARAM NAME="URL" VALUE="'+ ASXpath + '&pVideoPath=' + vidPath + vidFormat + '.wmv&pBeginTime=' + beginTime + '&pVideoDuration=' + videoDuration + '">';
	vidObj += '<PARAM NAME="ShowControls" VALUE="1">';
	vidObj += '<PARAM NAME="ShowDisplay" VALUE="0">';
	vidObj += '<PARAM NAME="windowlessVideo" VALUE="1">';
	vidObj += '<PARAM NAME="EnableContextMenu" VALUE="false">';
	vidObj += '<PARAM NAME="ShowStatusBar" VALUE="0">';
	vidObj += '<PARAM NAME="CanSeek" VALUE="1">';
	vidObj += '<PARAM NAME="stretchToFit" VALUE="1">';
	vidObj += '<PARAM NAME="AutoSize" VALUE="0">';
	vidObj += '<PARAM NAME="AutoStart" VALUE="1">';
	vidObj += '<PARAM NAME="SelectionStart" VALUE="100">';
	vidObj += '<PARAM NAME="SelectionEnd" VALUE="120">';
	
	vidObj += '<Embed type="application/x-mplayer2"';
	vidObj += '	pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"';
	vidObj += '	filename="'+ ASXpath + '&pVideoPath=' + vidPath + vidFormat + '.wmv&pBeginTime=' + beginTime + '&pVideoDuration=' + videoDuration + '"';
	vidObj += '	src="'+ ASXpath + '&pVideoPath=' + vidPath + vidFormat + '.wmv&pBeginTime=' + beginTime + '&pVideoDuration=' + videoDuration + '"';
	vidObj += '	Name=player';
	vidObj += '	ShowControls=1';
	vidObj += '	ShowDisplay=0';
	vidObj += '	ShowStatusBar=0';
	vidObj += '	AutoStart=1';
	vidObj += '	width='+vidWidth;
	vidObj += '	height='+vidHeight;
	vidObj += '</embed>';
	vidObj += '</OBJECT>';
	
	try {
		document.getElementById(targetDiv).innerHTML = vidObj;
	} catch(e) {}
}

// Image/DIV rotation functions:

i = 0;
deg2rad = Math.PI * 2 / 360;

function setDivRotation (deg,divid) {
	rad = deg * deg2rad;
	
	costheta = Math.cos(rad);
	sintheta = Math.sin(rad);
	
	try {
		document.getElementById(divid).filters.item(0).M11 = costheta;
		document.getElementById(divid).filters.item(0).M12 = -sintheta;
		document.getElementById(divid).filters.item(0).M21 = sintheta;
		document.getElementById(divid).filters.item(0).M22 = costheta;
	} catch(e) {}
}

function adjustVideoSound (playerName, soundValue) {
	try {
		document.getElementById(playerName).settings.mute = soundValue;
	} catch(e) {}
}

function displayEditMessage () {
	var messageText1 = document.getElementById("editTextLine1").innerHTML;
	var messageText2 = document.getElementById("editTextLine2").innerHTML;
	
	alert(messageText1+"\n\n"+messageText2);
}