String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function createRequestObject()
{
	var req_obj = null;

	if ( window.XMLHttpRequest )
	{
		req_obj = new XMLHttpRequest();
	}
	else
	{
		try
		{
    		req_obj = new ActiveXObject( "Msxml2.XMLHTTP" );
		}
		catch( e )
		{
		    req_obj = new ActiveXObject( "Microsoft.XMLHTTP" );
		}
	}

	return req_obj;
}

function ajaxSendRequest( req_obj, req_method, url, return_method, async )
{
	var request_sent = false;
	var is_async = ((async==null) ? true : async);
	var method = ((req_method == null) ? 'get' : req_method);
	try
	{
		req_obj.open( method, url, is_async );
		req_obj.onreadystatechange = return_method;
		req_obj.send(null);
		request_sent = true;
	}
	catch( e )
	{
		request_sent = false;
	}

	return request_sent;
}

function ajaxRequestComplete( req_obj )
{
	return ( req_obj.readyState == 4 );
}

function ajaxPopulateDiv( tgt_div, data )
{
	document.getElementById( tgt_div ).innerHTML = data;
}

var shareLinksTimeout = null;
var shareLinksTarget = null;
function showShareLinks( se, display )
{
	shareLinksTarget = null;
	clearTimeout( shareLinksTimeout );

	var pe = se.parentNode;
	for( var i = 0; i < 10 && pe.tagName.toLowerCase() != "li"; i++ )
	{
		pe = pe.parentNode;
	}

	if( pe.tagName.toLowerCase() == "li" )
	{
		var divs = pe.getElementsByTagName("div");
	
		if( divs.length > 0 )
		{
			var uls = divs[0].getElementsByTagName("ul");
			if( uls.length > 0 )
			{
				shareLinksTarget = uls[0];
				if( display == "false" )
				{
					shareLinksTimeout = setTimeout( "$(shareLinksTarget).hide(100);", 300 );
				}
				else
				{
					$(shareLinksTarget).show(100);
				}
			}
		}
	}
}

function returnSBLink( shareName )
{
	var articleTitle = document.getElementById( "articleHeadContainer" );
	if( !articleTitle )
	{
		return false;
	}

	articleTitle = encodeURIComponent( articleTitle.innerHTML );
	var url = encodeURIComponent( window.location.href );
	var newWindowHREF = null;

	if( shareName == "digg" )
	{
		newWindowHREF = "http://digg.com/submit?phase=2&url=" + url + "&title=" + articleTitle;
	}
	else if( shareName == "newsvine" )
	{
		newWindowHREF = "http://www.newsvine.com/_wine/save?popoff=0&u=" + url + "&h=" + articleTitle;
	}
	else if( shareName == "delicious" )
	{
		newWindowHREF = "http://del.icio.us/post?url=" + url + "&title=" + articleTitle;
	}
	else if( shareName == "reddit" )
	{
		newWindowHREF = "http://reddit.com/submit?url=" + url + "&title=" + articleTitle;
	}
	else if( shareName == "facebook" )
	{
		newWindowHREF = "http://www.facebook.com/sharer.php?u=" + url + "&t=" + articleTitle;
	}

	if( newWindowHREF != null )
	{
		window.open( newWindowHREF, shareName + "_share" );
	}
}

function emailFriend( url )
{
	Floaters.createNew( 'emailfriend', null, 'Email a Friend', '<br /><p style="text-align:center;">Loading email form...</p>', 250, 100 );
	$.ajax(
		{
			url:url + "&title=" + encodeURIComponent( $("#articleHeadContainer").html() ),
			type:'GET',
			dataType:'text',
			success:function(result)
			{
				Floaters.createNew( 'emailfriend', null, 'Email a Friend', result, 350, 350 );
			}
		}
	);
}

