﻿/* Global JavaScript */
$ektron(document).ready(
	function PageLoad()
	{
		//$ektron(".stripeMe tr").mouseover(function() { $ektron(this).addClass("over"); }).mouseout(function() { $ektron(this).removeClass("over"); });
		$ektron(".stripeMe tr:even").addClass("alt");
		/*
		if (ektb_remove != undefined)
		{
			ektb_remove = ektb_remove_override;
		}
		*/
	}
);

var fbProperties = {
	enableEscapeButton: true,
	hideOnContentClick: false,
	hideOnOverlayClick: true,
	overlayColor: '#000',
	overlayOpacity: 0.75,
	showCloseButton: true,
	titleShow: false,
	autoScale: false
};
var flowPlayerSwf = '/Include/FlowPlayer/flowplayer-3.2.5.swf';

function getFbProperties(fbProps)
{
	var newProps = fbProperties;
	for (attrname in fbProps)
	{
		newProps[attrname] = fbProps[attrname];
	}

	return newProps;
}

// Creates or uses an element, nested within a specified "display" element, for embedding specified Flash media (SWF) at assigned dimensions.
function fancyBoxSwfPlayer(selector, id, swf, fbParms, swfParms)
{
	// new fb container
	$('body').append('<div id="' + id + '" />');
	$('#' + id).width(fbParms.width).height(fbParms.height);
	$('#' + id).wrapAll('<div style="display:none;" />');
	// swf embed
	$('#' + id).append('<div id="' + id + 'Swf" />');
	var properties = getFbProperties(fbParms);
	/*
	if (swf.indexOf('flowplayer') > 0)
	{
		var parts = swfParms.config.split('}');
		swfParms.config = parts[0] + ",'key':'#$14ea9aa64f434294f75'}";
	}
	*/
	properties.onStart = function ()
	{
		swfobject.embedSWF(swf, id + 'Swf', this.width, this.height, '9.0.0', null, swfParms, null);
	};
	$(selector).fancybox(properties);
}

function ektb_remove_override()
{
	var focushelper = ektj$("body input#ektjFocusHelper");
	if (focushelper.length == 0)
	{
		ektj$("body").append("<input type=\"text\" id=\"ektjFocusHelper\" style=\"position:absolute; left: -10000px;\"> </input>");
		focushelper = ektj$("body input#ektjFocusHelper");
	}
	if (focushelper.length > 0)
	{
		//		focushelper[0].focus();
		//		focushelper[0].blur();
	}

	ektj$("object").show();
	ektj$("embed").show();

	ektj$("#EkTB_imageOff").unbind("click");
	ektj$("#EkTB_closeWindowButton").unbind("click");
	ektj$("#EkTB_window").fadeOut("fast", function () { ektj$('#EkTB_window,#EkTB_overlay,#EkTB_HideSelect').trigger("unload").unbind().remove(); });
	ektj$("#EkTB_load").remove();
	if (typeof document.body.style.maxHeight == "undefined")
	{//if IE 6
		ektj$("body", "html").css({ height: "auto", width: "auto" });
		ektj$("html").css("overflow", "");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	try
	{
		if (ektb_refreshWindow != "true")
			return false;

		ektb_refreshWindow = "false";

		if (top.frames["ek_main"] != null)
		{
			var buffer = '';
			try
			{
				buffer = new String(top.frames["ek_main"].location.href);
			}
			catch (ex)
			{
			}
			if (buffer.indexOf("#") != -1)
			{
				var sUrl = top.frames["ek_main"].location.pathname;
				var taxonomyId = "";
				if (document.getElementById('taxonomyselectedtree') != null)
					taxonomyId = document.getElementById('taxonomyselectedtree').value;
				if (taxonomyId != "")
					sUrl = sUrl + "?__taxonomyid=" + taxonomyId;
				if (parent != null)
				{
					parent.location.href = sUrl;
				} else
				{
					top.location.href = sUrl;
				}
			}
			else
				top.frames["ek_main"].location.href = top.frames["ek_main"].location.href;
		}
		else
		{
			var buffer = '';
			try
			{
				buffer = new String(top.opener.location);
			}
			catch (ex)
			{
			}
			if (buffer.indexOf("#") != -1)
			{
				var sUrl = parent.location.pathname;
				var taxonomyId = "";
				if (document.getElementById('taxonomyselectedtree') != null)
					taxonomyId = document.getElementById('taxonomyselectedtree').value;
				if (taxonomyId != "")
					sUrl = sUrl + "?__taxonomyid=" + taxonomyId;
				//alert(window.location.pathname);
				if (parent != null)
				{
					parent.location.href = sUrl;
				} else
				{
					top.location.href = sUrl;
				}
			}
			else
			{
				if (parent != null)
				{
					parent.location.href = parent.location.pathname + parent.location.search;
				} else
				{
					top.location.href = top.location.href;
				}
			}
		}

		if (top.DisplayUploadingBox)
		{
			top.DisplayUploadingBox(false);
		}
	}
	catch (e)
	{
		;
	}
	return false;
}


// handles enter key for any input text
function inputOnKeyPress(sender, e, action, parms)
{
	var keynum = window.event ? e.keyCode : e.which;

	if (keynum == 13) // enter key on the textbox
	{
		eval(action + "(sender,e,parms)");
		return false;
	}
}

// process enter submission. code example from ektron developer site examples
function callSearch(sender, e, parms)
{
	//alert("sender: " + sender + "\ne: " + e + "\nparms: " + parms);return;
	var searchBox = document.getElementById(parms[0]);
	if (searchBox != null && searchBox != undefined && searchBox.value != 'Search Site'
		&& searchBox.value != '' && searchBox.value != null)
	{
		__doPostBack(parms[1], ''); // asp input button does not properly submit a form on enter of input box
	}
	return false;
}

// handles focus/blur for the search box
function SearchBoxFocusBlur(sender, e)
{
	if (e.type == 'focus')
	{
		if (sender.value == 'search site')
		{
			sender.value = '';
		}
	}
	else
	{
		if (sender.value == '')
		{
			sender.value = 'search site';
		}
	}
}
