// JavaScript Document
function setConsoleInfo(pageid)
{
	//if (window.parent.document.getElementById("curidspan")){
	window.parent.document.getElementById("curidspan").innerHTML = pageid;
	window.parent.document.getElementById("currpageid").value = pageid;
	//}
}


var tmpLastElement
function makeActive(tmpElement)
{

	tmpLocationArray = tmpElement.split("_")
	tmpElementID = tmpLocationArray[2];
	tmpStoryID = tmpLocationArray[1];

	if (window.parent.document.getElementById("editmode").value == "true")
	{
		if (tmpLastElement != undefined || tmpLastElement == "")
		{
			document.getElementById(tmpLastElement).style.backgroundColor = "";
		}
		tmpLastElement = tmpElement;
		document.getElementById(tmpElement).style.backgroundColor = "silver";

		window.parent.document.getElementById("hdncurrstoryid").value = tmpStoryID;
		window.parent.document.getElementById("activeIndicator").value = tmpElementID;
	}
}

function swapFrame(url,tmpCurrTemplateID)
{
	window.location = url;
}


function sendPageLink(headline)
{
	tmpURL = "includes/sendPageLink.asp?pageID=" + document.getElementById("currentpageid").value;
	window.open(tmpURL, null, "height=600,width=800,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}

function printPage()
{
	tmpURL = "print.asp?storyid=" + document.getElementById("currentstoryid").value;
	window.open(tmpURL, "null", "height=800,width=630,status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes,scrollbars=yes");
}

function sendHomeLink(headline)
{
	tmpURL = "sendHomeLink.asp?pageID=" + document.getElementById("currentpageid").value;
	window.open(tmpURL, null, "height=600,width=800,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}

function sendStoryLink()
{
	tmpURL = "includes/sendStoryLink.asp?storyid=" + document.getElementById("currentstoryid").value;
	window.open(tmpURL, null, "height=600,width=800,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}

var event_http_request = false;
function getEventList(pageid, source)
{
	if(event_http_request) {
		event_http_request.abort();
		event_http_request = false;
	}
	if (window.XMLHttpRequest) { // Mozilla [11], Safari, IE 7
		event_http_request = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE 6-
		event_http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var url = "/includes/getEventList.asp?pageid=" + pageid + "&source=" + source;
	
	
	event_http_request.onreadystatechange = function(){ writeEvents() };
	event_http_request.open("GET", url, true);
	event_http_request.send(null);
	
	setConsoleInfo(pageid);
	//document.getElementById("currpageid").value = pageid;


}




function writeEvents()
{
	if (event_http_request.readyState == 4)
	{	
		if (event_http_request.status == 200)
		{
			document.getElementById("body").innerHTML = event_http_request.responseText;
		}
	}
}


function openEvite(id)
{
    var ScreenWidth=window.screen.width;
    var ScreenHeight=window.screen.height;	
    var movefromedge=0;
    placementx=(ScreenWidth/2)-((650)/2);
    placementy=(ScreenHeight/2)-((500+50)/2);
    var PopUpUrl= "evite.asp?storyid=" + id

	window.open(PopUpUrl,"","width=650,height=500,toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy+",screenX="+placementx+",screenY="+placementy+",");
}


function showGallery(id)
{

	//document.getElementById("galleryDiv").style.height = "804px";
	//document.getElementById("galleryDiv").style.width = "730px";
	
	var flashObject = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="767" height="697">'
	+ '<param name="movie" value="/gallery.swf?gid=' + id + '">'
	+ '<param name="quality" value="high">'
	+ '	<param name="wmode" value="transparent" />'
	+ '<embed src="/gallery.swf?gid=' + id + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="767" height="697"></embed>'
	+ '</object>'
	document.getElementById("galleryDiv").innerHTML = flashObject;
	document.getElementById("galleryDiv").style.display = "block";
	//document.getElementById("header").scrollIntoView();
}

function closeGallery()
{
	document.getElementById("galleryDiv").innerHTML = "";
	//document.getElementById("galleryDiv").style.height = "0px";
	//document.getElementById("galleryDiv").style.width = "0px";
	document.getElementById("galleryDiv").style.display = "none";
}



//This function is deprecated
function checkImage()
{
	if (document.getElementById("SPmiddle").innerHTML == "")
	{
		document.getElementById("SPmiddle").style.height = "0px";
		document.getElementById("SPstoryHolder").style.top = "0px";
	}
}

function resizeVidDiv()
{	
		document.getElementById("mainImage").style.height = "440px";
}

function resizeVidDivShort()
{	
		document.getElementById("mainImage").style.height = "240px";
}


function shrinkVidDiv()
{	
	document.getElementById("mainImage").style.height = "240px";
	
	
	//alert(document.getElementById("hdnvidfile").value);
	//alert(document.getElementById("hdnlcid").value);
	if((document.getElementById("hdnvidfile").value != "" && document.getElementById("hdnvidfile").value != "/images/flvvideo/none") || document.getElementById("hdnlcid").value != 0)
	{
		resetVidDiv();
	}
	else
	{
		//resetMainImage(document.getElementById("hdnvidimage").value);
	}
}

function writeNewVideo(file,lcid)
{

	shrinkVidDiv();
	ip = document.getElementById("hdnip").value;
	image = document.getElementById("hdnvidimage").value;

	height = 441;
	player = "mainImagePlayer";


	 var flashObject = '<object id="flvVideo" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="587" height="' + height + '" >'
	+ '          <param name="movie" value="' + player + '?video=/images/flvvideo/' + file + '&lcid=' + lcid + '&ip=' + ip + '&image=' + image + '&playflag=play" />'
	+ '          <param name="quality" value="high" />'
	+ '      	 <param name="wmode" value="transparent" />'
	+ '          <embed src="' + player + '?video=/images/flvvideo/' + file + '&lcid=' + lcid + '&ip=' + ip + '&image=' + image + '&playflag=play" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="587" height="' + height + '" wmode="transparent"></embed>'
	+ '          </object>'

	document.getElementById("mainImage").innerHTML = flashObject;

}

function resetVidDiv()
{	
	lcid = document.getElementById("hdnlcid").value;
	ip = document.getElementById("hdnip").value;
	image = document.getElementById("hdnvidimage").value;
	file = document.getElementById("hdnvidfile").value;
	
	var flashObject = '<object id="flvVideo" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="587" height="441" >'
	+ '          <param name="movie" value="mainImagePlayer.swf?video=' + file + '&lcid=' + lcid + '&ip=' + ip + '&image=' + image + '&playflag=" />'
	+ '          <param name="quality" value="high" />'
	+ '      	 <param name="wmode" value="transparent" />'
	+ '          <embed src="mainImagePlayer.swf?video=' + file + '&lcid=' + lcid + '&ip=' + ip + '&image=' + image + '&playflag=" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="587" height="441" wmode="transparent"></embed>'
	+ '          </object>'
	
	//alert(flashObject)
	document.getElementById("mainImage").innerHTML = flashObject;

}

function resetMainImage(image)
{
	var flashObject = '<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="558" height="314">'
    + '    <param name="movie" value="mainImage.swf?image=' + image + '" />'
    + '    <param name="quality" value="high" />'
	+ '    <param name="wmode" value="transparent" />'
    + '    <embed src="mainImage.swf?image=' + image + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="558" height="314" wmode="transparent"></embed>'
    + '    </object>'
	document.getElementById("mainImage").innerHTML = flashObject;

	
}



function openPlayer(cid,id)
{
    var ScreenWidth=window.screen.width;
    var ScreenHeight=window.screen.height;	
    var movefromedge=0;
    placementx=(ScreenWidth/2)-((770)/2);
    placementy=(ScreenHeight/2)-((630+50)/2);
	
    var PopUpUrl= "http://www.aspireonemedia.com/mediaPlayer/playerHome.asp?cid=128";
	
	if (id != undefined)
	{
		PopUpUrl += "&id=" + id
	}
	//alert(PopUpUrl)
	window.open(PopUpUrl,"Player","width=770,height=630,toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy+",screenX="+placementx+",screenY="+placementy+",");
}



var colorSwap_http_request = false;
function swapColor(color)
{
	if(colorSwap_http_request) {
		colorSwap_http_request.abort();
		colorSwap_http_request = false;
	}
	if (window.XMLHttpRequest) { // Mozilla [11], Safari, IE 7
		colorSwap_http_request = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE 6-
		colorSwap_http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}

	var url = "/includes/swapColor.asp?c=" + color

	
	colorSwap_http_request.onreadystatechange = function(){ colorRefresh() };
	colorSwap_http_request.open("GET", url, true);
	colorSwap_http_request.send(null);
}

function colorRefresh()
{
	if (colorSwap_http_request.readyState == 4)
	{	
		if (colorSwap_http_request.status == 200)
		{
			window.location = window.location;
		}
	}
}