function emailFriendSubmit( myForm )
{
	$("#floater-title-emailfriend").html("Processing form...");
	var queryString = $(myForm).formSerialize();
	if( myForm.from.value.trim() == "" )
	{
		alert("Please provide your name.");
		return false;
	}
	else if( myForm.fromemail.value.trim() == "" )
	{
		alert("Please provide your email address.");
		return false;
	}
	else if( myForm.to.value.trim() == "" )
	{
		alert("Please provide your friend's email address.");
		return false;
	}

	$.ajax(
		{
			url:$(myForm).attr("action"),
			type:$(myForm).attr("method"),
			data:queryString,
			dataType:'text',
			success:function(result)
			{
				var regex = new RegExp( ".*?location\\.href='(.+?)'.*", "i" );
				var nextLocation = regex.exec( result );
				if( nextLocation.length > 1 )
				{
					$.ajax(
						{
							url:nextLocation[1],
							type:"GET",
							dataType:"text",
							success:function(result)
							{
									Floaters.createNew( 'emailfriend', null, 'Email a Friend', result, 350, 300 );
							}
						}
					);			
				}
				else
				{
					alert("There was an error while processing the form. Please try again later.");
					Floaters.close("emailfriend");
				}
			}
		}
	);
	
	return false;
}

function changeSearchPage( url )
{
	//url = url.replace(/&amp;/,"&").replace(/&#37;/,"%");
	url = encodeURI( url );
	$("#floater-content-searchresults").html('<br /><br /><p align="center"><br />Executing your search<br />Please wait ...<br /><br /></p>');

	try
	{
		$.ajax(
			{
				url:url,
				type:"GET",
				dataType:"html",
				success:function(result)
				{
					//$("#floater-content-searchresults").html(result);
					document.getElementById("floater-content-searchresults").innerHTML = result;
				}
			}
		);
	}
	catch( e )
	{
		$("#floater-content-searchresults").html('<br /><br /><p align="center"><br />There was an error while executing your search. Please try again later.<br /><br /></p>');
	}
}

function executeSearch( searchFormID )
{
	var searchForm = document.getElementById(searchFormID);
	Floaters.createNew( 'searchresults', null, 'Search Results', '<br /><br /><p align="center"><br />Executing your search<br />Please wait ...<br /><br /></p>', 500, 350 );

	try
	{
		var queryString = $(searchForm).formSerialize();

		$.ajax(
			{
				url:$(searchForm).attr("action"),
				type:$(searchForm).attr("method"),
				data:queryString,
				dataType:"html",
				success:function(result)
				{
					//Floaters.createNew( 'searchresults', null, 'Search Results', result, 500, 350 );
					//$("#floater-content-searchresults").html(result);
					document.getElementById("floater-content-searchresults").innerHTML = result;
				}
			}
		);
	}
	catch( e )
	{
		//Floaters.createNew( 'searchresults', null, 'Search Results', '<br /><br /><p align="center"><br />There was an error while executing your search. Please try again later.<br /><br /></p>', 500, 350 );
		$("#floater-content-searchresults").html('<br /><br /><p align="center"><br />There was an error while executing your search. Please try again later.<br /><br /></p>');
	}

	return false;
}

