/**
* @uses lib/Prototype/Prototype.js
* @uses lib/Sureflix/Sureflix.js
* @uses lib/Sureflix/Utilities/Utils.js
* @uses lib/Sureflix/Plugins/Plugins.js
* @uses lib/Sureflix/Plugins/Detector.js
* @uses lib/Sureflix/Error/ErrorHandler.js
*/

/**
* @namespace This namespace contains classes for standard user interface elements.
* @author erik 12/30/2007
*/


Sureflix.UI = {};

SxUi = Sureflix.UI;

Sureflix.UI.useEffects = true;

 /**
 * Embeds a flash object in the page. Replaces InsertFlash() from ClientCommon.js
 * @param {String} imgID The unique ID of the Flash object element
 * @param {Number} imgW The width of the Flash element
 * @param {Number} imgH The height of the Flash element
 * @param {String} flashPath The path to the Flash file, usually on the cdn
 * @param {String} flashURL Imports "sUrl" as a root level variable to the movie which the movie can use to link to when clicked 
 * @param {String} staticURL Static image display if flash is not installed
 * @param {Boolean} isIFrame True if the movie is being loaded in an IFRAME
 * @example Sureflix.UI.InsertFlash("HomeBanner-FlashTest-Img01", 460, 180, 
 * 	"http://published.sureflix.com/ads/Articles/HomeBanner/HomeBanner-FlashTest-Img04.swf", 
 * 	"StudioList.asp?Studio=Matt+Sterling", 
 * 	"http://published.sureflix.com/ads/Articles/HomeBanner/HomeBanner-FlashTest-Img03.jpg");
 * 	//<A href=http://alpha.sureflix.com/work/ClientSamples/InsertFlash.htm target=_blank>sample code</A>
 * @author Nestor 1/1/2004
 */
Sureflix.UI.InsertFlash = function(imgID, imgW, imgH, flashPath, flashURL, staticURL, isIFrame){

	var target = " target=_blank";
		
	if (Sureflix.Plugins.Detector.isRequiredFlashInstalled()) {
		document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ');
		document.write(' ID="' + imgID + '" WIDTH="' + imgW + '" HEIGHT="' + imgH + '" ALIGN="">');
		document.write(' <PARAM NAME=movie VALUE="' + flashPath + '"> ');
		document.write(' <PARAM NAME="AllowScriptAccess" VALUE="always"> ');
		document.write(' <PARAM NAME="wmode" VALUE="opaque"> ');
			
		if (flashURL){
			document.write('<PARAM Name=FlashVars VALUE="sUrl=' + flashURL.replace('&','%26') + '">');
		}
		document.write('<PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#000000> <PARAM NAME="loop" value="true">  ');	
		document.write('<EMBED FlashVars="sUrl=' + flashURL + '" src="' + flashPath + '" quality=high bgcolor=#000000  ');
		document.write(' swLiveConnect=FALSE WIDTH="' + imgW + '" HEIGHT="' + imgH + '" NAME="' + imgID + '" ALIGN=""');
		document.write(' wmode="opaque" AllowScriptAccess="always" ');
		document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
		document.write(' </EMBED>');
		document.write('</OBJECT>');
	} else {
		image = '<IMG SRC="' + staticURL + '" WIDTH="' + imgW + '" HEIGHT="' + imgH + '" BORDER=0>';
		if (flashURL){
			document.write('<a href=' + flashURL + ' ' + target + '>' + image + '</a>');
		} else {
			document.write(image);
		}
	}

}

/**
* Returns the viewport's width
* @return {Integer} Width of the viewport
* @author Hernan 11/05/2007
* @author Erik 05/24/2008 changed from getWindowSize() to GetWindowWidth()
*/
Sureflix.UI.GetWindowWidth = function() {
	var myWidth = 0;

	if (typeof (window.innerWidth) === 'number') {
		//Non-IE
		myWidth = window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	} else if (document.body && document.body.clientWidth) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}


/**
* Returns the viewport's height
* @return {Integer} Height of the viewport
* @author Hernan 11/05/2007
* @author Erik 05/24/2008 changed from getWindowSize() to GetWindowHeight()
*/
Sureflix.UI.GetWindowHeight = function() {
	var myHeight = 0;

	if (typeof (window.innerHeight) === 'number') {
		//Non-IE
		myHeight = window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}

Sureflix.UI.BlurFocusedElement = function() {
	var focusedElements = $$(':focus');
	if (focusedElements.length > 0) {
		focusedElements[0].blur()
	}
}

Sureflix.UI.GetWindowScrollTop = function() {
	return document.scrollTop || window.pageYOffset;
}