//place it here for now while rob is working on the owh js file
function enlargePhoto( url, maxwidth, maxheight, title, text, byline )
{
	Floaters.createNew( 'enlargedphoto', null, title, '<br /><p style="text-align:center;">Loading photo...</p>', 250, 100 );

	url = url.replace(/&amp;/gi,'&').replace(/&quot;/gi,'"').replace(/&apos;/gi,"'") + "&maxw=" + maxwidth + "&maxh=" + maxheight;
	title = title.replace(/&amp;/gi,'&').replace(/&quot;/gi,'"').replace(/&apos;/gi,"'");
	title = title.trim() == "" ? "&nbsp;" : title;
	text = text.replace(/&amp;/gi,'&').replace(/&quot;/gi,'"').replace(/&apos;/gi,"'");
	byline = byline.replace(/&amp;/gi,'&').replace(/&quot;/gi,'"').replace(/&apos;/gi,"'");

	var img = new Image();
	img.onload = function(url,maxwidth,maxheight,title,text,byline,img)
	{
		return function()
		{
			img.onload = null;
			var imgwidth = img.width;
			var imgheight = img.height;

			var innerHTMLText = "";
			var contentDiv = document.getElementById( "floater-content-enlargedphoto" );
			var totalHeight = imgheight;
			if( text.trim() != "" || byline.trim() != "" )
			{
				innerHTMLText += '<div id="floaterphotocaption" style="width:' + imgwidth + 'px;">';
				innerHTMLText += text.trim() != "" ? text : "";
				innerHTMLText += text.trim() != "" && byline.trim() != "" ? "<br /><br />" : "";
				innerHTMLText += byline.trim() != "" ? "<span style=\"font-style:italic;\">" + byline + "</span>" : "";
				innerHTMLText += '</div>';

				var photodiv = document.createElement("div");
				photodiv.id = "enlargedphoto";
				photodiv.style.textAlign = "left";
				photodiv.style.margin = "0px";

				photodiv.innerHTML = innerHTMLText;
				photodiv.style.visibility = 'hidden';
				contentDiv.appendChild(photodiv);
				totalHeight += photodiv.style.pixelHeight ? photodiv.style.pixelHeight : photodiv.offsetHeight;
				photodiv.style.display = 'none';
			}

			innerHTMLText = '<img src="' + url + '" alt="Enlarged photo" />' + innerHTMLText;
			Floaters.createNew( 'enlargedphoto', null, title, '<div style="text-align:left; margin:0px;">' + innerHTMLText + '</div>', imgwidth + 22, totalHeight + 50 );
		}
	}(url,maxwidth,maxheight,title,text,byline,img);
	img.src = url;
	//Floaters.createNew( 'enlargedphoto', null, title, response, 500, 400 );
}

function parseXML ( xml )
{
	var domObj = null;

	if ( window.DOMParser )
	{
//		alert("Alpha");
		var parser=new DOMParser();
		domObj=parser.parseFromString(xml,"text/xml");
	}
	else if ( window.ActiveXObject && window.GetObject )
    {
//		alert("Bravo");
		domObj = new ActiveXObject("Microsoft.XMLDOM");
		domObj.async=false;
		domObj.loadXML(xml);
    }
    else
    {
//		alert("Charlie");
    	domObj = null;
    }

	return domObj;
}

function setSearchParameters( activeLinkIndices, positionid, selection, text, actionOverride )
{
	if(selection=="all")
	{
		document[positionid+"searchForm"].SearchCategory.value="%";
		document[positionid+"searchForm"].SearchProfile.value="0";
	}
	else
	{
		document[positionid+"searchForm"].SearchCategory.value = selection;
		document[positionid+"searchForm"].SearchProfile.value="";
	}

	if( typeof actionOverride != 'undefined' && actionOverride != null && actionOverride != "" )
	{
		document[positionid+"searchForm"].action = actionOverride;
	}
	else if( typeof searchFormDefaultAction != 'undefined' && searchFormDefaultAction != null && searchFormDefaultAction != "" )
	{
		document[positionid+"searchForm"].action = searchFormDefaultAction;
	}

	$("#"+positionid+" .searchNav").find("li a").each( function()
		{
			$(this).removeClass();
		}
	);

	var indices = activeLinkIndices.split("\|");
	for( var ic = 0; ic < indices.length; ic++ )
	{
		$("#"+positionid+" .searchNav li:eq("+indices[ic]+") > a").addClass("activeNav");
	}
}

var showSearchOptionsTimeout = null;
var showSearchOptionsTarget = null;
function openMoreSearchOptions( targetid, display )
{
	clearTimeout( showSearchOptionsTimeout );

	showSearchOptionsTarget = document.getElementById(targetid);
	if( showSearchOptionsTarget )
	{
		if( display == "false" )
		{
			showSearchOptionsTimeout = setTimeout( "$(showSearchOptionsTarget).slideUp(250);", 300 );
		}
		else
		{
			$(showSearchOptionsTarget).slideDown(250);
		}
	}
}

var morePicturesItems = new Array();
var showMorePicturesTimeout = null;
var showMorePicturesTarget = null;
function addMorePicturesItem( url, title, caption, byline, maxThumbW, maxThumbH, maxW, maxH )
{
	url = url.replace(/&amp;/gi,'&').replace(/&quot;/gi,'"').replace(/&apos;/gi,"'");
	title = title.replace(/&amp;/gi,'&').replace(/&quot;/gi,'"').replace(/&apos;/gi,"'");
	title = title.trim() == "" ? "&nbsp;" : title;
	caption = caption.replace(/&amp;/gi,'&').replace(/&quot;/gi,'"').replace(/&apos;/gi,"'");
	byline = byline.replace(/&amp;/gi,'&').replace(/&quot;/gi,'"').replace(/&apos;/gi,"'");

	morePicturesItems.push( { url:url, title:title, caption:caption, byline:byline, maxthumbw:maxThumbW, maxthumbh:maxThumbH, maxw:maxW, maxh:maxH } );

	//preload the thumbnails at least
	var tempImgObject = new Image();
	tempImgObject.src = url + "&maxw=" + maxThumbW + "&maxh=" + maxThumbH;

	//preload the larger photo too
	var tempImgObject2 = new Image();
	tempImgObject2.src = url + "&maxw=" + maxW + "&maxh=" + maxH;
}

function updateMorePicturesCount()
{
	var piclink = document.getElementById( "morePicturesLink" );
	if( piclink && morePicturesItems.length > 1 )
	{
		piclink.innerHTML = '<a href="javascript:showMorePictures();">More Photos (' + morePicturesItems.length + ')</a>';
		piclink.style.display = "block";
	}
}

var showMorePicturesIndex = -1;
var showMorePicturesCurrentTarget = null;
var showMorePicturesActive = false;
function showMorePictures()
{
	var morePicsDOM = document.createElement("div");
	var maxw = morePicturesItems[0].maxw;
	var maxh = morePicturesItems[0].maxh;

	morePicsDOM.style.width = maxw + "px";
	morePicsDOM.style.height = maxh + "px";
	morePicsDOM.style.overflow = "hidden";
	morePicsDOM.style.position = "relative";
	morePicsDOM.style.margin = "0px auto";

	var captions = document.createElement("div");
	captions.id = "showMorePicturesCaptions";
	captions.style.width = ( Math.floor( maxw * 3/5 ) ) + "px";
	captions.style.textAlign = "left";
	captions.style.margin = "0px auto";
	captions.style.paddingTop = "5px";
	
	for( var dc = 0; dc < morePicturesItems.length; dc++ )
	{
		var curpic = morePicturesItems[dc];

		var curpicDOM = document.createElement("div");
		curpicDOM.style.position = "absolute";
		curpicDOM.style.display = "none";
		curpicDOM.id = "morephotos-" + dc;

		var curpicInner = document.createElement("div");
		curpicInner.position = "relative";
		curpicInner.style.width = maxw + "px";
		curpicInner.style.height = maxh + "px";
		curpicInner.style.overflow = "hidden";
		curpicInner.style.textAlign = "center";
		curpicInner.style.verticalAlign = "middle";
		curpicInner.style.lineHeight = maxh + "px";

		var curpicImage = new Image();
		curpicImage.onload = function(curpicImage, maxh)
		{
			return function()
			{
				curpicImage.onload = null;
				curpicImage.style.marginTop = Math.floor( ( maxh - curpicImage.height ) / 2 );
			};
		}( curpicImage, maxh );
		curpicImage.src = curpic.url + "&maxw=" + curpic.maxw + "&maxh=" + curpic.maxh;
		curpicImage.alt = curpic.title;
		curpicImage.title = curpic.title;
		curpicImage.style.margin = "0px auto";
		curpicImage.style.verticalAlign = "middle";

		curpicInner.appendChild( curpicImage );
		curpicDOM.appendChild( curpicInner );

		if( dc == 0 )
		{
			curpicDOM.style.left = "0px";
			curpicDOM.style.display = "block";
			curpicDOM.style.opacity = "1";
			showMorePicturesIndex = 0;
			showMorePicturesCurrentTarget = curpicDOM;

			captions.innerHTML = buildPhotoCaption( curpic.title, curpic.caption, curpic.byline );
		}

		morePicsDOM.appendChild( curpicDOM );
	}


	var nextArrow = document.createElement("div");
	nextArrow.className = "morepicturesnextarrow";
	nextArrow.style.top = ( Math.floor( maxh / 2 ) + 30 - 22 ) + "px";
	nextArrow.innerHTML = "<a href=\"javascript:showNextPicture('next');\"><img src=\"/images/bluearrowright.gif\" alt=\"Next Image\" title=\"Next Image\" /></a>";

	var prevArrow = document.createElement("div");
	prevArrow.className = "morepicturesprevarrow";
	prevArrow.style.top = ( Math.floor( maxh / 2 ) + 30 - 22 ) + "px";
	prevArrow.innerHTML = "<a href=\"javascript:showNextPicture('previous');\"><img src=\"/images/bluearrowleft.gif\" alt=\"Previous Image\" title=\"Previous Image\" /></a>";

	Floaters.createNew( "morephotos", null, "More Photos", "", maxw + 80, maxh + 150 );

	document.getElementById("floater-content-morephotos").style.textAlign = "center";
	document.getElementById("floater-content-morephotos").appendChild( morePicsDOM );
	document.getElementById("floater-content-morephotos").appendChild( captions );
	document.getElementById("floater-content-morephotos").appendChild( nextArrow );
	document.getElementById("floater-content-morephotos").appendChild( prevArrow );

	//the following is a HACK for ie6
	var tdiv = document.getElementById("floater-content-morephotos");
	var safety = 0;
	while( !( tdiv.className && tdiv.className == "floater-wrapper-default" ) && safety++ < 10 )
	{
		tdiv = tdiv.parentNode;
	}

	if( tdiv.className && tdiv.className == "floater-wrapper-default" )
	{
		//var forcew = Floaters.getElementWidth( tdiv );
		//tdiv.style.width = ( forcew - 1 ) + "px"; 
		tdiv.className = "floater-wrapper-default ie-100-hack"
	}
}

function buildPhotoCaption( title, caption, byline )
{
	var captionText = "";
	captionText += title.trim() != "" ? "<div style=\"font-weight:bold;\">" + title + "</div>" : "";
	captionText += caption.trim() != "" ? caption : "";
	captionText += caption.trim() != "" && byline.trim() != "" ? "<br />" : "";
	captionText += byline.trim() != "" ? "<div style=\"font-style:italic;\">" + byline + "</div>" : "";

	return captionText;
}

function showNextPicture( direction )
{
	if( !showMorePicturesActive )
	{
		direction = direction == "next" ? "next" : direction == "previous" ? "previous" : "next";
	
		showMorePicturesIndex += direction == "next" ? 1 : -1;
		if( ( showMorePicturesIndex < 0 && direction == "previous" ) || ( showMorePicturesIndex >= morePicturesItems.length && direction == "previous" ) )
		{
			showMorePicturesIndex = morePicturesItems.length - 1;
		}
		else if( ( showMorePicturesIndex < 0 && direction == "next" ) || ( showMorePicturesIndex >= morePicturesItems.length && direction == "next" ) )
		{
			showMorePicturesIndex = 0;
		}
	
		var lastTarget = showMorePicturesCurrentTarget;
		showMorePicturesCurrentTarget = document.getElementById("morephotos-" + showMorePicturesIndex);
	
		if( showMorePicturesCurrentTarget )
		{
			if( lastTarget )
			{
				$(lastTarget).animate(
					{
						left: direction == "next" ? "-700px" : "700px",
						opacity: "0.1"
					}
					, 500
					, "swing"
					, function( lastTarget )
					{
						return function()
						{
							lastTarget.style.display = "none";	
						};
					}(lastTarget)
				);
			}
			
			if( showMorePicturesCurrentTarget )
			{
				showMorePicturesActive = true;

				showMorePicturesCurrentTarget.style.left = direction == "next" ? "700px" : "-700px";
				showMorePicturesCurrentTarget.style.opacity = "0.1";
				showMorePicturesCurrentTarget.style.display = "block";
				$(showMorePicturesCurrentTarget).animate(
					{
						left: "0px",
						opacity: "1"
					}
					, 500
					, "swing"
					, function()
					{
						var captions = document.getElementById("showMorePicturesCaptions");
						var curItem = morePicturesItems[showMorePicturesIndex];
						if( captions && curItem )
						{
							captions.innerHTML = buildPhotoCaption( curItem.title, curItem.caption, curItem.byline );
						}

						showMorePicturesActive = false;
					}
				);
			}
		}
	}
}

	function open_ors_window( form_name, option )
	{
		var mod = "";
		var opt = "";
		var window_name = 'wnd_mkt_login';
		var mkt_login_features = "width=860,height=695,resizable=1,toolbar=0,scrollbars=1";
	
		if (form_name != null)
		{	mod = "&u_mod="+form_name;	}
		else
		{	mod = "&u_mod=login";	}
		
	
		if (option != null)
		{	opt = "&u_opt="+option;	}
	
		setTimeout("checkChild()", 1000);
		wnd = window.open( D_SRVR_SECURE_HOST+"index.php?u_page=1002"+mod+"&u_dta="+getCookie("D_SRVR_DTA")+opt, window_name, mkt_login_features );
		child_win = wnd;
		wnd.focus();
	}

	var child_win = null;
	function checkChild()
	{
		if ((child_win != null) && (child_win.closed == true))
		{
			displayLoginLinks();
			window.location.reload( true );
		}
		else
		{
			setTimeout("checkChild()", 500);
		}
	}

	function displayLoginLinks()
	{
		try
		{
			$.ajax(
				{
					url:"/section/exec?name=loginLinks.php5&omniture=0",
					type:"GET",
					dataType:"html",
					success:function(result)
					{
						$("#loginLinks").html(result);
					}
				}
			);
		}
		catch( e )
		{
			// do nothing
		}
	}

	function attempt_logout()
	{
		var newFrame = document.createElement("iframe");
		newFrame.src = D_SRVR_SECURE_HOST+"index.php?u_page=1002&u_mod=logout&u_dta="+getCookie("D_SRVR_DTA");
		newFrame.style.width = "1px";
		newFrame.style.height = "1px";

		newFrame.style.visibility = "hidden";
		newFrame.style.display = "none";

		document.body.appendChild( newFrame );

		try
		{
			$.ajax(
				{
					url:"/section/exec?name=orsClearLoginVars.php5&omniture=0",
					type:"GET",
					dataType:"html",
					success:function(result)
					{
						displayLoginLinks();
						window.location.reload( true );
					}
				}
			);
		}
		catch( e )
		{
			// do nothing
		}
	}

for (var xx=1; xx<50; xx++)
{
	eval("var AAMB"+xx+" = \"\";");
}
function displayAd(adNum, boxed, contained, hideHeader, force, finishAd)
{
	var someStr = eval("AAMB" + adNum).replace(/\r|\n/gi, "\\n").replace(/.*?(<\s*body.*?>)(.*)(<\s*\/\s*body\s*>).*/gi, "$2").replace(/\\n/gi,"\n").trim();
	var regex = new RegExp( "AE[0-9]\.gif" );
	var nextLocation = regex.exec( someStr );

	if ( ( (someStr.length > 0) && ( nextLocation == null ) ) || ( ( nextLocation != null ) && ( someStr.indexOf( "noscript" ) >= 0 ) ) || (force == true) )
	{
		if( finishAd !== true )
		{
			if (contained == true)
			{
				document.writeln("<div class=\"adContainer\">");
			}
	
			if (boxed == true)
			{
				document.writeln("<div class=\"ltBlueModule\" style=\"width: 179px;\">\r\t\t<div class=\"boxTop\">\r\t\t\t<div class=\"boxParentColorRow1\"><div class=\"row1\"></div></div>\r\t\t\t<div class=\"boxParentColorRow2\"><div class=\"row2\"></div></div>\r\t\t\t<div class=\"boxParentColorRow3\"><div class=\"row3\"></div></div>\r\t\t\t<div class=\"boxParentColorRow4\"><div class=\"row4\"></div></div>\r\t\t</div>\r\t\t<div class=\"boxContainer\">\r\t\t<div class=\"boxContents\"");
			}
	
			if (hideHeader == false)
			{
				document.writeln("<h5>Advertising</h5>");
			}
	
			document.writeln("<div id=\"AAMB" + adNum + "\" class=\"aamb\">\n" + someStr + "\n</div>");
		}
		else
		{	
			if (boxed == true)
			{
			document.writeln("\r\t\t</div>\r\t\t</div>\r\t\t<div class=\"boxBottom\">\r\t\t\t<div class=\"boxParentColorRow4\"><div class=\"row4\"></div></div>\r\t\t\t<div class=\"boxParentColorRow3\"><div class=\"row3\"></div></div>\r\t\t\t<div class=\"boxParentColorRow2\"><div class=\"row2\"></div></div>\r\t\t\t<div class=\"boxParentColorRow1\"><div class=\"row1\"></div></div>\r\t\t</div>\r</div>\r");
			}
	
			if (contained == true)
			{
				document.writeln("</div>");
			}
		}
	}
/*
	else
	{
		var hideObj = document.getElementById( "AAMB" + adNum );
		hideObj.style.visibility = 'hidden';
		hideObj.style.display = 'none';
	}

*/
}
function popWin(url_in, width_in, height_in, title_in)
{  // General method used to open a popup window from the site
	var winWidth = ((width_in!=null) ? parseInt(width_in) : 640);
	var winHeight = ((height_in!=null) ? parseInt(height_in) : 480);
	var windowTitle = (String)((title_in!=null) ? title_in: "");
	
	windowTitle = windowTitle.replace(/ /g, "_");
	var features = "width="+winWidth+",height="+winHeight+",resizable=1,toolbar=0,scrollbars=0";  

	wnd = window.open(url_in, windowTitle, features);
	wnd.focus();
}

function changeVideoPlaylist( frm, pid, count )
{
	var url = frm.action;
	url += "&prodover=";
	if( pid != null && typeof pid != 'undefined' )
	{
		url += pid;
	}
	else
	{
		url += frm.viewplaylist.options[frm.viewplaylist.selectedIndex].value;
	}

	if( count )
	{
		url += "&vidcount=" + frm.viewcount.options[frm.viewcount.selectedIndex].value;
	}

	window.location.href = url;
}

function launchapgallery( slideshow_link, width, height )
{
	if( width == null )
	{
		width = 480;
	}
	if( height == null )
	{
		height = 500;
	}

	if( slideshow_link != "" )
	{
		var newwin = window.open( "/apps/pbcs.dll/misc?URL=/templates/apgallery.pbs&omniture=0&swf=" + encodeURIComponent(slideshow_link), "apgalleryplayer","width=" + width + ",height=" + height + ",status=0,scrollbars=0,menubar=0,location=0,resizable=1" );
		newwin.focus();
	}
}

function enterKeyPressed(e)
{ 
	var myKeyCode	= 0;
	var enter_pressed = false;

	if ( document.all )	// Internet Explorer 4+
	{	myKeyCode = e.keyCode;	}
	else if ( document.layers || document.getElementById ) // Netscape 4 0r 6+
	{	myKeyCode = e.which;	}

	if ( (myKeyCode == 13) )
	{	enter_pressed = true;	}
	
	return enter_pressed;
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");

		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 document.cookie.substring(c_start,c_end);
		}
	}

	return "";
}

function launchigallery( slideshow_id, width, height, maximize )
{
	if( width == null )
	{
		width = 800;
	}
	if( height == null )
	{
		height = 600;
	}

	videoid = ( slideshow_id != undefined && slideshow_id != null ? slideshow_id : "" );
	var extraoptions = "";

	if( screen && ( maximize === true || maximize == "true" ) )
	{
		width = screen.availWidth;
		height = screen.availHeight - 35;
		extraoptions = ",top=0,left=0";
	}

	var newwin = window.open( "http://odc.omaha.com/index.php?u_page=5002&p=" + slideshow_id, "igalleryplayer","width=" + width + ",height=" + height + ",status=0,scrollbars=0,menubar=0,location=0,resizable=1" + extraoptions );
	newwin.focus();
	newwin.moveTo(0,0);
}

