if(typeof document.ord=="undefined")document.ord=Math.random()*10000000000000000;
ord=document.ord;

if(typeof g_ext == "undefined") g_ext="";
if(typeof sBlinkxReferrer == "undefined") sBlinkxReferrer = false;
if(typeof g_sStorePrefix == "undefined") g_sStorePrefix = "http://cdn.blinkx.com";
if(typeof bWall == "undefined") bWall=false;
if(typeof g_bWhiteBottomBorder == "undefined") g_bWhiteBottomBorder=true;
if(typeof g_bIsSafeSearchOn == "undefined") g_bIsSafeSearchOn=true;
if(typeof g_sQueryParam == "undefined") g_sQueryParam="";
if(typeof varBackUpLocation == "undefined") varBackUpLocation=g_sStorePrefix+"/images/defaultswf/webvideo2.jpg";
if(typeof bWasInSingleVideoMode == "undefined") bWasInSingleVideoMode=false;
if(typeof g_sScratchpadCookieName == "undefined") g_sScratchpadCookieName="blinkxtvscratchpadMediaIDs";
if(typeof g_bDisableLinks == "undefined") g_bDisableLinks=false;
if(typeof g_bUseCutDownMediaIcons == "undefined") g_bUseCutDownMediaIcons=false;

//Function to produce xml http request
function initXMLHttpClient()
{
	var xmlhttp;
	try
	{
		xmlhttp=new XMLHttpRequest();
		return xmlhttp;
	}
	catch(e)
	{
		var arrSignatures=['MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
		for (var i=0,iMax=arrSignatures.length;i<iMax;i++)
		{
			try
			{
				xmlhttp=new ActiveXObject(arrSignatures[i]);
				return xmlhttp;
			}
			catch (oError)
			{
			}
		}
		throw new Error("Could not create XMLHttpObject on this system.");
	}
	return xmlhttp;
}


/**
 * SWFObject v1.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){
_16.push(key+"="+_18[key]);}
return _16;
},getSWFHTML:function(){
var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}
_19+="/>";
}else{
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}
_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();
return true;
}else{
if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(_23,_24){
var _25=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_25=new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{
var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
for(var i=3;axo!=null;i++){
axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
_25=new deconcept.PlayerVersion([i,0,0]);}}
catch(e){}
if(_23&&_25.major>_23.major){return _25;}
if(!_23||((_23.minor!=0||_23.rev!=0)&&_25.major==_23.major)||_25.major!=6||_24){
try{_25=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}
catch(e){}}}
return _25;};
deconcept.PlayerVersion=function(_29){

if (_29.length==0) return;
this.major=parseInt(_29[0])!=null?parseInt(_29[0]):0;

if (_29.length==1) return;
this.minor=parseInt(_29[1])||0;

if (_29.length==2) return;
this.rev=parseInt(_29[2])||0;

};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}return true;};
deconcept.util={getRequestParameter:function(_2b){
var q=document.location.search||document.location.hash;
if(q){
var _2d=q.indexOf(_2b+"=");
var _2e=(q.indexOf("&",_2d)>-1)?q.indexOf("&",_2d):q.length;
if(q.length>1&&_2d>-1){
return q.substring(q.indexOf("=",_2d)+1,_2e);
}}return "";}};
if(Array.prototype.push==null){
Array.prototype.push=function(_2f){
this[this.length]=_2f;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject; // for backwards compatibility
var SWFObject=deconcept.SWFObject;

//---------------------------------------------------------Flash-----------------------------------------------------------//
//DEFINE THE REQUIRED VERSION OF FLASH FOR THE SITE
var FLASH_VERSION_MAJOR=9, FLASH_VERSION_MINOR=0, FLASH_VERSION_REVISION=28;

//Detects whether flash is the correct version
function isCorrectFlashVersionInstalled(iMajorVer,iMinorVer,iRevisionVer)
{
	var bInstalled=false;
	if(navigator.mimeTypes.length>0)
	{
		if(navigator.mimeTypes["application/x-shockwave-flash"]==null)
		{
			bInstalled=false;
		}
		else
			bInstalled=navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin!=null;
	}
	else if(window.ActiveXObject)
	{
		try
		{
			new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			bInstalled=true;
		}
		catch(oError)
		{
			bInstalled=false;
		}
	}

	if(bInstalled)
	{
		bVerOk=false;
		if(window.DetectFlashVer)
		{
			bVerOk=DetectFlashVer(iMajorVer,iMinorVer,iRevisionVer);
		}
		else if(deconcept.SWFObjectUtil)
		{
			bVerOk=deconcept.SWFObjectUtil.getPlayerVersion().versionIsValid(new deconcept.PlayerVersion([FLASH_VERSION_MAJOR,FLASH_VERSION_MINOR,FLASH_VERSION_REVISION]));
		}
		return bVerOk;
	}
}

//Main method to load flash.
function showFlash(source,newId,width,height,flashvars,replaceId)
{
	if(isCorrectFlashVersionInstalled(FLASH_VERSION_MAJOR,FLASH_VERSION_MINOR,FLASH_VERSION_REVISION))
	{
		var playerMasq = new SWFObject(source, newId,width,height,FLASH_VERSION_MAJOR+"."+FLASH_VERSION_MINOR+"."+FLASH_VERSION_REVISION, "#000000");
		playerMasq.addParam("allowScriptAccess", "always");
		playerMasq.addParam("quality", "high");
		playerMasq.addParam("allowFullScreen", "true");
		playerMasq.addParam("bgcolor", "#000000");
		playerMasq.addParam("flashvars",flashvars);
		playerMasq.write(replaceId);
	}
	else
	{
		incorrectFlashVersion();
	}
}

//What to do if the flash version is incorrect
function incorrectFlashVersion()
{
	var replaceContentHtml = "<table width=\"100%\" height=\"100%\"><tr><td align=\"center\" style=\"background-color:white\">You must have at least version "+FLASH_VERSION_MAJOR+"."+FLASH_VERSION_MINOR+"."+FLASH_VERSION_REVISION+" of the Adobe Flash Player installed<br/>to view the blinkx player.<br/><br/>You can download Adobe Flash Player <a alt=\"Download Adobe Flash Player\" href=\"http://get.adobe.com/flashplayer/\">here</a>.</td></tr></table>";
}

var replaceContentHtml = "<table width=\"100%\" height=\"100%\"><tr><td align=\"center\" style=\"background-color:white\">You must have the latest version of Adobe Flash Player installed<br/>to view the blinkx website properly.<br/><br/>You can download Adobe Flash Player <a alt=\"Download Adobe Flash Player\" href=\"http://get.adobe.com/flashplayer/\">here</a>.</td></tr></table>";
var replaceContentHtmlMinimal='<div style="width:100%;height:100%;background-color:white;background-image:url('+g_sStorePrefix+'/images/blinkx3/images/searchClearBtn.gif);background-position:center;background-repeat:no-repeat;"></div>';
function replaceContentWithFlashMessage(sID,message)
{
	var oObj=document.getElementById(sID);
	if(oObj)
	{
		if(!message) message=replaceContentHtml;
		oObj.innerHTML=message;
	}
}

function isFlashInstalled()
{
	if (navigator.mimeTypes.length > 0)
	{
		return navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin != null;
	}
	else if (window.ActiveXObject)
	{
		try
		{
			new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			return true;
		}
		catch(oError)
		{
			return false;
		}
	}
	else
	{
		//no way to detect!
		return false;
	}
}

//-------------- COOKIE SECTION ------------------------

function writeBiasCookie()
{
  var oBias = document.getElementById("bias");
  if(oBias)
  {
	var sCookieValue = oBias.value;

	var oExpires = new Date();
	offset = 1 / 1;
	oExpires.setYear(oExpires.getFullYear()+offset);

	writeCookie(sContextName+"bias",sCookieValue, oExpires, sPath);
  }
}

function writeFilterCookie()
{
  var oFilter = document.getElementById("filter");
  if(oFilter)
  {
	var sCookieValue = oFilter.value;

	var oExpires = new Date();
	offset = 1 / 1;
	oExpires.setYear(oExpires.getFullYear()+offset);

	writeCookie(sContextName+"filter",sCookieValue, oExpires, sPath);
  }
}

function readCookie(sName)
{
  var sRE = "(?:; )?" + sName + "=([^;]*);?";
  var oRE = new RegExp(sRE);

  if (oRE.test(document.cookie))
  {
	return decodeURIComponent(RegExp["$1"]);
  }
  else
  {
	return null;
  }
}

function writeCookie(sName, sValue, oExpires, sPath, sDomain, bSecure)
{
  var sCookie = sName + "=" + encodeURIComponent(sValue);

  if (oExpires)
  {
	sCookie += "; expires=" + oExpires.toGMTString();
  }

  if (sPath)
  {
	sCookie += "; path=" + sPath;
  }

  if (sDomain)
  {
	sCookie += "; domain=" + sDomain;
  }

  if (bSecure)
  {
	sCookie += "; secure";
  }

  document.cookie = sCookie;
}


function deleteCookie(sName, sPath, sDomain)
{
  var sCookie = sName + "=; expires=" + (new Date(0)).toGMTString();
  if (sPath)
  {
	sCookie += "; path=" + sPath;
  }
  if (sDomain)
  {
	sCookie += "; domain=" + sDomain;
  }
  document.cookie = sCookie;
}

function writeLocaleCookie(sLocale)
{
  var oExpires = new Date();
  offset = 1 / 1;
  oExpires.setYear(oExpires.getFullYear()+offset);

  writeCookie(sContextName+"Locale",sLocale, oExpires, sPath);
}

//-------------- COOKIE SECTION ------------------------



/*
/click/rss/20/PartnerId/
*/
function launchAVConsoleStoryInline(partnerid,edition,storyid)
{
	if (bbcV2Tst())
	{
		url = consoleURL(partnerid,edition) + "&nol_storyid=" + storyid;

		window.location = url;
	}
	else
	{
		self.location.href="http://news.bbc.co.uk/1/hi/help/3662494.stm";
	}
}


function launchAVConsoleStory(partnerid,edition,storyid)
{
	if (bbcV2Tst())
	{
		url = consoleURL(partnerid,edition) + "&nol_storyid=" + storyid;

clickmain=window.open(url,"console","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,width=681,height=487");
	}
	else
	{
		self.location.href="http://news.bbc.co.uk/1/hi/help/3662494.stm";
	}
}

function launchAVConsoleV3(partnerid,edition,section)
{
	if(bbcV2Tst())
	{
		url = consoleURL(partnerid,edition)

		if (section)
		{
			url += "&nol_index=" + section;
		}
		else if ((!section) && (edition == "sport"))
		{
			url = url.replace("fs.stm","fs_fp.stm");
		}

	clickmain=window.open(url,"console","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,width=681,height=487");
	}
	else
	{
		self.location.href="http://news.bbc.co.uk/1/hi/help/3662494.stm";
	}
}

function bbcV2Tst(){

	var type = getBrowserType();

	return (type  != "other" &&(type == "ie5" || type == "nav6" || type == "domCompliant"));
}

function getBrowserType()
{
	var myUserAgent;

	var myMajor;
	myUserAgent= navigator.userAgent.toLowerCase();
	myMajor= parseInt(navigator.appVersion);
	if( (myUserAgent.indexOf('mozilla')!= -1) &&(myUserAgent.indexOf('spoofer')== -1) &&(myUserAgent.indexOf('compatible') == -1) &&(myUserAgent.indexOf('opera') == -1) &&(myUserAgent.indexOf('webtv')  == -1) )
	{
		if (myMajor > 4 )
			{
				return "nav6";
			}
			else if ((myMajor == 4 ) || (myMajor == 5 ))
			{
				return "nav4";
			}
	}

	if (myUserAgent.indexOf("msie") == 4)
		{
			return "ie4";

	}
	else if (myUserAgent.indexOf("msie") == 5)
		{
			return "ie5";
		}
// dom compliant browsers are allowed
	if(document.body.firstChild)
	return "domCompliant";
	return "other";
}

function consoleURL(partnerid,edition)
{
	url = "http://www.bbc.co.uk";

	if (partnerid)
	{
		url += partnerid + "-";
	}

	if (edition == "sport")
	{
		url += "/mediaselector/check/sol/ukfs_sport/hi/av?redirect=fs.stm&news=1&nbram=1&nbwm=1";
	}
	else
	{
		url += "/mediaselector/check/nolavconsole/"+edition+"_news/hi?redirect=fs.stm&news=1&nbram=1&nbwm=1";
	}

	url += "&bbram=1&bbwm=1";

	return url;
}

function headerImageMouseOver(oDiv,sImageName)
{
	if(sImageName=="go") oDiv.className="go_hover";
	else if(sImageName=="wallit") oDiv.className="wallit_hover";
	oDiv.style.cursor='pointer';
}

function headerImageMouseOut(oDiv,sImageName)
{
	if(sImageName=="go") oDiv.className="go_normal";
	else if(sImageName=="wallit") oDiv.className="wallit_normal";
	oDiv.style.cursor='';
}

function headerImageMouseDown(oDiv,sImageName)
{
	if(sImageName=="go") oDiv.className="go_click";
	else if(sImageName=="wallit") oDiv.className="wallit_click";
}

function headerImageMouseUp(oDiv,sImageName)
{
	headerImageMouseOut(oDiv,sImageName);
}


/*Copyright (c) 2006, Yahoo! Inc. All rights reserved.Code licensed under the BSD License:http://developer.yahoo.net/yui/license.txtversion: 0.11.3*/
window.YAHOO=window.YAHOO||{};YAHOO.namespace=function(ns){if(!ns||!ns.length){return null;}var _2=ns.split(".");var _3=YAHOO;for(var i=(_2[0]=="YAHOO")?1:0;i<_2.length;++i){_3[_2[i]]=_3[_2[i]]||{};_3=_3[_2[i]];}return _3;};YAHOO.log=function(_5,_6,_7){var l=YAHOO.widget.Logger;if(l&&l.log){return l.log(_5,_6,_7);}else{return false;}};YAHOO.extend=function(_9,_10){var f=function(){};f.prototype=_10.prototype;_9.prototype=new f();_9.prototype.constructor=_9;_9.superclass=_10.prototype;if(_10.prototype.constructor==Object.prototype.constructor){_10.prototype.constructor=_10;}};YAHOO.namespace("util");YAHOO.namespace("widget");YAHOO.namespace("example");
/* Copyright (c) 2006, Yahoo! Inc. All rights reserved.  Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt Version: 0.11.3 */
YAHOO.util.CustomEvent=function(_1,_2,_3){this.type=_1;this.scope=_2||window;this.silent=_3;this.subscribers=[];if(!this.silent){}};YAHOO.util.CustomEvent.prototype={subscribe:function(fn,_5,_6){this.subscribers.push(new YAHOO.util.Subscriber(fn,_5,_6));},unsubscribe:function(fn,_7){var _8=false;for(var i=0,len=this.subscribers.length;i<len;++i){var s=this.subscribers[i];if(s&&s.contains(fn,_7)){this._delete(i);_8=true;}}return _8;},fire:function(){var len=this.subscribers.length;if(!len&&this.silent){return;}var _12=[];for(var i=0;i<arguments.length;++i){_12.push(arguments[i]);}if(!this.silent){}for(i=0;i<len;++i){var s=this.subscribers[i];if(s){if(!this.silent){}var _13=(s.override)?s.obj:this.scope;s.fn.call(_13,this.type,_12,s.obj);}}},unsubscribeAll:function(){for(var i=0,len=this.subscribers.length;i<len;++i){this._delete(len-1-i);}},_delete:function(_14){var s=this.subscribers[_14];if(s){delete s.fn;delete s.obj;}this.subscribers.splice(_14,1);},toString:function(){return "CustomEvent: "+"'"+this.type+"', "+"scope: "+this.scope;}};YAHOO.util.Subscriber=function(fn,obj,_16){this.fn=fn;this.obj=obj||null;this.override=(_16);};YAHOO.util.Subscriber.prototype.contains=function(fn,obj){return (this.fn==fn&&this.obj==obj);};YAHOO.util.Subscriber.prototype.toString=function(){return "Subscriber { obj: "+(this.obj||"")+", override: "+(this.override||"no")+" }";};if(!YAHOO.util.Event){YAHOO.util.Event=function(){var _17=false;var _18=[];var _19=[];var _20=[];var _21=[];var _22=[];var _23=0;var _24=[];var _25=[];var _26=0;return {POLL_RETRYS:200,POLL_INTERVAL:50,EL:0,TYPE:1,FN:2,WFN:3,SCOPE:3,ADJ_SCOPE:4,isSafari:(/Safari|Konqueror|KHTML/gi).test(navigator.userAgent),isIE:(!this.isSafari&&!navigator.userAgent.match(/opera/gi)&&navigator.userAgent.match(/msie/gi)),addDelayedListener:function(el,_28,fn,_29,_30){_19[_19.length]=[el,_28,fn,_29,_30];if(_17){_23=this.POLL_RETRYS;this.startTimeout(0);}},startTimeout:function(_31){var i=(_31||_31===0)?_31:this.POLL_INTERVAL;var _32=this;var _33=function(){_32._tryPreloadAttach();};this.timeout=setTimeout(_33,i);},onAvailable:function(_34,_35,_36,_37){_24.push({id:_34,fn:_35,obj:_36,override:_37});_23=this.POLL_RETRYS;this.startTimeout(0);},addListener:function(el,_38,fn,_39,_40){if(!fn||!fn.call){return false;}if(this._isValidCollection(el)){var ok=true;for(var i=0,len=el.length;i<len;++i){ok=(this.on(el[i],_38,fn,_39,_40)&&ok);}return ok;}else{if(typeof el=="string"){var oEl=this.getEl(el);if(_17&&oEl){el=oEl;}else{this.addDelayedListener(el,_38,fn,_39,_40);return true;}}}if(!el){return false;}if("unload"==_38&&_39!==this){_20[_20.length]=[el,_38,fn,_39,_40];return true;}var _43=(_40)?_39:el;var _44=function(e){return fn.call(_43,YAHOO.util.Event.getEvent(e),_39);};var li=[el,_38,fn,_44,_43];var _47=_18.length;_18[_47]=li;if(this.useLegacyEvent(el,_38)){var _48=this.getLegacyIndex(el,_38);if(_48==-1||el!=_21[_48][0]){_48=_21.length;_25[el.id+_38]=_48;_21[_48]=[el,_38,el["on"+_38]];_22[_48]=[];el["on"+_38]=function(e){YAHOO.util.Event.fireLegacyEvent(YAHOO.util.Event.getEvent(e),_48);};}_22[_48].push(_47);}else{if(el.addEventListener){el.addEventListener(_38,_44,false);}else{if(el.attachEvent){el.attachEvent("on"+_38,_44);}}}return true;},fireLegacyEvent:function(e,_49){var ok=true;var le=_22[_49];for(var i=0,len=le.length;i<len;++i){var _51=le[i];if(_51){var li=_18[_51];if(li&&li[this.WFN]){var _52=li[this.ADJ_SCOPE];var ret=li[this.WFN].call(_52,e);ok=(ok&&ret);}else{delete le[i];}}}return ok;},getLegacyIndex:function(el,_54){var key=this.generateId(el)+_54;if(typeof _25[key]=="undefined"){return -1;}else{return _25[key];}},useLegacyEvent:function(el,_56){if(!el.addEventListener&&!el.attachEvent){return true;}else{if(this.isSafari){if("click"==_56||"dblclick"==_56){return true;}}}return false;},removeListener:function(el,_57,fn,_58){if(!fn||!fn.call){return false;}if(typeof el=="string"){el=this.getEl(el);}else{if(this._isValidCollection(el)){var ok=true;for(var i=0,len=el.length;i<len;++i){ok=(this.removeListener(el[i],_57,fn)&&ok);}return ok;}}if("unload"==_57){for(i=0,len=_20.length;i<len;i++){var li=_20[i];if(li&&li[0]==el&&li[1]==_57&&li[2]==fn){_20.splice(i,1);return true;}}return false;}var _59=null;if("undefined"==typeof _58){_58=this._getCacheIndex(el,_57,fn);}if(_58>=0){_59=_18[_58];}if(!el||!_59){return false;}if(el.removeEventListener){el.removeEventListener(_57,_59[this.WFN],false);}else{if(el.detachEvent){el.detachEvent("on"+_57,_59[this.WFN]);}}delete _18[_58][this.WFN];delete _18[_58][this.FN];_18.splice(_58,1);return true;},getTarget:function(ev,_61){var t=ev.target||ev.srcElement;return this.resolveTextNode(t);},resolveTextNode:function(_63){if(_63&&_63.nodeName&&"#TEXT"==_63.nodeName.toUpperCase()){return _63.parentNode;}else{return _63;}},getPageX:function(ev){var x=ev.pageX;if(!x&&0!==x){x=ev.clientX||0;if(this.isIE){x+=this._getScrollLeft();}}return x;},getPageY:function(ev){var y=ev.pageY;if(!y&&0!==y){y=ev.clientY||0;if(this.isIE){y+=this._getScrollTop();}}return y;},getXY:function(ev){return [this.getPageX(ev),this.getPageY(ev)];},getRelatedTarget:function(ev){var t=ev.relatedTarget;if(!t){if(ev.type=="mouseout"){t=ev.toElement;}else{if(ev.type=="mouseover"){t=ev.fromElement;}}}return this.resolveTextNode(t);},getTime:function(ev){if(!ev.time){var t=new Date().getTime();try{ev.time=t;}catch(e){return t;}}return ev.time;},stopEvent:function(ev){this.stopPropagation(ev);this.preventDefault(ev);},stopPropagation:function(ev){if(ev.stopPropagation){ev.stopPropagation();}else{ev.cancelBubble=true;}},preventDefault:function(ev){if(ev.preventDefault){ev.preventDefault();}else{ev.returnValue=false;}},getEvent:function(e){var ev=e||window.event;if(!ev){var c=this.getEvent.caller;while(c){ev=c.arguments[0];if(ev&&Event==ev.constructor){break;}c=c.caller;}}return ev;},getCharCode:function(ev){return ev.charCode||((ev.type=="keypress")?ev.keyCode:0);},_getCacheIndex:function(el,_67,fn){for(var i=0,len=_18.length;i<len;++i){var li=_18[i];if(li&&li[this.FN]==fn&&li[this.EL]==el&&li[this.TYPE]==_67){return i;}}return -1;},generateId:function(el){var id=el.id;if(!id){id="yuievtautoid-"+_26;++_26;el.id=id;}return id;},_isValidCollection:function(o){return (o&&o.length&&typeof o!="string"&&!o.tagName&&!o.alert&&typeof o[0]!="undefined");},elCache:{},getEl:function(id){return document.getElementById(id);},clearCache:function(){},_load:function(e){_17=true;},_tryPreloadAttach:function(){if(this.locked){return false;}this.locked=true;var _70=!_17;if(!_70){_70=(_23>0);}var _71=[];for(var i=0,len=_19.length;i<len;++i){var d=_19[i];if(d){var el=this.getEl(d[this.EL]);if(el){this.on(el,d[this.TYPE],d[this.FN],d[this.SCOPE],d[this.ADJ_SCOPE]);delete _19[i];}else{_71.push(d);}}}_19=_71;var _73=[];for(i=0,len=_24.length;i<len;++i){var _74=_24[i];if(_74){el=this.getEl(_74.id);if(el){var _75=(_74.override)?_74.obj:el;_74.fn.call(_75,_74.obj);delete _24[i];}else{_73.push(_74);}}}_23=(_71.length===0&&_73.length===0)?0:_23-1;if(_70){this.startTimeout();}this.locked=false;return true;},purgeElement:function(el,_76,_77){var _78=this.getListeners(el,_77);if(_78){for(var i=0,len=_78.length;i<len;++i){var l=_78[i];this.removeListener(el,l.type,l.fn);}}if(_76&&el&&el.childNodes){for(i=0,len=el.childNodes.length;i<len;++i){this.purgeElement(el.childNodes[i],_76,_77);}}},getListeners:function(el,_80){var _81=[];if(_18&&_18.length>0){for(var i=0,len=_18.length;i<len;++i){var l=_18[i];if(l&&l[this.EL]===el&&(!_80||_80===l[this.TYPE])){_81.push({type:l[this.TYPE],fn:l[this.FN],obj:l[this.SCOPE],adjust:l[this.ADJ_SCOPE],index:i});}}}return (_81.length)?_81:null;},_unload:function(e,me){for(var i=0,len=_20.length;i<len;++i){var l=_20[i];if(l){var _83=(l[this.ADJ_SCOPE])?l[this.SCOPE]:window;l[this.FN].call(_83,this.getEvent(e),l[this.SCOPE]);}}if(_18&&_18.length>0){var j=_18.length;while(j){var _85=j-1;l=_18[_85];if(l){this.removeListener(l[this.EL],l[this.TYPE],l[this.FN],_85);}j=j-1;}this.clearCache();}for(i=0,len=_21.length;i<len;++i){delete _21[i][0];delete _21[i];}},_getScrollLeft:function(){return this._getScroll()[1];},_getScrollTop:function(){return this._getScroll()[0];},_getScroll:function(){var dd=document.documentElement,db=document.body;if(dd&&dd.scrollTop){return [dd.scrollTop,dd.scrollLeft];}else{if(db){return [db.scrollTop,db.scrollLeft];}else{return [0,0];}}}};}();YAHOO.util.Event.on=YAHOO.util.Event.addListener;if(document&&document.body){YAHOO.util.Event._load();}else{YAHOO.util.Event.on(window,"load",YAHOO.util.Event._load,YAHOO.util.Event,true);}YAHOO.util.Event.on(window,"unload",YAHOO.util.Event._unload,YAHOO.util.Event,true);YAHOO.util.Event._tryPreloadAttach();}
/* Copyright (c) 2006, Yahoo! Inc. All rights reserved.  Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt Version: 0.11.3 */
YAHOO.util.Dom=function(){var ua=navigator.userAgent.toLowerCase();var isOpera=(ua.indexOf('opera')>-1);var isSafari=(ua.indexOf('safari')>-1);var isIE=(window.ActiveXObject);var id_counter=0;var util=YAHOO.util;var property_cache={};var toCamel=function(property){var convert=function(prop){var test=/(-[a-z])/i.exec(prop);return prop.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());};while(property.indexOf('-')>-1){property=convert(property);}return property;};var toHyphen=function(property){if(property.indexOf('-')>-1){return property;}var converted='';for(var i=0,len=property.length;i<len;++i){if(property.charAt(i)==property.charAt(i).toUpperCase()){converted=converted+'-'+property.charAt(i).toLowerCase();}else{converted=converted+property.charAt(i);}}return converted;};var cacheConvertedProperties=function(property){property_cache[property]={camel:toCamel(property),hyphen:toHyphen(property)};};return{get:function(el){if(!el){return null;}if(typeof el!='string'&&!(el instanceof Array)){return el;}if(typeof el=='string'){return document.getElementById(el);}else{var collection=[];for(var i=0,len=el.length;i<len;++i){collection[collection.length]=util.Dom.get(el[i]);}return collection;}return null;},getStyle:function(el,property){var f=function(el){var value=null;var dv=document.defaultView;if(!property_cache[property]){cacheConvertedProperties(property);}var camel=property_cache[property]['camel'];var hyphen=property_cache[property]['hyphen'];if(property=='opacity'&&el.filters){value=1;try{value=el.filters.item('DXImageTransform.Microsoft.Alpha').opacity/100;}catch(e){try{value=el.filters.item('alpha').opacity/100;}catch(e){}}}else if(el.style[camel]){value=el.style[camel];}else if(isIE&&el.currentStyle&&el.currentStyle[camel]){value=el.currentStyle[camel];}else if(dv&&dv.getComputedStyle){var computed=dv.getComputedStyle(el,'');if(computed&&computed.getPropertyValue(hyphen)){value=computed.getPropertyValue(hyphen);}}return value;};return util.Dom.batch(el,f,util.Dom,true);},setStyle:function(el,property,val){if(!property_cache[property]){cacheConvertedProperties(property);}var camel=property_cache[property]['camel'];var f=function(el){switch(property){case'opacity':if(isIE&&typeof el.style.filter=='string'){el.style.filter='alpha(opacity='+val*100+')';if(!el.currentStyle||!el.currentStyle.hasLayout){el.style.zoom=1;}}else{el.style.opacity=val;el.style['-moz-opacity']=val;el.style['-khtml-opacity']=val;}break;default:el.style[camel]=val;}};util.Dom.batch(el,f,util.Dom,true);},getXY:function(el){var f=function(el){if(el.offsetParent===null||this.getStyle(el,'display')=='none'){return false;}var parentNode=null;var pos=[];var box;if(el.getBoundingClientRect){box=el.getBoundingClientRect();var doc=document;if(!this.inDocument(el)&&parent.document!=document){doc=parent.document;if(!this.isAncestor(doc.documentElement,el)){return false;}}var scrollTop=Math.max(doc.documentElement.scrollTop,doc.body.scrollTop);var scrollLeft=Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft);return[box.left+scrollLeft,box.top+scrollTop];}else{pos=[el.offsetLeft,el.offsetTop];parentNode=el.offsetParent;if(parentNode!=el){while(parentNode){pos[0]+=parentNode.offsetLeft;pos[1]+=parentNode.offsetTop;parentNode=parentNode.offsetParent;}}if(isSafari&&this.getStyle(el,'position')=='absolute'){pos[0]-=document.body.offsetLeft;pos[1]-=document.body.offsetTop;}}if(el.parentNode){parentNode=el.parentNode;}else{parentNode=null;}while(parentNode&&parentNode.tagName.toUpperCase()!='BODY'&&parentNode.tagName.toUpperCase()!='HTML'){if(util.Dom.getStyle(parentNode,'display')!='inline'){pos[0]-=parentNode.scrollLeft;pos[1]-=parentNode.scrollTop;}if(parentNode.parentNode){parentNode=parentNode.parentNode;}else{parentNode=null;}}return pos;};return util.Dom.batch(el,f,util.Dom,true);},getX:function(el){var f=function(el){return util.Dom.getXY(el)[0];};return util.Dom.batch(el,f,util.Dom,true);},getY:function(el){var f=function(el){return util.Dom.getXY(el)[1];};return util.Dom.batch(el,f,util.Dom,true);},setXY:function(el,pos,noRetry){var f=function(el){var style_pos=this.getStyle(el,'position');if(style_pos=='static'){this.setStyle(el,'position','relative');style_pos='relative';}var pageXY=this.getXY(el);if(pageXY===false){return false;}var delta=[parseInt(this.getStyle(el,'left'),10),parseInt(this.getStyle(el,'top'),10)];if(isNaN(delta[0])){delta[0]=(style_pos=='relative')?0:el.offsetLeft;}if(isNaN(delta[1])){delta[1]=(style_pos=='relative')?0:el.offsetTop;}if(pos[0]!==null){el.style.left=pos[0]-pageXY[0]+delta[0]+'px';}if(pos[1]!==null){el.style.top=pos[1]-pageXY[1]+delta[1]+'px';}var newXY=this.getXY(el);if(!noRetry&&(newXY[0]!=pos[0]||newXY[1]!=pos[1])){this.setXY(el,pos,true);}};util.Dom.batch(el,f,util.Dom,true);},setX:function(el,x){util.Dom.setXY(el,[x,null]);},setY:function(el,y){util.Dom.setXY(el,[null,y]);},getRegion:function(el){var f=function(el){var region=new YAHOO.util.Region.getRegion(el);return region;};return util.Dom.batch(el,f,util.Dom,true);},getClientWidth:function(){return util.Dom.getViewportWidth();},getClientHeight:function(){return util.Dom.getViewportHeight();},getElementsByClassName:function(className,tag,root){var method=function(el){return util.Dom.hasClass(el,className)};return util.Dom.getElementsBy(method,tag,root);},hasClass:function(el,className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)');var f=function(el){return re.test(el['className']);};return util.Dom.batch(el,f,util.Dom,true);},addClass:function(el,className){var f=function(el){if(this.hasClass(el,className)){return;}el['className']=[el['className'],className].join(' ');};util.Dom.batch(el,f,util.Dom,true);},removeClass:function(el,className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)','g');var f=function(el){if(!this.hasClass(el,className)){return;}var c=el['className'];el['className']=c.replace(re,' ');if(this.hasClass(el,className)){this.removeClass(el,className);}};util.Dom.batch(el,f,util.Dom,true);},replaceClass:function(el,oldClassName,newClassName){if(oldClassName===newClassName){return false;};var re=new RegExp('(?:^|\\s+)'+oldClassName+'(?:\\s+|$)','g');var f=function(el){if(!this.hasClass(el,oldClassName)){this.addClass(el,newClassName);return;}el['className']=el['className'].replace(re,' '+newClassName+' ');if(this.hasClass(el,oldClassName)){this.replaceClass(el,oldClassName,newClassName);}};util.Dom.batch(el,f,util.Dom,true);},generateId:function(el,prefix){prefix=prefix||'yui-gen';el=el||{};var f=function(el){if(el){el=util.Dom.get(el);}else{el={};}if(!el.id){el.id=prefix+id_counter++;}return el.id;};return util.Dom.batch(el,f,util.Dom,true);},isAncestor:function(haystack,needle){haystack=util.Dom.get(haystack);if(!haystack||!needle){return false;}var f=function(needle){if(haystack.contains&&!isSafari){return haystack.contains(needle);}else if(haystack.compareDocumentPosition){return!!(haystack.compareDocumentPosition(needle)&16);}else{var parent=needle.parentNode;while(parent){if(parent==haystack){return true;}else if(!parent.tagName||parent.tagName.toUpperCase()=='HTML'){return false;}parent=parent.parentNode;}return false;}};return util.Dom.batch(needle,f,util.Dom,true);},inDocument:function(el){var f=function(el){return this.isAncestor(document.documentElement,el);};return util.Dom.batch(el,f,util.Dom,true);},getElementsBy:function(method,tag,root){tag=tag||'*';root=util.Dom.get(root)||document;var nodes=[];var elements=root.getElementsByTagName(tag);if(!elements.length&&(tag=='*'&&root.all)){elements=root.all;}for(var i=0,len=elements.length;i<len;++i){if(method(elements[i])){nodes[nodes.length]=elements[i];}}return nodes;},batch:function(el,method,o,override){var id=el;el=util.Dom.get(el);var scope=(override)?o:window;if(!el||el.tagName||!el.length){if(!el){return false;}return method.call(scope,el,o);}var collection=[];for(var i=0,len=el.length;i<len;++i){if(!el[i]){id=id[i];}collection[collection.length]=method.call(scope,el[i],o);}return collection;},getDocumentHeight:function(){var scrollHeight=-1,windowHeight=-1,bodyHeight=-1;var marginTop=parseInt(util.Dom.getStyle(document.body,'marginTop'),10);var marginBottom=parseInt(util.Dom.getStyle(document.body,'marginBottom'),10);var mode=document.compatMode;if((mode||isIE)&&!isOpera){switch(mode){case'CSS1Compat':scrollHeight=((window.innerHeight&&window.scrollMaxY)?window.innerHeight+window.scrollMaxY:-1);windowHeight=[document.documentElement.clientHeight,self.innerHeight||-1].sort(function(a,b){return(a-b);})[1];bodyHeight=document.body.offsetHeight+marginTop+marginBottom;break;default:scrollHeight=document.body.scrollHeight;bodyHeight=document.body.clientHeight;}}else{scrollHeight=document.documentElement.scrollHeight;windowHeight=self.innerHeight;bodyHeight=document.documentElement.clientHeight;}var h=[scrollHeight,windowHeight,bodyHeight].sort(function(a,b){return(a-b);});return h[2];},getDocumentWidth:function(){var docWidth=-1,bodyWidth=-1,winWidth=-1;var marginRight=parseInt(util.Dom.getStyle(document.body,'marginRight'),10);var marginLeft=parseInt(util.Dom.getStyle(document.body,'marginLeft'),10);var mode=document.compatMode;if(mode||isIE){switch(mode){case'CSS1Compat':docWidth=document.documentElement.clientWidth;bodyWidth=document.body.offsetWidth+marginLeft+marginRight;break;default:bodyWidth=document.body.clientWidth;docWidth=document.body.scrollWidth;break;}}else{docWidth=document.documentElement.clientWidth;bodyWidth=document.body.offsetWidth+marginLeft+marginRight;}var w=Math.max(docWidth,bodyWidth);return w;},getViewportHeight:function(){var height=-1;var mode=document.compatMode;if((mode||isIE)&&!isOpera){switch(mode){case'CSS1Compat':height=document.documentElement.clientHeight;break;default:height=document.body.clientHeight;}}else{height=self.innerHeight;}return height;},getViewportWidth:function(){var width=-1;var mode=document.compatMode;if(mode||isIE){switch(mode){case'CSS1Compat':width=document.documentElement.clientWidth;break;default:width=document.body.clientWidth;}}else{width=self.innerWidth;}return width;}};}();YAHOO.util.Region=function(t,r,b,l){this.top=t;this[1]=t;this.right=r;this.bottom=b;this.left=l;this[0]=l;};YAHOO.util.Region.prototype.contains=function(region){return(region.left>=this.left&&region.right<=this.right&&region.top>=this.top&&region.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new YAHOO.util.Region(t,r,b,l);}else{return null;}};YAHOO.util.Region.prototype.union=function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};YAHOO.util.Region.getRegion=function(el){var p=YAHOO.util.Dom.getXY(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Point=function(x,y){if(x instanceof Array){y=x[1];x=x[0];}this.x=this.right=this.left=this[0]=x;this.y=this.top=this.bottom=this[1]=y;};YAHOO.util.Point.prototype=new YAHOO.util.Region();
/* Copyright (c) 2006, Yahoo! Inc. All rights reserved.  Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt Version: 0.11.3 */
YAHOO.util.DragDrop=function(id,_2,_3){if(id){this.init(id,_2,_3);}};YAHOO.util.DragDrop.prototype={id:null,config:null,dragElId:null,handleElId:null,invalidHandleTypes:null,invalidHandleIds:null,invalidHandleClasses:null,startPageX:0,startPageY:0,groups:null,locked:false,lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isTarget:true,padding:null,_domRef:null,__ygDragDrop:true,constrainX:false,constrainY:false,minX:0,maxX:0,minY:0,maxY:0,maintainOffset:false,xTicks:null,yTicks:null,primaryButtonOnly:true,available:false,b4StartDrag:function(x,y){},startDrag:function(x,y){},b4Drag:function(e){},onDrag:function(e){},onDragEnter:function(e,id){},b4DragOver:function(e){},onDragOver:function(e,id){},b4DragOut:function(e){},onDragOut:function(e,id){},b4DragDrop:function(e){},onDragDrop:function(e,id){},b4EndDrag:function(e){},endDrag:function(e){},b4MouseDown:function(e){},onMouseDown:function(e){},onMouseUp:function(e){},onAvailable:function(){},getEl:function(){if(!this._domRef){this._domRef=YAHOO.util.Dom.get(this.id);}return this._domRef;},getDragEl:function(){return YAHOO.util.Dom.get(this.dragElId);},init:function(id,_7,_8){this.initTarget(id,_7,_8);YAHOO.util.Event.addListener(this.id,"mousedown",this.handleMouseDown,this,true);},initTarget:function(id,_9,_10){this.config=_10||{};this.DDM=YAHOO.util.DDM;this.groups={};this.id=id;this.addToGroup((_9)?_9:"default");this.handleElId=id;YAHOO.util.Event.onAvailable(id,this.handleOnAvailable,this,true);this.setDragElId(id);this.invalidHandleTypes={A:"A"};this.invalidHandleIds={};this.invalidHandleClasses=[];this.applyConfig();},applyConfig:function(){this.padding=this.config.padding||[0,0,0,0];this.isTarget=(this.config.isTarget!==false);this.maintainOffset=(this.config.maintainOffset);this.primaryButtonOnly=(this.config.primaryButtonOnly!==false);},handleOnAvailable:function(){this.available=true;this.resetConstraints();this.onAvailable();},setPadding:function(_11,_12,_13,_14){if(!_12&&0!==_12){this.padding=[_11,_11,_11,_11];}else{if(!_13&&0!==_13){this.padding=[_11,_12,_11,_12];}else{this.padding=[_11,_12,_13,_14];}}},setInitPosition:function(_15,_16){var el=this.getEl();if(!this.DDM.verifyEl(el)){return;}var dx=_15||0;var dy=_16||0;var p=YAHOO.util.Dom.getXY(el);this.initPageX=p[0]-dx;this.initPageY=p[1]-dy;this.lastPageX=p[0];this.lastPageY=p[1];this.setStartPosition(p);},setStartPosition:function(pos){var p=pos||YAHOO.util.Dom.getXY(this.getEl());this.deltaSetXY=null;this.startPageX=p[0];this.startPageY=p[1];},addToGroup:function(_22){this.groups[_22]=true;this.DDM.regDragDrop(this,_22);},removeFromGroup:function(_23){if(this.groups[_23]){delete this.groups[_23];}this.DDM.removeDDFromGroup(this,_23);},setDragElId:function(id){this.dragElId=id;},setHandleElId:function(id){this.handleElId=id;this.DDM.regHandle(this.id,id);},setOuterHandleElId:function(id){YAHOO.util.Event.addListener(id,"mousedown",this.handleMouseDown,this,true);this.setHandleElId(id);},unreg:function(){YAHOO.util.Event.removeListener(this.id,"mousedown",this.handleMouseDown);this._domRef=null;this.DDM._remove(this);},isLocked:function(){return (this.DDM.isLocked()||this.locked);},handleMouseDown:function(e,oDD){var EU=YAHOO.util.Event;var _26=e.which||e.button;if(this.primaryButtonOnly&&_26>1){return;}if(this.isLocked()){return;}this.DDM.refreshCache(this.groups);var pt=new YAHOO.util.Point(EU.getPageX(e),EU.getPageY(e));if(this.DDM.isOverTarget(pt,this)){var _28=EU.getTarget(e);if(this.isValidHandleChild(_28)&&(this.id==this.handleElId||this.DDM.handleWasClicked(_28,this.id))){this.setStartPosition();this.b4MouseDown(e);this.onMouseDown(e);this.DDM.handleMouseDown(e,this);this.DDM.stopEvent(e);}}},addInvalidHandleType:function(_29){var _30=_29.toUpperCase();this.invalidHandleTypes[_30]=_30;},addInvalidHandleId:function(id){this.invalidHandleIds[id]=id;},addInvalidHandleClass:function(_31){this.invalidHandleClasses.push(_31);},removeInvalidHandleType:function(_32){var _33=_32.toUpperCase();delete this.invalidHandleTypes[_33];},removeInvalidHandleId:function(id){delete this.invalidHandleIds[id];},removeInvalidHandleClass:function(_34){for(var i=0,len=this.invalidHandleClasses.length;i<len;++i){if(this.invalidHandleClasses[i]==_34){delete this.invalidHandleClasses[i];}}},isValidHandleChild:function(_36){var _37=true;var _38;try{_38=_36.nodeName.toUpperCase();}catch(e){_38=_36.nodeName;}_37=_37&&!this.invalidHandleTypes[_38];_37=_37&&!this.invalidHandleIds[_36.id];for(var i=0,len=this.invalidHandleClasses.length;_37&&i<len;++i){_37=!YAHOO.util.Dom.hasClass(_36,this.invalidHandleClasses[i]);}return _37;},setXTicks:function(_39,_40){this.xTicks=[];this.xTickSize=_40;var _41={};for(var i=this.initPageX;i>=this.minX;i=i-_40){if(!_41[i]){this.xTicks[this.xTicks.length]=i;_41[i]=true;}}for(i=this.initPageX;i<=this.maxX;i=i+_40){if(!_41[i]){this.xTicks[this.xTicks.length]=i;_41[i]=true;}}this.xTicks.sort(this.DDM.numericSort);},setYTicks:function(_42,_43){this.yTicks=[];this.yTickSize=_43;var _44={};for(var i=this.initPageY;i>=this.minY;i=i-_43){if(!_44[i]){this.yTicks[this.yTicks.length]=i;_44[i]=true;}}for(i=this.initPageY;i<=this.maxY;i=i+_43){if(!_44[i]){this.yTicks[this.yTicks.length]=i;_44[i]=true;}}this.yTicks.sort(this.DDM.numericSort);},setXConstraint:function(_45,_46,_47){this.leftConstraint=_45;this.rightConstraint=_46;this.minX=this.initPageX-_45;this.maxX=this.initPageX+_46;if(_47){this.setXTicks(this.initPageX,_47);}this.constrainX=true;},clearConstraints:function(){this.constrainX=false;this.constrainY=false;this.clearTicks();},clearTicks:function(){this.xTicks=null;this.yTicks=null;this.xTickSize=0;this.yTickSize=0;},setYConstraint:function(iUp,_49,_50){this.topConstraint=iUp;this.bottomConstraint=_49;this.minY=this.initPageY-iUp;this.maxY=this.initPageY+_49;if(_50){this.setYTicks(this.initPageY,_50);}this.constrainY=true;},resetConstraints:function(){if(this.initPageX||this.initPageX===0){var dx=(this.maintainOffset)?this.lastPageX-this.initPageX:0;var dy=(this.maintainOffset)?this.lastPageY-this.initPageY:0;this.setInitPosition(dx,dy);}else{this.setInitPosition();}if(this.constrainX){this.setXConstraint(this.leftConstraint,this.rightConstraint,this.xTickSize);}if(this.constrainY){this.setYConstraint(this.topConstraint,this.bottomConstraint,this.yTickSize);}},getTick:function(val,_52){if(!_52){return val;}else{if(_52[0]>=val){return _52[0];}else{for(var i=0,len=_52.length;i<len;++i){var _53=i+1;if(_52[_53]&&_52[_53]>=val){var _54=val-_52[i];var _55=_52[_53]-val;return (_55>_54)?_52[i]:_52[_53];}}return _52[_52.length-1];}}},toString:function(){return ("DragDrop "+this.id);}};if(!YAHOO.util.DragDropMgr){YAHOO.util.DragDropMgr=new function(){this.ids={};this.handleIds={};this.dragCurrent=null;this.dragOvers={};this.deltaX=0;this.deltaY=0;this.preventDefault=true;this.stopPropagation=true;this.initalized=false;this.locked=false;this.init=function(){this.initialized=true;};this.POINT=0;this.INTERSECT=1;this.mode=this.POINT;this._execOnAll=function(_56,_57){for(var i in this.ids){for(var j in this.ids[i]){var oDD=this.ids[i][j];if(!this.isTypeOfDD(oDD)){continue;}oDD[_56].apply(oDD,_57);}}};this._onLoad=function(){this.init();var EU=YAHOO.util.Event;EU.on(document,"mouseup",this.handleMouseUp,this,true);EU.on(document,"mousemove",this.handleMouseMove,this,true);EU.on(window,"unload",this._onUnload,this,true);EU.on(window,"resize",this._onResize,this,true);};this._onResize=function(e){this._execOnAll("resetConstraints",[]);};this.lock=function(){this.locked=true;};this.unlock=function(){this.locked=false;};this.isLocked=function(){return this.locked;};this.locationCache={};this.useCache=true;this.clickPixelThresh=3;this.clickTimeThresh=1000;this.dragThreshMet=false;this.clickTimeout=null;this.startX=0;this.startY=0;this.regDragDrop=function(oDD,_59){if(!this.initialized){this.init();}if(!this.ids[_59]){this.ids[_59]={};}this.ids[_59][oDD.id]=oDD;};this.removeDDFromGroup=function(oDD,_60){if(!this.ids[_60]){this.ids[_60]={};}var obj=this.ids[_60];if(obj&&obj[oDD.id]){delete obj[oDD.id];}};this._remove=function(oDD){for(var g in oDD.groups){if(g&&this.ids[g][oDD.id]){delete this.ids[g][oDD.id];}}delete this.handleIds[oDD.id];};this.regHandle=function(_63,_64){if(!this.handleIds[_63]){this.handleIds[_63]={};}this.handleIds[_63][_64]=_64;};this.isDragDrop=function(id){return (this.getDDById(id))?true:false;};this.getRelated=function(_65,_66){var _67=[];for(var i in _65.groups){for(j in this.ids[i]){var dd=this.ids[i][j];if(!this.isTypeOfDD(dd)){continue;}if(!_66||dd.isTarget){_67[_67.length]=dd;}}}return _67;};this.isLegalTarget=function(oDD,_69){var _70=this.getRelated(oDD,true);for(var i=0,len=_70.length;i<len;++i){if(_70[i].id==_69.id){return true;}}return false;};this.isTypeOfDD=function(oDD){return (oDD&&oDD.__ygDragDrop);};this.isHandle=function(_71,_72){return (this.handleIds[_71]&&this.handleIds[_71][_72]);};this.getDDById=function(id){for(var i in this.ids){if(this.ids[i][id]){return this.ids[i][id];}}return null;};this.handleMouseDown=function(e,oDD){this.currentTarget=YAHOO.util.Event.getTarget(e);this.dragCurrent=oDD;var el=oDD.getEl();this.startX=YAHOO.util.Event.getPageX(e);this.startY=YAHOO.util.Event.getPageY(e);this.deltaX=this.startX-el.offsetLeft;this.deltaY=this.startY-el.offsetTop;this.dragThreshMet=false;this.clickTimeout=setTimeout(function(){var DDM=YAHOO.util.DDM;DDM.startDrag(DDM.startX,DDM.startY);},this.clickTimeThresh);};this.startDrag=function(x,y){clearTimeout(this.clickTimeout);if(this.dragCurrent){this.dragCurrent.b4StartDrag(x,y);this.dragCurrent.startDrag(x,y);}this.dragThreshMet=true;};this.handleMouseUp=function(e){if(!this.dragCurrent){return;}clearTimeout(this.clickTimeout);if(this.dragThreshMet){this.fireEvents(e,true);}else{}this.stopDrag(e);this.stopEvent(e);};this.stopEvent=function(e){if(this.stopPropagation){YAHOO.util.Event.stopPropagation(e);}if(this.preventDefault){YAHOO.util.Event.preventDefault(e);}};this.stopDrag=function(e){if(this.dragCurrent){if(this.dragThreshMet){this.dragCurrent.b4EndDrag(e);this.dragCurrent.endDrag(e);}this.dragCurrent.onMouseUp(e);}this.dragCurrent=null;this.dragOvers={};};this.handleMouseMove=function(e){if(!this.dragCurrent){return true;}if(YAHOO.util.Event.isIE&&!e.button){this.stopEvent(e);return this.handleMouseUp(e);}if(!this.dragThreshMet){var _74=Math.abs(this.startX-YAHOO.util.Event.getPageX(e));var _75=Math.abs(this.startY-YAHOO.util.Event.getPageY(e));if(_74>this.clickPixelThresh||_75>this.clickPixelThresh){this.startDrag(this.startX,this.startY);}}if(this.dragThreshMet){this.dragCurrent.b4Drag(e);this.dragCurrent.onDrag(e);this.fireEvents(e,false);}this.stopEvent(e);return true;};this.fireEvents=function(e,_76){var dc=this.dragCurrent;if(!dc||dc.isLocked()){return;}var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);var pt=new YAHOO.util.Point(x,y);var _78=[];var _79=[];var _80=[];var _81=[];var _82=[];for(var i in this.dragOvers){var ddo=this.dragOvers[i];if(!this.isTypeOfDD(ddo)){continue;}if(!this.isOverTarget(pt,ddo,this.mode)){_79.push(ddo);}_78[i]=true;delete this.dragOvers[i];}for(var _84 in dc.groups){if("string"!=typeof _84){continue;}for(i in this.ids[_84]){var oDD=this.ids[_84][i];if(!this.isTypeOfDD(oDD)){continue;}if(oDD.isTarget&&!oDD.isLocked()&&oDD!=dc){if(this.isOverTarget(pt,oDD,this.mode)){if(_76){_81.push(oDD);}else{if(!_78[oDD.id]){_82.push(oDD);}else{_80.push(oDD);}this.dragOvers[oDD.id]=oDD;}}}}}if(this.mode){if(_79.length){dc.b4DragOut(e,_79);dc.onDragOut(e,_79);}if(_82.length){dc.onDragEnter(e,_82);}if(_80.length){dc.b4DragOver(e,_80);dc.onDragOver(e,_80);}if(_81.length){dc.b4DragDrop(e,_81);dc.onDragDrop(e,_81);}}else{var len=0;for(i=0,len=_79.length;i<len;++i){dc.b4DragOut(e,_79[i].id);dc.onDragOut(e,_79[i].id);}for(i=0,len=_82.length;i<len;++i){dc.onDragEnter(e,_82[i].id);}for(i=0,len=_80.length;i<len;++i){dc.b4DragOver(e,_80[i].id);dc.onDragOver(e,_80[i].id);}for(i=0,len=_81.length;i<len;++i){dc.b4DragDrop(e,_81[i].id);dc.onDragDrop(e,_81[i].id);}}};this.getBestMatch=function(dds){var _87=null;var len=dds.length;if(len==1){_87=dds[0];}else{for(var i=0;i<len;++i){var dd=dds[i];if(dd.cursorIsOver){_87=dd;break;}else{if(!_87||_87.overlap.getArea()<dd.overlap.getArea()){_87=dd;}}}}return _87;};this.refreshCache=function(_88){for(sGroup in _88){if("string"!=typeof sGroup){continue;}for(i in this.ids[sGroup]){var oDD=this.ids[sGroup][i];if(this.isTypeOfDD(oDD)){var loc=this.getLocation(oDD);if(loc){this.locationCache[oDD.id]=loc;}else{delete this.locationCache[oDD.id];}}}}};this.verifyEl=function(el){try{if(el){var _90=el.offsetParent;if(_90){return true;}}}catch(e){}return false;};this.getLocation=function(oDD){if(!this.isTypeOfDD(oDD)){return null;}var el=oDD.getEl();var _91=null;try{_91=YAHOO.util.Dom.getXY(el);}catch(e){}if(!_91){return null;}x1=_91[0];x2=x1+el.offsetWidth;y1=_91[1];y2=y1+el.offsetHeight;var t=y1-oDD.padding[0];var r=x2+oDD.padding[1];var b=y2+oDD.padding[2];var l=x1-oDD.padding[3];return new YAHOO.util.Region(t,r,b,l);};this.isOverTarget=function(pt,_96,_97){var loc=this.locationCache[_96.id];if(!loc||!this.useCache){loc=this.getLocation(_96);this.locationCache[_96.id]=loc;}if(!loc){return false;}_96.cursorIsOver=loc.contains(pt);var dc=this.dragCurrent;if(!dc||!dc.getTargetCoord||(!_97&&!dc.constrainX&&!dc.constrainY)){return _96.cursorIsOver;}_96.overlap=null;var pos=dc.getTargetCoord(pt.x,pt.y);var el=dc.getDragEl();var _98=new YAHOO.util.Region(pos.y,pos.x+el.offsetWidth,pos.y+el.offsetHeight,pos.x);var _99=_98.intersect(loc);if(_99){_96.overlap=_99;return (_97)?true:_96.cursorIsOver;}else{return false;}};this._onUnload=function(e,me){this.unregAll();};this.unregAll=function(){if(this.dragCurrent){this.stopDrag();this.dragCurrent=null;}this._execOnAll("unreg",[]);for(i in this.elementCache){delete this.elementCache[i];}this.elementCache={};this.ids={};};this.elementCache={};this.getElWrapper=function(id){var _101=this.elementCache[id];if(!_101||!_101.el){_101=this.elementCache[id]=new this.ElementWrapper(YAHOO.util.Dom.get(id));}return _101;};this.getElement=function(id){return YAHOO.util.Dom.get(id);};this.getCss=function(id){var el=YAHOO.util.Dom.get(id);return (el)?el.style:null;};this.ElementWrapper=function(el){this.el=el||null;this.id=this.el&&el.id;this.css=this.el&&el.style;};this.getPosX=function(el){return YAHOO.util.Dom.getX(el);};this.getPosY=function(el){return YAHOO.util.Dom.getY(el);};this.swapNode=function(n1,n2){if(n1.swapNode){n1.swapNode(n2);}else{var p=n2.parentNode;var s=n2.nextSibling;n1.parentNode.replaceChild(n2,n1);p.insertBefore(n1,s);}};this.getScroll=function(){var t,l;if(document.documentElement&&document.documentElement.scrollTop){t=document.documentElement.scrollTop;l=document.documentElement.scrollLeft;}else{if(document.body){t=document.body.scrollTop;l=document.body.scrollLeft;}}return {top:t,left:l};};this.getStyle=function(el,_105){return YAHOO.util.Dom.getStyle(el,_105);};this.getScrollTop=function(){return this.getScroll().top;};this.getScrollLeft=function(){return this.getScroll().left;};this.moveToEl=function(_106,_107){var _108=YAHOO.util.Dom.getXY(_107);YAHOO.util.Dom.setXY(_106,_108);};this.getClientHeight=function(){return YAHOO.util.Dom.getClientHeight();};this.getClientWidth=function(){return YAHOO.util.Dom.getClientWidth();};this.numericSort=function(a,b){return (a-b);};this._timeoutCount=0;this._addListeners=function(){if(YAHOO.util.Event&&document){this._onLoad();}else{if(this._timeoutCount>1000){}else{var DDM=YAHOO.util.DDM;setTimeout(function(){DDM._addListeners();},10);if(document&&document.body){this._timeoutCount+=1;}}}};this.handleWasClicked=function(node,id){if(this.isHandle(id,node.id)){return true;}else{var p=node.parentNode;while(p){if(this.isHandle(id,p.id)){return true;}else{p=p.parentNode;}}}return false;};}();YAHOO.util.DDM=YAHOO.util.DragDropMgr;YAHOO.util.DDM._addListeners();}YAHOO.util.DD=function(id,_111,_112){if(id){this.init(id,_111,_112);}};YAHOO.extend(YAHOO.util.DD,YAHOO.util.DragDrop);YAHOO.util.DD.prototype.scroll=true;YAHOO.util.DD.prototype.autoOffset=function(_113,_114){var x=_113-this.startPageX;var y=_114-this.startPageY;this.setDelta(x,y);};YAHOO.util.DD.prototype.setDelta=function(_115,_116){this.deltaX=_115;this.deltaY=_116;};YAHOO.util.DD.prototype.setDragElPos=function(_117,_118){var el=this.getDragEl();this.alignElWithMouse(el,_117,_118);};YAHOO.util.DD.prototype.alignElWithMouse=function(el,_119,_120){var _121=this.getTargetCoord(_119,_120);if(!this.deltaSetXY){var _122=[_121.x,_121.y];YAHOO.util.Dom.setXY(el,_122);var _123=parseInt(YAHOO.util.Dom.getStyle(el,"left"),10);var _124=parseInt(YAHOO.util.Dom.getStyle(el,"top"),10);this.deltaSetXY=[_123-_121.x,_124-_121.y];}else{YAHOO.util.Dom.setStyle(el,"left",(_121.x+this.deltaSetXY[0])+"px");YAHOO.util.Dom.setStyle(el,"top",(_121.y+this.deltaSetXY[1])+"px");}this.cachePosition(_121.x,_121.y);this.autoScroll(_121.x,_121.y,el.offsetHeight,el.offsetWidth);};YAHOO.util.DD.prototype.cachePosition=function(_125,_126){if(_125){this.lastPageX=_125;this.lastPageY=_126;}else{var _127=YAHOO.util.Dom.getXY(this.getEl());this.lastPageX=_127[0];this.lastPageY=_127[1];}};YAHOO.util.DD.prototype.autoScroll=function(x,y,h,w){if(this.scroll){var _130=this.DDM.getClientHeight();var _131=this.DDM.getClientWidth();var st=this.DDM.getScrollTop();var sl=this.DDM.getScrollLeft();var bot=h+y;var _135=w+x;var _136=(_130+st-y-this.deltaY);var _137=(_131+sl-x-this.deltaX);var _138=40;var _139=(document.all)?80:30;if(bot>_130&&_136<_138){window.scrollTo(sl,st+_139);}if(y<st&&st>0&&y-st<_138){window.scrollTo(sl,st-_139);}if(_135>_131&&_137<_138){window.scrollTo(sl+_139,st);}if(x<sl&&sl>0&&x-sl<_138){window.scrollTo(sl-_139,st);}}};YAHOO.util.DD.prototype.getTargetCoord=function(_140,_141){var x=_140-this.deltaX;var y=_141-this.deltaY;if(this.constrainX){if(x<this.minX){x=this.minX;}if(x>this.maxX){x=this.maxX;}}if(this.constrainY){if(y<this.minY){y=this.minY;}if(y>this.maxY){y=this.maxY;}}x=this.getTick(x,this.xTicks);y=this.getTick(y,this.yTicks);return {x:x,y:y};};YAHOO.util.DD.prototype.applyConfig=function(){YAHOO.util.DD.superclass.applyConfig.call(this);this.scroll=(this.config.scroll!==false);};YAHOO.util.DD.prototype.b4MouseDown=function(e){this.autoOffset(YAHOO.util.Event.getPageX(e),YAHOO.util.Event.getPageY(e));};YAHOO.util.DD.prototype.b4Drag=function(e){this.setDragElPos(YAHOO.util.Event.getPageX(e),YAHOO.util.Event.getPageY(e));};YAHOO.util.DD.prototype.toString=function(){return ("DD "+this.id);};YAHOO.util.DDProxy=function(id,_142,_143){if(id){this.init(id,_142,_143);this.initFrame();}};YAHOO.extend(YAHOO.util.DDProxy,YAHOO.util.DD);YAHOO.util.DDProxy.dragElId="ygddfdiv";YAHOO.util.DDProxy.prototype.resizeFrame=true;YAHOO.util.DDProxy.prototype.centerFrame=false;YAHOO.util.DDProxy.prototype.createFrame=function(){var self=this;var body=document.body;if(!body||!body.firstChild){setTimeout(function(){self.createFrame();},50);return;}var div=this.getDragEl();if(!div){div=document.createElement("div");div.id=this.dragElId;var s=div.style;s.position="absolute";s.visibility="hidden";s.cursor="move";s.border="2px solid #aaa";s.zIndex=999;body.insertBefore(div,body.firstChild);}};YAHOO.util.DDProxy.prototype.initFrame=function(){this.createFrame();};YAHOO.util.DDProxy.prototype.applyConfig=function(){YAHOO.util.DDProxy.superclass.applyConfig.call(this);this.resizeFrame=(this.config.resizeFrame!==false);this.centerFrame=(this.config.centerFrame);this.setDragElId(this.config.dragElId||YAHOO.util.DDProxy.dragElId);};YAHOO.util.DDProxy.prototype.showFrame=function(_147,_148){var el=this.getEl();var _149=this.getDragEl();var s=_149.style;this._resizeProxy();if(this.centerFrame){this.setDelta(Math.round(parseInt(s.width,10)/2),Math.round(parseInt(s.height,10)/2));}this.setDragElPos(_147,_148);YAHOO.util.Dom.setStyle(_149,"visibility","visible");};YAHOO.util.DDProxy.prototype._resizeProxy=function(){if(this.resizeFrame){var DOM=YAHOO.util.Dom;var el=this.getEl();var _151=this.getDragEl();var bt=parseInt(DOM.getStyle(_151,"borderTopWidth"),10);var br=parseInt(DOM.getStyle(_151,"borderRightWidth"),10);var bb=parseInt(DOM.getStyle(_151,"borderBottomWidth"),10);var bl=parseInt(DOM.getStyle(_151,"borderLeftWidth"),10);if(isNaN(bt)){bt=0;}if(isNaN(br)){br=0;}if(isNaN(bb)){bb=0;}if(isNaN(bl)){bl=0;}var _156=Math.max(0,el.offsetWidth-br-bl);var _157=Math.max(0,el.offsetHeight-bt-bb);DOM.setStyle(_151,"width",_156+"px");DOM.setStyle(_151,"height",_157+"px");}};YAHOO.util.DDProxy.prototype.b4MouseDown=function(e){var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);this.autoOffset(x,y);this.setDragElPos(x,y);};YAHOO.util.DDProxy.prototype.b4StartDrag=function(x,y){this.showFrame(x,y);};YAHOO.util.DDProxy.prototype.b4EndDrag=function(e){YAHOO.util.Dom.setStyle(this.getDragEl(),"visibility","hidden");};YAHOO.util.DDProxy.prototype.endDrag=function(e){var DOM=YAHOO.util.Dom;var lel=this.getEl();var del=this.getDragEl();DOM.setStyle(del,"visibility","");DOM.setStyle(lel,"visibility","hidden");YAHOO.util.DDM.moveToEl(lel,del);DOM.setStyle(del,"visibility","hidden");DOM.setStyle(lel,"visibility","");};YAHOO.util.DDProxy.prototype.toString=function(){return ("DDProxy "+this.id);};YAHOO.util.DDTarget=function(id,_160,_161){if(id){this.initTarget(id,_160,_161);}};YAHOO.extend(YAHOO.util.DDTarget,YAHOO.util.DragDrop);YAHOO.util.DDTarget.prototype.toString=function(){return ("DDTarget "+this.id);};
/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */

/////////////////////////////////////////////////////////////////////////

/**
 * @class a YAHOO.util.DDFramed implementation. During the drag over event, the
 * dragged element is inserted before the dragged-over element.
 *
 * @extends YAHOO.util.DDProxy
 * @constructor
 * @param {String} id the id of the linked element
 * @param {String} sGroup the group of related DragDrop objects
 */
YAHOO.example.DDPlayer = function(id,sGroup,config)
{
	this.initPlayer(id, sGroup);
};

// YAHOO.example.DDPlayer.prototype = new YAHOO.util.DDProxy();
YAHOO.extend(YAHOO.example.DDPlayer,YAHOO.util.DDProxy);
YAHOO.example.DDPlayer.TYPE = "DDPlayer";
YAHOO.example.DDPlayer.prototype.initPlayer=function(id,sGroup,config)
{
	if (!id){return;}
	this.init(id,sGroup,config);
	this.initFrame();
	this.isTarget=false;
	this.originalStyles=[];
	this.type=YAHOO.example.DDPlayer.TYPE;
	this.slot=null;
	this.startPos=YAHOO.util.Dom.getXY(this.getEl());
};
YAHOO.example.DDPlayer.prototype.startDrag=function(x,y){};
YAHOO.example.DDPlayer.prototype.getTargetDomRef=function(oDD)
{
	if(oDD.player)return oDD.player.getEl();
	else return oDD.getEl();
};
YAHOO.example.DDPlayer.prototype.endDrag=function(e)
{
	var s=this.getEl().style;
	s.opacity=1;
	s.filter="alpha(opacity=100)";
};
YAHOO.example.DDPlayer.prototype.resetTargets=function()
{
	// reset the target styles
	var targets=YAHOO.util.DDM.getRelated(this, true);
	for(var i=0,iMax=targets.length;i<iMax;i++){
		var targetEl=this.getTargetDomRef(targets[i]);
		var oldStyle=this.originalStyles[targetEl.id];
		if(oldStyle)targetEl.className=oldStyle;
	}
};
YAHOO.example.DDPlayer.prototype.onDragDrop=function(e,id)
{
	// get the drag and drop object that was targeted
	var oDD;
	if("string"==typeof id)oDD=YAHOO.util.DDM.getDDById(id);
	else oDD = YAHOO.util.DDM.getBestMatch(id);
	scratchPadAddMedia(this.id);
	this.slot=oDD;
	this.slot.player=this;
};
YAHOO.example.DDPlayer.prototype.onDragOver=function(e,id){};
YAHOO.example.DDPlayer.prototype.onDrag=function(e,id){};

function PlayingItemGetText(el)
{
	if(el != null)
	{
		if (el.textContent) return el.textContent;
		if (el.innerText) return el.innerText;
	}
	else
	{
		return "";
	}
}



function PlayingItemBuildSummaryDetails(nItem)
{
	//alert("playing item build summary details, nItem is: " + nItem + "arrayMediaPos.length -1 is" + (arrayMediaPos.length -1));
	try
	{
		if(nItem > arrayMediaPos.length -1)
		{
			return ;
		}

		//HARD CODED HACK FOR VITAMIN WATER CAMPAIGN AS PLAYER WILL NOT SEND IMPRESSIONURL
		if(	arrayDocumentID[nItem]=="53297131" || arrayDocumentID[nItem]=="53410553" ||
			arrayDocumentID[nItem]=="53297130" || arrayDocumentID[nItem]=="53410552")
		{
			var url="/proxy?u=http%3A%2F%2Fad%2Edoubleclick%2Enet%2Fad%2FN3314%2EBlinkx%2FB2680977%3Bsz%3D1x1%3Bord%3D"+(new Date().getTime())
			leaveImpression(url);
		}
		//HARD CODED HACK FOR SHELL CAMPAIGN AS PLAYER WILL NOT SEND IMPRESSIONURL
		else if(arrayDocumentID[nItem]=="53124847" || arrayDocumentID[nItem]=="53507775")
		{
			var aUKPages=Array("environment_uk_23","news_uk_53","science_and_tech_uk_33");
			var aNLPages=Array("environment_nl_23","news_nl_23","science_and_tech_nl_23");
			var aDEPages=Array("environment_de_23","news_de_23","science_and_tech_de_23");
			var aUSPages=Array("environment_us_23","news_us_23","science_and_tech_us_23");
			var aCAPages=Array("environment_ca_23","news_ca_23","science_and_tech_ca_23");
			var aCNPages=Array("environment_cn_23","news_cn_23","science_and_tech_cn_23");
			var bUKPage=false;
			var bNLPage=false;
			var bDEPage=false;
			var bUSPage=false;
			var bCAPage=false;
			var bCNPage=false;
			for(var i=0,iMax=aUKPages.length;i<iMax;i++)
			{
				if(location.href.match(new RegExp(aUKPages[i])))
				{
					bUKPage=true;
					break;
				}
			}
			if(!bUKPage)
			{
				for(var i=0,iMax=aNLPages.length;i<iMax;i++)
				{
					if(location.href.match(new RegExp(aNLPages[i])))
					{
						bNLPage=true;
						break;
					}
				}
			}
			if(!bNLPage)
			{
				for(var i=0,iMax=aDEPages.length;i<iMax;i++)
				{
					if(location.href.match(new RegExp(aDEPages[i])))
					{
						bDEPage=true;
						break;
					}
				}
			}
			if(!bDEPage)
			{
				for(var i=0,iMax=aUSPages.length;i<iMax;i++)
				{
					if(location.href.match(new RegExp(aUSPages[i])))
					{
						bUSPage=true;
						break;
					}
				}
			}
			if(!bUSPage)
			{
				for(var i=0,iMax=aCAPages.length;i<iMax;i++)
				{
					if(location.href.match(new RegExp(aCAPages[i])))
					{
						bCAPage=true;
						break;
					}
				}
			}
			if(!bCAPage)
			{
				for(var i=0,iMax=aCNPages.length;i<iMax;i++)
				{
					if(location.href.match(new RegExp(aCNPages[i])))
					{
						bCNPage=true;
						break;
					}
				}
			}
			if(bUKPage)
			{
				var url="/proxy?u=http%3A%2F%2Fad%2Edoubleclick%2Enet%2Fad%2FN339%2EBlinkx%2FB2662908%2E32%3Bsz%3D1x1%3Bord%3D"+(new Date().getTime())
				leaveImpression(url);
			}
			else if(bNLPage)
			{
				var url="/proxy?u=http%3A%2F%2Fad%2Edoubleclick%2Enet%2Fad%2FN339%2EBlinkx%2FB2664688%2E22%3Bsz%3D1x1%3Bord%3D"+(new Date().getTime())
				leaveImpression(url);
			}
			else if(bDEPage)
			{
				var url="/proxy?u=http%3A%2F%2Fad%2Edoubleclick%2Enet%2Fad%2FN339%2EBlinkx%2FB2663098%2E22%3Bsz%3D1x1%3Bord%3D"+(new Date().getTime())
				leaveImpression(url);
			}
			else if(bUSPage)
			{
				var url="/proxy?u=http%3A%2F%2Fad%2Edoubleclick%2Enet%2Fad%2FN339%2EBlinkx%2FB2662463%2E22%3Bsz%3D1x1%3Bord%3D"+(new Date().getTime())
				leaveImpression(url);
			}
			else if(bCAPage)
			{
				var url="/proxy?u=http%3A%2F%2Fad%2Edoubleclick%2Enet%2Fad%2FN339%2EBlinkx%2FB2667120%2E22%3Bsz%3D1x1%3Bord%3D"+(new Date().getTime())
				leaveImpression(url);
			}
			else if(bCNPage)
			{
				var url="/proxy?u=http%3A%2F%2Fad%2Edoubleclick%2Enet%2Fad%2FN339%2EBlinkx%2FB2667188%2E22%3Bsz%3D1x1%3Bord%3D"+(new Date().getTime())
				leaveImpression(url);
			}

		}
		//HARD CODED HACK FOR BANK JOB CAMPAI AS PLAYER WILL NOT SEND IMPRESSIONURL
		else if(arrayDocumentID[nItem]=="55127013" || arrayDocumentID[nItem]=="55126985")
		{
			var aSponSearchPages=Array("entertainment53","sports53","business13");
			var bSponSearchPage=false;
			for(var i=0,iMax=aSponSearchPages.length;i<iMax;i++)
			{
				if(location.href.match(new RegExp(aSponSearchPages[i])))
				{
					bSponSearchPage=true;
					break;
				}
			}
			if(bSponSearchPage)
			{
				var url="/proxy?type=sponsoredsearchimp&u=http%3A%2F%2Fview%2Eatdmt%2Ecom%2FIWC%2Fview%2Fblnkilgt0650000050iwc%2Fdirect%2F01%2F";
				leaveImpression(url);
			}
		}
		//HARD CODED HACK FOR MICROSOFT CAMPAIGN AS PLAYER WILL NOT SEND IMPRESSIONURL
		else if(arrayDocumentID[nItem]=="58123565" || arrayDocumentID[nItem]=="58123564")
		{
			var url="/proxy?type=sponsoredsearchimp&campaign=WindowsMobile&u=http%3A%2F%2Fview%2Eatdmt%2Ecom%2FUKM%2Fview%2Fblnknbuk0290000080ukm%2Fdirect%2F01%2F";
			leaveImpression(url);
		}

		//reset all background colors  and remove details about the currently playing clip
		for(var nCounter=0;nCounter<=10;nCounter++)
		{
			if(document.getElementById(   "id_rowResult" + nCounter) != null)
			{
				document.getElementById(   "id_rowResult" + nCounter).style. backgroundColor  = "transparent";
			}
		}

		//alert("highlighting with nItem:" + nItem);
		//highlight the currently playing one
		var nMediaPos = arrayMediaPos[nItem];
		if(!nMediaPos)
		{
			nMediaPos = arrayMediaPos["\""+nItem+"\""];
		}
		//alert("nItem is: " + nItem + " nMediaPos is:" + nMediaPos);
		var oHighlightElement=document.getElementById("id_rowResult"+nMediaPos);
		if(oHighlightElement!=null)
		{
			if(oHighlightElement.className=="ResultsSponsored")
			{
				oHighlightElement.style.backgroundColor="#FFEE8F";
			}
			else if (oHighlightElement.className=="ResultsPremium")
			{
				oHighlightElement.style.backgroundColor="#cfedfe";
			}
			else
			{
				oHighlightElement.style.backgroundColor="#F0F0F0";
			}
		}

		//alert("highlighting finished");

		//empty now playing table
		var TBody               = document.getElementById("id_resultDetail" );
		var clipsBody           = document.getElementById("id_resultDetail");
		var clipsItems          = clipsBody.getElementsByTagName("tr")  ;
		while(clipsItems.length>0 )
		{
			clipsBody.removeChild(clipsItems[0]);
		}

		//get the details
		var sTitle              = PlayingItemGetText(document.getElementById(   "id_ResultTitle" + nMediaPos));
		var sSummary            = PlayingItemGetText(document.getElementById(   "id_ResultSummary" + nMediaPos));
		var sHREF               = "";

		if(document.getElementById(   "id_ResultTitle" + nMediaPos) != null)
		{
			sHREF = document.getElementById(   "id_ResultTitle" + nMediaPos).href;
		}

		if(sHREF == "")
		{
			sHREF  = arrayMediaURLS[nMediaPos] ;
		}

		if( sSummary == "")
		{
			sSummary = decodeURIComponent(arraySummarys[nMediaPos]);
		}
		if( sTitle == "")
		{
			sTitle = decodeURIComponent(arrayTitles[nMediaPos]);
		}
		sTitle = sTitle.replace(/\./g,".<wbr/>");
		sTitle = sTitle.replace(/\@/g,"@<wbr/>");
		sTitle = sTitle.replace(/\_/g,"_<wbr/>");
		sTitle = sTitle.replace(/\\/g,"\<wbr/>");

		//if we are playing a direct play item in the burl we also have to update the title above the player
		if(bWasInSingleVideoMode)
		{
			document.getElementById("id_burl_title").innerHTML = sTitle;
		}

		if(!g_bDisableLinks)
		{
			//append email to friend
			var oTREmailAndBurl = document.createElement('tr');
			var oTDEmailAndBurl = document.createElement('td');

			var oTableEmail=document.createElement("table");
			oTableEmail.width="100%";
			oTableEmail.border="0";
			oTableEmail.cellPadding="0";
			oTableEmail.cellSpacing="0";

				var oTBodyEmail=document.createElement("tbody");

					var oTREmail=document.createElement("tr");

					if(arrayBBTVBurlURLs && arrayBBTVBurlURLs[nMediaPos] && arrayBBTVBurlURLs[nMediaPos].length)
					{
						var bbtvBurlUrl=arrayBBTVBurlURLs[nMediaPos];
						var textBbtvBurlTD 		= document.createElement('td');
						textBbtvBurlTD.setAttribute('align', 'left');
						textBbtvBurlTD.style.color = "#848484";

						var textBbtvBurlA		= document.createElement('a');
						textBbtvBurlA.href		= bbtvBurlUrl;
						textBbtvBurlA.innerHTML	= "Watch&nbsp;in&nbsp;High&nbsp;Quality";
						textBbtvBurlA.onclick		= function(){try{blinkx_Stop();}catch(e){}};

						textBbtvBurlTD.appendChild(textBbtvBurlA);
						oTREmail.appendChild(textBbtvBurlTD);
					}

					// create a class for this
					var textEmailTD 		= document.createElement('td');
					textEmailTD.setAttribute('align', 'right');
					textEmailTD.style.color = "#848484";

					var encID=arrayDocumentIDEnc[nMediaPos];
					if(!encID)encID="";

					var textEmailA			= document.createElement('a');
					textEmailA.href			= "javascript:resultElementEmail('" + sHREF + "','" + escape(escape(sTitle)) + "','"+encID+"');";
					textEmailA.innerHTML	= "Email&nbsp;this&nbsp;video&nbsp;to&nbsp;a&nbsp;friend";

					textEmailTD.appendChild(textEmailA);
					oTREmail.appendChild(textEmailTD);
					oTBodyEmail.appendChild(oTREmail);
				oTableEmail.appendChild(oTBodyEmail);
			oTDEmailAndBurl.appendChild(oTableEmail);

			oTREmailAndBurl.appendChild(oTDEmailAndBurl);

			TBody.appendChild(oTREmailAndBurl);
		}//end if(!g_bDisableLinks)








		//append title;
		var TCol1Title          = document.createElement('td');
		TCol1Title.className    = "ResultElementContent";
		var TRowTitle           = document.createElement('tr');
		if(!g_bDisableLinks)
		{
			var MediaTitle          = document.createElement('a');
			MediaTitle.onclick = function()	{try{blinkx_Stop(); window.open(sHREF, 'blinkxburl', '');return false;}catch(ep){}};
			MediaTitle.className = "ResultElementTitleDetails";
			MediaTitle.innerHTML = sTitle;
			MediaTitle.href = sHREF;
			TCol1Title.appendChild(MediaTitle);
		}
		else
		{
			var MediaTitle          = document.createElement('span');
			MediaTitle.className = "ResultElementTitleDetails";
			MediaTitle.innerHTML = sTitle;
			TCol1Title.appendChild(MediaTitle);
		}
		TRowTitle.appendChild(TCol1Title);
		TBody.appendChild(TRowTitle);

		//append summary
		var TCol1Summary        = document.createElement('td');
		TCol1Summary.className    = "ResultElementContent";

		var TRowSummary         = document.createElement('tr');
		var div                 = document.createElement('div');

		TRowSummary.height= "30px;";
		div.className = "ResultElementContent";

		var overflowStopper     = document.createElement('div');
		overflowStopper.className = "summaryOverflowStopper";
		overflowStopper.innerHTML =   sSummary;
		div.appendChild(overflowStopper);

		TCol1Summary.appendChild(div);
		TRowSummary.appendChild(TCol1Summary);
		TBody.appendChild(TRowSummary);

		if(arraySummaryLinkText[nMediaPos].length && arraySummaryLinkHref[nMediaPos].length)
		{
			var oTRSummaryLink = document.createElement("tr");
			var oTDSummaryLink = document.createElement("td");
			oTDSummaryLink.align="center";
			oTDSummaryLink.className = "ResultElementData";
			if(!g_bDisableLinks)
			{
				var oASummaryLink = document.createElement("a");
				oASummaryLink.className = "movieMode";
				oASummaryLink.href=arraySummaryLinkHref[nMediaPos];
				oASummaryLink.target="_blank";
				oASummaryLink.onclick = function(){try{blinkx_Stop();}catch(ep){}};
				oASummaryLink.innerHTML = "&raquo;&nbsp;"+arraySummaryLinkText[nMediaPos].replace(/\s+/,"&nbsp;")+"&nbsp;&laquo;";
				oTDSummaryLink.appendChild(oASummaryLink);
			}
			else
			{
				var oSpanSummaryLink = document.createElement("span");
				oSpanSummaryLink.className = "movieMode";
				oSpanSummaryLink.innerHTML = "&raquo;&nbsp;"+arraySummaryLinkText[nMediaPos].replace(/\s+/,"&nbsp;")+"&nbsp;&laquo;";
				oTDSummaryLink.appendChild(oSpanSummaryLink);
			}

			oTRSummaryLink.appendChild(oTDSummaryLink);
			TBody.appendChild(oTRSummaryLink);
		}

		//append details
		var oTRDetails = document.createElement('tr');
		var oTDDetails = document.createElement('td');
		oTDDetails.className = "ResultElementData";

		var oTable = document.createElement('table');
		var oTBody = document.createElement('tbody');
		var oTR = document.createElement('tr');


		if(!oHighlightElement || (oHighlightElement && oHighlightElement.className!="ResultsSponsored"))
		{
			var oTD         = document.createElement('td');
			var oImg        = document.createElement('img');
			oImg.border     = "0";
			// functionality added to reload the parent results page on channel

			if(typeof arrayFooterUrls!="undefined" && typeof arrayFooterAlt!="undefined")
			{
				if(!g_bDisableLinks)
				{
					var oAFooter=document.createElement("a");
					oAFooter.href=arrayFooterUrls[nMediaPos];
					oAFooter.alt=arrayFooterAlt[nMediaPos];
					oAFooter.title=arrayFooterAlt[nMediaPos];
					oAFooter.onclick=function(){try{blinkx_Stop();}catch(e){}};
				}
				if(g_bUseCutDownMediaIcons && typeof arrayDisplayNames!="undefined")
				{
					oImg=document.createTextNode(arrayDisplayNames[nMediaPos]);
					oTD.className="ResultElementText";
				}
				else
				{
					oImg.src=unescape(arrayMediaChannelGraphic[nMediaPos]);
					oImg.alt=arrayFooterAlt[nMediaPos];
					oImg.title=arrayFooterAlt[nMediaPos];
				}
				if(!g_bDisableLinks)
				{
					oAFooter.appendChild(oImg);
					oTD.appendChild(oAFooter);
				}
				else
				{
					oTD.appendChild(oImg);
				}
			}
			else
			{
				var imageLink="/channel/"+arrayChannels[nMediaPos];
				if(sBlinkxReferrer) imageLink+="?blinkxreferrer="+sBlinkxReferrer;
				oImg.onclick=function()
				{
					try{blinkx_Stop();}catch(ep){};
					try
					{
						if(window.opener && !window.opener.closed && window.opener.location.href.match(/http:\/\/([^\.]+\.)?blinkx.com/i))
						{
							window.opener.location.href=imageLink;
							if(window.opener.focus && typeof window.opener.focus=="function"){window.opener.focus();}
							return false;
						}
					}
					catch(ep){}
					window.location.href=imageLink;
				};

				oImg.src = unescape(arrayMediaChannelGraphic[nMediaPos]);
				oImg.alt = "All "+decodeURIComponent(arrayDisplayNames[nMediaPos])+" Videos";
				oImg.title = "All "+decodeURIComponent(arrayDisplayNames[nMediaPos])+" Videos";
				oImg.onerror = function (error){this.style.display='none';};
				oImg.onmouseover=function (){this.style.cursor='pointer';};
				oImg.onmouseout=function(){this.style.cursor='';};
				oTD.appendChild(oImg);
			}
			oTR.appendChild(oTD);

			oTD = document.createElement('td');
			oTD.innerHTML = "&nbsp;&nbsp;";
			oTR.appendChild(oTD);
		}


		oTD = document.createElement('td');
		oTD.className="ResultElementText";
		oTD.innerHTML = arrayDates[nMediaPos];
		oTR.appendChild(oTD);

		oTD = document.createElement('td');
		oTD.innerHTML = "&nbsp;&nbsp;";
		oTD.width="100%";
		oTR.appendChild(oTD);

		if(!g_bUseCutDownMediaIcons && arrayMediaBitrate[nMediaPos].length>0)
		{
			oTD = document.createElement('td');
			oTD.className="ResultElementText";
			oTD.vAlign = "middle";
			oTD.innerHTML = "<img border=0 src=\"" + g_sStorePrefix + "/images/tv/graph.gif\" alt=\"quality information: bitrate: " + arrayMediaBitrate[nMediaPos] +"\" title=\"quality information: bitrate: " + arrayMediaBitrate[nMediaPos] + "\"></img>";
			oTR.appendChild(oTD);
		}

		if(!g_bUseCutDownMediaIcons && arrayMediaDuration[nMediaPos] != "")
		{
			oTD = document.createElement('td');
			oTD.className="ResultElementText";
			oTD.vAlign = "middle";
			oTD.innerHTML = "<img border=0 src=\"" + g_sStorePrefix + "/images/tv/clock.gif\" alt=\"duration\" title=\"duration\"></img>";
			oTR.appendChild(oTD);
		}

		if(arrayMediaDuration[nMediaPos] != "")
		{
			oTD = document.createElement('td');
			oTD.className="ResultElementText";
			oTD.innerHTML = arrayMediaDuration[nMediaPos];
			oTR.appendChild(oTD);
		}

		oTD = document.createElement('td');
		oTD.innerHTML = "&nbsp;&nbsp;";
		oTD.width="100%";
		oTR.appendChild(oTD);

		oTD = document.createElement('td');
		oTD.className="ResultElementText";
		oTD.innerHTML = arrayMediaType[nMediaPos];
		oTR.appendChild(oTD);

		if(bShowAddToMyPlaylist)
		{
			oTD = document.createElement('td');
			oTD.className="ResultElementText";
			if(!g_bDisableLinks)
			{
				var oA = document.createElement('a');
				oA.className = "addToSP";
				oA.href = "javascript:scratchPadAddMedia('swf"+nMediaPos+"');";
			}
			var oImg = document.createElement('img');
			oImg.border = "0";
			oImg.src = g_sStorePrefix + "/images/tv/addscratch.gif";
			oImg.alt = "Add To My Playlist";
			oImg.onerror = function (error){this.style.display='none';};
			if(!g_bDisableLinks)
			{
				oA.appendChild(oImg);
				oTD.appendChild(oA);
			}
			else
			{
				oTD.appendChild(oImg);
			}
			oTR.appendChild(oTD);
		}

		// email
		if(!g_bUseCutDownMediaIcons)
		{
			oTD = document.createElement('td');
			oTD.className="ResultElementText";

			if(!g_bDisableLinks)
			{
				// add anchor tag
				oA = document.createElement('a');
				oA.href = "javascript:resultElementEmail('" + sHREF + "','" + escape(escape(sTitle)) + "','"+encID+"');";
			}
			// add image
			oImg = document.createElement('img');
			oImg.border = "0";
			oImg.src = g_sStorePrefix + "/images/tv/icon_email.gif";
			oImg.alt = "Email to a Friend";
			if(!g_bDisableLinks)
			{
				oA.appendChild(oImg);
				oTD.appendChild(oA);
			}
			else
			{
				oTD.appendChild(oImg);
			}

			oTR.appendChild(oTD);
		}
		oTBody.appendChild(oTR);
		oTable.appendChild(oTBody);
		oTDDetails.appendChild(oTable);
		oTRDetails.appendChild(oTDDetails);
		TBody.appendChild(oTRDetails);

		if(arrayChannels[nMediaPos].match(/dwworld/i)
		|| arrayChannels[nMediaPos].match(/dwworldpr/i))
		{
			var oTRDeutscheWelle=document.createElement("tr"),
				oTDDeutscheWelle=document.createElement("td");
			appendDeutscheWelleFrame(oTDDeutscheWelle);
			oTRDeutscheWelle.appendChild(oTDDeutscheWelle);
			TBody.appendChild(oTRDeutscheWelle);
		}
	}
	catch(ep)
	{
		//alert("error:" + ep);
	}

}

function http_build_query(aParams)
{
	var entries=new Array;
	for (var i in aParams) entries.push(i+'='+encodeURIComponent(aParams[i]));
	return entries.join('&');
}

	function resultElementEmail(url, title, vID)
	{
		try {
			if(url.indexOf("http://")!=0) url='http://www.blinkx.com'+url;

			var redirect="/emailform?type=video&url=" + encodeURIComponent(url) + "&title=" + title + "&returnurl="+encodeURIComponent(window.location.href);
			if(vID && vID.length) redirect+="&v="+vID;
			if(typeof g_sAdid != "undefined" && g_sAdid.length) redirect+="&adid="+g_sAdid;

			location.href=redirect;
		} catch (ep) {}
	}

	function scratchEmail()
	{
		var sIDList=readCookie(g_sScratchpadCookieName);
		if(sIDList && sIDList+""!="undefined" && sIDList!="")
		{
			var aParams=new Array;
			aParams['type']='playlist';
			aParams['url']='http://www.blinkx.com/burl?idlist=' + sIDList;
			aParams['title']='MyPlaylist';
			aParams['returnurl']=window.location.href;
			if(typeof g_brandedPlaylistExtra!=="undefined") aParams['d']=g_brandedPlaylistExtra;

			location.href='/emailform?'+http_build_query(aParams);
		}
		else alert("Please add some videos to your playlist");
	}

	function ScratchPadPlayAll()
	{
		try{blinkx_Stop();}catch(ep){}
		var sIDList=readCookie(g_sScratchpadCookieName);
		if(sIDList && sIDList+""!="undefined" && sIDList!="") window.open("/burl?mediaidlist="+sIDList,'','');
		else alert("Please add some videos to your playlist");
	}

	function scratchPadItemGetText(el)
	{
		if(el != null)
		{
			if (el.textContent) return el.textContent;
			if (el.innerText) return el.innerText;
		}
		else
		{
			return "";
		}
	}

	function scratchPadLoadFromCookiesReponse()
	{
		try
		{
			if (http.readyState==4)
			{
				if (http.status==200)
				{
					xml=http.responseXML;
					var totalElementsList=xml.getElementsByTagName("item");
					var sIDList=readCookie(g_sScratchpadCookieName);
					if(sIDList)
					{
						arrayMediaID=sIDList.split(":");
						var j,i,currentElement,sID,sBURL,sTitle,sSWF,sDefault;
						for(j=0,jMax=arrayMediaID.length;j<jMax;j++) {
							for(i=0,iMax=totalElementsList.length;i<iMax;i++)
							{
								currentElement=totalElementsList.item(i);
								if(currentElement.hasChildNodes())
								{
									sID="",sTitle="",sSWF="",sDefault="";
									sBURL=currentElement.getElementsByTagName("burl").item(0).firstChild.nodeValue;

									try{sID=currentElement.getElementsByTagName("id").item(0).firstChild.nodeValue}catch(ep){}
									try{sSWF=currentElement.getElementsByTagName("swf").item(0).firstChild.nodeValue}catch(ep){}
									try{sTitle=currentElement.getElementsByTagName("title").item(0).firstChild.nodeValue}catch(ep){}
									try{sDefault=currentElement.getElementsByTagName("swf_default").item(0).firstChild.nodeValue}catch(ep){}

									if(arrayMediaID[j]==sID){
										arrayMediaHREF[j]=sBURL;
										arrayMediaSWF[j]=sSWF;
										arrayMediaSWFDefault[j]=sDefault;
										arrayMediaTitle[j]=sTitle;
										break;
									}
								}
							}
						}
					}

					try
					{
						if(bIsCondenast)condenastWriteMediaToTable(0,true);
					}
					catch(ep)
					{
						scratchPadWriteMediaToTable(0,true);
					}
				}
			}
		}
		catch(ep){}
	}

	function scratchPadLoadFromCookies()
	{
		var sIDList=readCookie(g_sScratchpadCookieName);
		if(sIDList)
		{
			arrayMediaID=sIDList.split(":");

			var url="/mediaAJAX.php?ids="+encodeURIComponent(arrayMediaID.join(','));
			if(!g_bIsSafeSearchOn) url+="&safefilter=off";

			http=initXMLHttpClient();
			http.open("GET",url,true);
			http.onreadystatechange=scratchPadLoadFromCookiesReponse;
			http.send(null);
		}
		else
		{
			arrayMediaID=new Array;
			try
			{
				var clipsBody=document.getElementById("id_scratchPadMedia"),
					oTR=document.createElement('tr'),
					oTD=document.createElement('td');

				try
				{
					if(bIsCondenast)oTD.innerHTML="Your playlist is empty.  Perform a search to start building your playlist.";
				}
				catch(ep)
				{
					oTD.className="scratchpadEmptyText";
					oTD.innerHTML="Your playlist is empty.  Drag some videos here to start building your playlist.";
				}

				oTR.id="noResTR";
				oTR.appendChild(oTD);
				clipsBody.appendChild(oTR);
			}
			catch(ep)
			{
			}
		}
	}

	function scratchPadLoadSaveToCookies()
	{
		var strIDListRequest   = "";
		var strIDListArray     = ""
		for(var i=0,iMax=arrayMediaID.length;i<iMax;i++)
		{
			strIDListRequest    = strIDListRequest + "id="+ arrayMediaID[i];
			strIDListArray      = strIDListArray   + arrayMediaID[i] ;

			if(i+1 < arrayMediaID.length)
			{
				strIDListRequest    = strIDListRequest    + "||";
				strIDListArray      = strIDListArray    + ":";
			}
		}
		var oExpires=new Date();
		offset=1/1;
		oExpires.setYear(oExpires.getFullYear()+offset);
		writeCookie(g_sScratchpadCookieName,strIDListArray,oExpires,"/",null);
	}

	function scratchPadWriteMediaToTableItem(oTR,nItem)
	{
		var oTD1=document.createElement('td'),
			oTD2=document.createElement('td'),
			oATitle=document.createElement('a'),
			oARemove=document.createElement('a'),
			oDiv=document.createElement('div'),
			space=document.createTextNode(" ");

		var sTitle=arrayMediaTitle[nItem];
		if(sTitle.length>49)sTitle=sTitle.substring(0,46)+"...";

		oATitle.href=arrayMediaHREF[nItem];
		oATitle.className="scratchpadElementTitleDetails";
		oATitle.innerHTML=sTitle;
		oATitle.target="_blank";

		oARemove.href="javascript:scratchPadRemoveMedia("+nItem+");";
		oARemove.className="removeMediaLink";
		oARemove.innerHTML="[-]";

		oDiv.id="scratchpadswf"+nItem;
		oDiv.className="scratchPadSwf";

		oTD1.appendChild(oDiv);
		oTD2.appendChild(oATitle);
		oTD2.appendChild(space);
		oTD2.appendChild(oARemove);

		oTR.appendChild(oTD1);
		oTR.appendChild(oTD2);
	}

	function ScratchPadOpen(nPos)
	{
		try
		{
			if(arrayMediaHREF[nPos].indexOf("www.blinkx.com") > 0)
			{
				window.open(arrayMediaHREF[nPos]);
			}
			else
			{
				window.open("http://www.blinkx.com/" + arrayMediaHREF[nPos]);
			}
		}
		catch(ep)
		{
		}

	}

	//write one memory item to screen
	function scratchPadWriteMediaToTable(nItemIn,bRemoveAll)
	{
		var clipsBody=document.getElementById("id_scratchPadMedia");
		var clipsItems=clipsBody.getElementsByTagName("tr");

		var d;
		if(arrayMediaTitle.length>0)
		{
			d=document.getElementById("id_play");
			if(d)d.disabled=false;
			d=document.getElementById("id_email");
			if(d)d.disabled=false;
			d=document.getElementById("id_wall");
			if(d)d.disabled=false;
		}
		else
		{
			d=document.getElementById("id_email");
			if(d)d.disabled=true;
			d=document.getElementById("id_wall");
			if(d)d.disabled=true;
			d=document.getElementById("id_play");
			if(d)d.disabled=true;
		}

		while(clipsItems.length>0 && bRemoveAll==true)
		{
			clipsBody.removeChild(clipsItems[0]);
		}

		if(arrayMediaTitle.length<1)
		{
			var oTR=document.createElement('tr'),
				oTD=document.createElement('td');
			oTR.id="noResTR";
			oTD.className="scratchpadEmptyText";
			oTD.innerHTML="Your playlist is empty. Drag some videos here to start building your playlist.";

			oTR.appendChild(oTD);
			clipsBody.appendChild(oTR);
		}
		else
		{
			var oNoResTR=document.getElementById('noResTR');
			if(oNoResTR) oNoResTR.parentNode.removeChild(oNoResTR);
			nItem=nItemIn;

			var TRow,TCol1,TCol2;
			for(;nItem<arrayMediaTitle.length;nItem+=2)
			{
				try
				{
					TRow=document.createElement('tr');
					scratchPadWriteMediaToTableItem(TRow,nItem);
					if(nItem+1<arrayMediaTitle.length)
					{
						scratchPadWriteMediaToTableItem(TRow,nItem+1);
					}
					else
					{
						TCol1=document.createElement('td');
						TCol2=document.createElement('td');
						TRow.appendChild(TCol1);
						TRow.appendChild(TCol2);
					}
					clipsBody.appendChild(TRow);
				}
				catch(ep){}
			}

			nItem=nItemIn;

			var varLayerMask,linkFlashTemp;
			for(;nItem<arrayMediaTitle.length ; nItem++)
			{
				varLayerMask="scratchpadswf"+nItem;
				if(isCorrectFlashVersionInstalled(9,0,28))
				{
					linkFlashTemp=new SWFObject(varScratchPadImageStore+"/images/linkflash2.swf",varLayerMask,"40","30","7","#000000");
					linkFlashTemp.addParam("allowScriptAccess", "always");
					linkFlashTemp.addParam("movie",varScratchPadImageStore+"/images/linkflash2.swf");
					linkFlashTemp.addParam("quality","high");
					linkFlashTemp.addParam("wmode","transparent");
					linkFlashTemp.addParam("bgcolor","#000000");
					linkFlashTemp.addParam("flashvars","&Jscript=javascript:ScratchPadOpen("+nItem+");&SizeX=80&Filename="+encodeURIComponent(arrayMediaSWF[nItem])+"&AlternateFilename="+varScratchPadImageStore+"/"+arrayMediaSWFDefault[nItem]);
					linkFlashTemp.write(varLayerMask);
				}
				else
				{
					replaceContentWithFlashMessage(varLayerMask,replaceContentHtmlMinimal);
				}
			}
		}
	}

	function scratchPadSetBlinkxItEmbed()
	{
		try
		{
			var sIDList=readCookie(g_sScratchpadCookieName);
			if(sIDList && sIDList+""!="undefined" && sIDList!="")
			{
				sIDList=sIDList.replace(/:/g, ",");
				varIDListEncoded=escape(sIDList);
			}
		}
		catch(ep){}
	}

	function scratchPadAddMedia(varID)
	{
		//save to memory
		var sTitle          = scratchPadItemGetText(document.getElementById("id_ResultTitle" + varID.substring(3)));
		var sID             = arrayDocumentID[varID.substring(3)] ;
		var sIDEnc          = arrayDocumentIDEnc[varID.substring(3)] ;
		var bAllreadythere  = false;

		sID = sID.replace(/^\s*|\s*$/g,"");

		for(i = 0 ; i < arrayMediaID.length;i++)
		{
			if(arrayMediaID[i]==sID)
			{
				bAllreadythere = true;
				break;
			}
		}

		if(!bAllreadythere)
		{
			if(arrayMediaTitle.length < 75)
			{
				var nPos = arrayMediaTitle.length;

				arrayMediaTitle[nPos]       = sTitle;
				arrayMediaSWF[nPos]         = arraySWFLocations[varID.substring(3)];
				arrayMediaSWFDefault[nPos]  = unescape(arrayMeidaChannelSWFBackup[varID.substring(3)]);
				arrayMediaHREF[nPos]        = "http://www.blinkx.com/burl?v=" + sIDEnc;
				arrayMediaID[nPos]          = sID;
				scratchPadWriteMediaToTable(0 , true);
				scratchPadLoadSaveToCookies();
			}
			else
			{
				alert("sorry, your playlist can only hold 75 videos");
			}
		}
		else
		{
			alert("your playlist already has this video ");
		}
	}

	function scratchPadRemoveAll()
	{
		if(confirm("Are you sure you want to clear your playlist?"))
		{
			arrayMediaTitle.splice(0,arrayMediaTitle.length);
			arrayMediaSWF.splice(0,arrayMediaSWF.length);
			arrayMediaHREF.splice(0,arrayMediaHREF.length);
			arrayMediaID.splice(0,arrayMediaID.length);
			arrayMediaSWFDefault.splice(0,arrayMediaSWFDefault);
			scratchPadWriteMediaToTable(0,true);
			scratchPadLoadSaveToCookies();
		}
	}

	function scratchPadRemoveMedia(nPos)
	{
		arrayMediaTitle.splice(nPos,1);
		arrayMediaSWF.splice(nPos,1);
		arrayMediaHREF.splice(nPos,1);
		arrayMediaID.splice(nPos,1);
		arrayMediaSWFDefault.splice(nPos,1);
		scratchPadWriteMediaToTable(0,true);
		scratchPadLoadSaveToCookies();
	}

	function createChannelFromPad()
	{
		var counter=1;
		var aParamItems=new Array;
		for(var i in arrayMediaID)
		{
			aParamItems.push("add_media_"+(counter++)+"="+arrayMediaID[i]);
		}
		location.href="/channel/editChannel?query=<?=urlencode($_REQUEST['query'])?>&"+aParamItems.join("&");
	}

	function createWallFromPad()
	{
		var aParamItems=new Array;
		for(var i in arrayMediaID)
		{
			aParamItems.push(arrayMediaID[i]);
		}

		var sIDList=aParamItems.join(":");
		if(sIDList+""!="undefined" && sIDList!="") location.href="/wall?mediaidlist="+sIDList;
		else alert("Please add some videos to your playlist");
	}


///////////////////////////////////////////////////////
//burl
//////////////////////////////////////////////////////
		/**
		 * @desc generates playlist html output
		 */
		function  BURLLoadPlaylist()
		{
			try
			{
				var nItemIn             = 0 ;
				// boolean flag set to clear playlist
				var bRemoveAll          = true;
				// playlist TBODY element
				var clipsBody           = document.getElementById("id_BURLPlaylistMedia");
				// gets all playlist TR descendents
				var clipsItems          = clipsBody.getElementsByTagName("tr")  ;
				// get the playlist TBODY element (again?)
				var TBody               = document.getElementById("id_BURLPlaylistMedia");

				// loop through playlist TR descendents if we are going to clear the playlist
				while(clipsItems.length>0 && bRemoveAll == true)
				{
					// remove TR element
					clipsBody.removeChild(clipsItems[0]);
				}

				nItem = nItemIn        ;

				// 01/22/2008 simon - by the time arrayTitles is accessed here, it is already escaped for HTML entities
				// in this case, it is already URI encoded and escaped for HTML special characters in /media/mediaBURL.JS.php
				for(  ; nItem <  arrayTitles.length ; nItem++)
				{
					try
					{
						if(arrayIsAdvert[nItem] == "false")
						{

						var TCol1               = document.createElement('td');
						var TCol2               = document.createElement('td');
						var TRow                = document.createElement('tr');
						var MediaTitle          = document.createElement('a');
						var MediaDiv            = document.createElement('div');
						var sTitle = stripslashes(arrayEscapedTitles[nItem]);
						var clipNum             = nItem+1;

						if(sTitle.length > 45)
						{
							sTitle = sTitle.substring(0,43) + "...";
						}

						MediaTitle.className = 'burlResultsLink';
						MediaTitle.setAttribute('href', 'javascript:void(0);');
						MediaTitle.innerHTML = "<span class=\"burlResultsLink\" onclick=\"try{blinkx_playerPlayClipNumber('" + clipNum + "');}catch(ep){};return false;\">" + sTitle + "</span>";
						MediaTitle.title        =  decodeURIComponent(arrayDisplayNames[nItem]);

						MediaTitle.jsLink         = decodeURIComponent(arrayMediaLinks[nItem]);

						MediaDiv.id             = "id_playlist" + nItem;
						MediaDiv.height         = "40";
						MediaDiv.width          = "40";
						MediaDiv.style.margin   = "5px";
						MediaDiv.style.border   = "1px solid transparent";

						TCol2.appendChild(MediaTitle);
						TCol1.appendChild(MediaDiv);

						TRow.appendChild(TCol1);
						TRow.appendChild(TCol2);
						TBody.appendChild(TRow);
						}

					}
					catch(ep)
					{
					}
				}

				nItem = nItemIn;
				for(  ; nItem <  arrayTitles.length ; nItem++)
				{
					if(arrayIsAdvert[nItem] == "false")
					{
					try
					{
						var varLayerMask  =  "id_playlist" + nItem;

						if(isCorrectFlashVersionInstalled(9,0,28))
						{
							var linkFlashTemp = new SWFObject(varBURLStorePrefix + "/images/linkflash2.swf" , varLayerMask , "40", "30", "7", "#000000");
							linkFlashTemp.addParam("allowScriptAccess", "always");
							linkFlashTemp.addParam("movie", varBURLStorePrefix + "/images/linkflash2.swf" );
							linkFlashTemp.addParam("quality", "high");
							linkFlashTemp.addParam("wmode", "transparent");
							linkFlashTemp.addParam("bgcolor", "#000000");
							linkFlashTemp.addParam("flashvars", "SizeX=80&Filename="+encodeURIComponent(arraySWFLocations[nItem])+"&AlternateFilename="+ varBURLStorePrefix  +"/"+ arraySWFBackup[nItem] + "&Jscript=javascript:BURLPlayItem("+nItem+")");
							linkFlashTemp.write( varLayerMask );

						}
						else
						{
							replaceContentWithFlashMessage(varLayerMask,replaceContentHtmlMinimal);
						}
					}
					catch(ep)
					{
					}
					}
				}
			}
			catch(ep)
			{
			}
		}

		function BURLPlayListHighLight(nItem)
		{
			for(var i = 0 ; i < arraySWFLocations.length; i++)
			{
				if(document.getElementById("id_playlist"+i) != null)
				{
					document.getElementById("id_playlist"+i).style.border='1px solid transparent';
				}
			}

			if(document.getElementById("id_playlist"+nItem) != null)
			{
				theElement = document.getElementById("id_playlist"+nItem)
				theElement.style.border='1px solid rgb(230,118,6)';
				var selectedPosY = 0;
				while(theElement != null)
				{
					selectedPosY += theElement.offsetTop;
					theElement = theElement.offsetParent;
				}

				nPosA = selectedPosY - 108;

				if(nPosA > 2)
				{
					document.getElementById("id_BURLPlaylistMediaDiv").scrollTop  = nPosA ;
				}
			}
		}

		function BURLRequestSuggestions(nMediaID)
		{
			http=initXMLHttpClient();
			var url="/mediaAJAX.php?suggestid="+nMediaID;
			if(!g_bIsSafeSearchOn) url+="&safefilter=off";
			http.open("GET",url,true);
			http.onreadystatechange=BURLRequestSuggestionsLoad;
			http.send(null);
		}

		function BURLRequestSuggestionsLoad()
		{
			try
			{
				if (http.readyState==4)
				{
					if (http.status==200)
					{
						xml=http.responseXML;
						var totalElementsList=xml.getElementsByTagName("item");

						var clipsBody=document.getElementById("id_BURLSuggestMedia");
						var clipsItems=clipsBody.getElementsByTagName("tr")  ;
						var TBody=document.getElementById("id_BURLSuggestMedia");

						arraySuggestSWFLocations    = new Array();
						arraySuggestSWFBackup       = new Array();
						arraySuggestTitles          = new Array();
						arraySuggestDisplay	        = new Array();
						arraySuggestHREF            = new Array();
						arraySuggestLinks           = new Array();
						arraySuggestPublishers      = new Array();

						//empty table
						while(clipsItems.length>0)
						{
							clipsBody.removeChild(clipsItems[0]);
						}

						for(i = 0 ; i <  totalElementsList.length;i++)
						{
							var currentElement = totalElementsList.item(i);
							if(currentElement.hasChildNodes())
							{
								var sBURL           = "";
								var sTitle          = "";
								var sSWF            = "";
								var sDefault        = "";
								var sChannelName    = "";
								var sDisplayName	= "";
								var sLink 			= "";

								try{    sSWF            = currentElement.getElementsByTagName("swf").item(0).firstChild.nodeValue}catch(ep){}
								try{    sTitle          = currentElement.getElementsByTagName("title").item(0).firstChild.nodeValue}catch(ep){}
								try{    sDefault        = currentElement.getElementsByTagName("swf_default").item(0).firstChild.nodeValue}catch(ep){}
								try{    sChannelName    = currentElement.getElementsByTagName("channelname").item(0).firstChild.nodeValue}catch(ep){}
								try{    sDisplayName    = currentElement.getElementsByTagName("displayname").item(0).firstChild.nodeValue}catch(ep){}
								try{    sBURL           = currentElement.getElementsByTagName("burl").item(0).firstChild.nodeValue}catch(ep){}
								try{    sLink           = currentElement.getElementsByTagName("link").item(0).firstChild.nodeValue}catch(ep){}


								arraySuggestSWFLocations[i]     =    sSWF;
								arraySuggestTitles[i]           =    sTitle;
								arraySuggestSWFBackup[i]        =    sDefault;
								arraySuggestHREF[i]             =    sBURL;
								arraySuggestPublishers[i]       =    sChannelName;
								arraySuggestLinks[i]       		=    sLink;
								arraySuggestDisplay[i]     		=    sDisplayName;


								try
								{
									var TCol1               = document.createElement('td');
									var TCol2               = document.createElement('td');
									var TRow                = document.createElement('tr');
									var MediaTitle          = document.createElement('a');
									var MediaDiv            = document.createElement('div');

									if(sTitle.length > 45)
									{
										sTitle = sTitle.substring(0,43) + "...";
									}

									MediaTitle.innerHTML    =  sTitle;
									MediaTitle.href         =  sBURL ;
									MediaTitle.className    = "ResultElementTitleDetails";
									MediaTitle.className    = "scratchpadElementTitleDetails";
									MediaTitle.title        = sDisplayName;
									MediaTitle.pos			= i;

									MediaTitle.onclick		= function()
										{
											try{blinkx_Stop();}catch(ep){};
											eval(arraySuggestLinks[this.pos]);
											return false;
										};


									MediaTitle.target = "_blank";


									MediaDiv.id             = "id_suggestSWF" + i;
									MediaDiv.height         = "40";
									MediaDiv.width          = "40";
									MediaDiv.style.margin   = "5px";

									TCol2.appendChild(MediaTitle);
									TCol1.appendChild(MediaDiv);

									TRow.appendChild(TCol1);
									TRow.appendChild(TCol2);
									TBody.appendChild(TRow);
								}
								catch(ep)
								{
								}
							}
						}

						for(nItem = 0  ; nItem <  arraySuggestSWFBackup.length ; nItem++)
						{
							var varLayerMask  =  "id_suggestSWF" + nItem;

							if(isCorrectFlashVersionInstalled(9,0,28))
							{
								var linkFlashTemp = new SWFObject(varBURLStorePrefix +"/images/linkflash2.swf" , varLayerMask , "40", "30", "7", "#000000");
								linkFlashTemp.addParam("allowScriptAccess", "always");
								linkFlashTemp.addParam("movie", varBURLStorePrefix + "/images/linkflash2.swf" );
								linkFlashTemp.addParam("quality", "high");
								linkFlashTemp.addParam("wmode", "transparent");
								linkFlashTemp.addParam("bgcolor", "#000000");
								linkFlashTemp.addParam("flashvars", "SizeX=80&Filename="+encodeURIComponent(arraySuggestSWFLocations[nItem])+"&AlternateFilename="+ varBURLStorePrefix  +"/"+ arraySuggestSWFBackup[nItem]     + "&Jscript=javascript:BURLPlaySuggestItem("+nItem+")");
								linkFlashTemp.write( varLayerMask );
							}
							else
							{
								replaceContentWithFlashMessage(varLayerMask,replaceContentHtmlMinimal);
							}
						}
					}
				}
			}
			catch(ep)
			{
			}
		}


		function openWindowCentered(source,name,height,width,otherParams)
		{
			var aw = screen.width, ah = screen.height, top = 0, left = 0;
			if(height && width) {left = aw>width?parseInt((aw-width)/2):0, top = ah>height?parseInt((ah-height)/2):0;}
			var paramString = "top="+top+",left="+left;
			if(height) paramString += ",height=" + height;
			if(width)  paramString += ",width=" + width;
			if(otherParams) paramString += "," + otherParams;
			return window.open(source,name,paramString);
		}

		function BURLPlaySuggestItem(nPos)
		{
			if(nPos >= 0   && nPos < arraySuggestHREF.length)
			{
				varURL = arraySuggestHREF[  nPos];
				try{blinkx_Stop();}catch(ep){}

				eval(arraySuggestLinks[nPos]);
				//window.open(unescape(varURL));
			}
		}

		function BURLOpenOrginalPos(nPos)
		{
			try
			{
				if(nPos >= 0   && nPos < arrayMediaURLS.length)
				{
					varURL = arrayMediaURLS[  nPos];
					try{blinkx_Stop();}catch(ep){}
					eval(unescape(varURL));
				}
			}
			catch(ep)
			{
			}
		}

		function BURLOpenOrginal()
		{
			if(this.varCurrentPos >=0   && this.varCurrentPos < arrayMediaURLS.length)
			{
				varURL = arrayMediaURLS[  this.varCurrentPos];
				try{blinkx_Stop();}catch(ep){}
				eval(unescape(varURL));
			}
		}

		function BURLMail()
		{
			if(bWasInSingleVideoMode)
			{
				var nMediaPos = arrayMediaPos[this.varCurrentPos];
				if(!nMediaPos)
				{
					nMediaPos = arrayMediaPos["\""+this.varCurrentPos+"\""];
				}

				varShareURL		= encodeURIComponent("http://www.blinkx.com/burl?v="+arrayDocumentIDEnc[nMediaPos])	;
				varShareTitle	= arrayTitles[nMediaPos];

				sLocation 		= "/emailform?type=video&url="+varShareURL+"&title="+varShareTitle+"&returnurl="+encodeURIComponent(window.location);

				location.href = sLocation;
			}
			else
			{
				location.href="/emailform?type="+varShareType+"&url="+varShareURL+"&title="+varShareTitle+"&returnurl="+encodeURIComponent(window.location);
			}
		}

		function addLoadEvent(func)
		{
			var oldonload = window.onload;
			if (typeof window.onload != 'function')
			{
				window.onload = func;
			}
			else
			{
				window.onload = function()
				{
					oldonload();
					func();
				}
			}
		}



		function BURLPlayItem(nPos)
		{
			try
			{
				blinkx_playerPlayClipNumber(nPos+1);
			}
			catch(ep)
			{
			}
		}

var bTabMenuOpen=false;

function toggleTabMenu()
{
	if(bTabMenuOpen) hideTabMenu();
	else showTabMenu();
}

function showTabMenu()
{
	if(!bTabMenuOpen)
	{
		var oMenu=document.getElementById("tabmenuholder");
		if(oMenu)
		{
			bTabMenuOpen=true;
			oMenu.style.visibility="visible";
		}
	}
}

function hideTabMenu()
{
	if(bTabMenuOpen)
	{
		var oMenu=document.getElementById("tabmenuholder");
		if(oMenu)
		{
			bTabMenuOpen=false;
			oMenu.style.visibility="hidden";
		}
	}
}

	function wallToChannel(varName)
	{
		try
		{
			showFrontPageChannelHeadline(varName);

			if(document.getElementById("newwall"))
			{
				var oExpires = new Date();
				oExpires.setYear(oExpires.getFullYear()+1);
				writeCookie('blinkxFrontPageWallChannel', varName, oExpires  , "/" , null);
				varChannelID = 589;

				if (varName == "entertainment")
				{
					varChannelID = 591;
				}
				else if (varName == "default")
				{
					varChannelID = 589;
				}
				else if (varName == "sport")
				{
					varChannelID = 593;
				}
				else if (varName == "music")
				{
					varChannelID = 813;
				}
				else if (varName == "viral")
				{
					varChannelID = 595;
				}
				else if (varName == "business")
				{
					varChannelID = 597;
				}
				else if (varName == "scitech")
				{
					varChannelID = 801;
				}
				else if (varName == "education")
				{
					varChannelID = 803;
				}
				else if (varName == "travel")
				{
					varChannelID = 805;
				}
				else if (varName == "home")
				{
					varChannelID = 807;
				}
				else if (varName == "film")
				{
					varChannelID = 825;
				}
				else if (varName == "environment")
				{
					varChannelID = 827;
				}
				else if (varName == "automotive")
				{
					varChannelID = 869;
				}
				else if (varName == "gaming")
				{
					varChannelID = 871;
				}
				else if (varName == "food")
				{
					varChannelID = 939;
				}

				varApiQuery  = "/"+ varWallAPIPath +"?action=query&databasematch=channelmedia&channelid=";
				varApiQuery  = varApiQuery + varChannelID;

				var oOriginalWall = document.getElementById("newwall");
				var oCloneWall = oOriginalWall.cloneNode(true);
				//prompt("Original src",oCloneWall.src);
				if(oCloneWall.src)
				{
					oCloneWall.src = oCloneWall.src.replace(/channelid(=|%3D)\d+/g,"channelid$1" + varChannelID);
					oOriginalWall.parentNode.replaceChild(oCloneWall,oOriginalWall);
				}
				else
				{
					var replacementsrc,width=oCloneWall.width,height=oCloneWall.height;
					var childNodes = oCloneWall.childNodes;
					for(var i=0,iMax=childNodes.length; i<iMax; i++)
					{
						var node = childNodes[i];
						if(node.nodeName.match(/param/i) && node.value.match(/channelid(=|%3D)\d+/g))
						{
							replacementsrc = node.value.replace(/channelid(=|%3D)\d+/g,"channelid$1" + varChannelID);
						}
					}
					var oReplacementDiv = document.createElement("div");
					oReplacementDiv.style.backgroundColor = "#000";
					oReplacementDiv.style.height = eval("\"" + height + "\"");
					oReplacementDiv.style.width = eval("\"" + width + "\"");
					oReplacementDiv.id = "tabbedvideowall";
					var oSpan = document.createElement("span");
					oSpan.innerHTML = "loading...";
					oReplacementDiv.appendChild(oSpan);
					oOriginalWall.parentNode.replaceChild(oReplacementDiv,oOriginalWall);
					var wall = new SWFObject(replacementsrc, "newwall", eval("\""+width+"\""), eval("\""+height+"\""), "7", "#FFFFFF");
					wall.addParam("allowScriptAccess", "always");
					wall.addParam("quality", "high");
					wall.addParam("wmode", "transparent");
					wall.addParam("bgcolor", "#eeeeee");
					if(isCorrectFlashVersionInstalled(9,0,28))
					{
						wall.write("tabbedvideowall");
					}
				}
				wallResetCurrentChannel(varName);
			}
		}
		catch(ep)
		{
			//alert(ep.message);
		}
	}

	function wallResetCurrentChannel(varName)
	{
		try
		{
			var t0=document.getElementById("id_videoWallType0"),
				t1=document.getElementById("id_videoWallType1"),
				t2=document.getElementById("id_videoWallType2"),
				t3=document.getElementById("id_videoWallType3"),
				x0=document.getElementById("id_videoWallType4"),
				m0=document.getElementById("id_videoWallMenuType0"),
				m1=document.getElementById("id_videoWallMenuType1"),
				m2=document.getElementById("id_videoWallMenuType2"),
				m3=document.getElementById("id_videoWallMenuType3"),
				m4=document.getElementById("id_videoWallMenuType4"),
				m5=document.getElementById("id_videoWallMenuType5"),
				m6=document.getElementById("id_videoWallMenuType6"),
				m7=document.getElementById("id_videoWallMenuType7"),
				m8=document.getElementById("id_videoWallMenuType8");
				m9=document.getElementById("id_videoWallMenuType9");
				m10=document.getElementById("id_videoWallMenuType10");

			if(t0)t0.className="tab unselectedTab";
			if(t1)t1.className="tab unselectedTab";
			if(t2)t2.className="tab unselectedTab";
			if(t3)t3.className="tab unselectedTab";
			if(x0)x0.className="moreTab";
			if(m0)m0.className="tabMenuItem";
			if(m1)m1.className="tabMenuItem";
			if(m2)m2.className="tabMenuItem";
			if(m3)m3.className="tabMenuItem";
			if(m4)m4.className="tabMenuItem";
			if(m5)m5.className="tabMenuItem";
			if(m6)m6.className="tabMenuItem";
			if(m7)m7.className="tabMenuItem";
			if(m8)m8.className="tabMenuItem";
			if(m9)m9.className="tabMenuItem";
			if(m10)m10.className="tabMenuItem";

			if(!varName)varName = readCookie("blinkxFrontPageWallChannel");

			if(varName=="entertainment" && t1)t1.className="tab selectedTab";
			else if(varName=="business" && t2)t2.className="tab selectedTab";
			else if (varName=="sport" && t3)t3.className="tab selectedTab";
			else if (varName=="music"
				|| varName=="viral"
				|| varName=="scitech"
				|| varName=="education"
				|| varName=="travel"
				|| varName=="home"
				|| varName=="film"
				|| varName=="environment"
				|| varName=="automotive"
				|| varName=="gaming"
				|| varName=="food")
			{
				if(x0)x0.className="moreTab";

				if(varName=="music" && m0)m0.className="tabMenuItemSelected";
				else if(varName=="viral" && m1)m1.className="tabMenuItemSelected";
				else if(varName=="scitech" && m2)m2.className="tabMenuItemSelected";
				else if(varName=="education" && m3)m3.className="tabMenuItemSelected";
				else if(varName=="travel" && m4)m4.className="tabMenuItemSelected";
				else if(varName=="home" && m5)m5.className="tabMenuItemSelected";
				else if(varName=="film" && m6)m6.className="tabMenuItemSelected";
				else if(varName=="environment" && m7)m7.className="tabMenuItemSelected";
				else if(varName=="automotive" && m8)m8.className="tabMenuItemSelected";
				else if(varName=="gaming" && m9)m9.className="tabMenuItemSelected";
				else if(varName=="food" && m10)m10.className="tabMenuItemSelected";
			}
			else if(t0)t0.className="tab selectedTab";
		}
		catch(ep)
		{
		}
	}

	function showFrontPageChannelHeadline(varName)
	{
		try
		{
			var oNewsTR = document.getElementById("newsHeadlineRow"),
				oEntTR = document.getElementById("entertainmentHeadlineRow"),
				oBusinessTR = document.getElementById("businessHeadlineRow"),
				oSportTR = document.getElementById("sportHeadlineRow"),
				oMusicTR = document.getElementById("musicHeadlineRow"),
				oViralTR = document.getElementById("viralHeadlineRow"),
				oSciTechTR = document.getElementById("scitechHeadlineRow"),
				oEducationTR = document.getElementById("educationHeadlineRow"),
				oTravelTR = document.getElementById("travelHeadlineRow"),
				oHomeTR = document.getElementById("homeHeadlineRow"),
				oFilmTR = document.getElementById("filmHeadlineRow"),
				oEnvironmentTR = document.getElementById("environmentHeadlineRow"),
				oAutomotiveTR = document.getElementById("automotiveHeadlineRow"),
				oGamingTR = document.getElementById("gamingHeadlineRow"),
				oFoodTR = document.getElementById("foodHeadlineRow");

			if(oNewsTR)oNewsTR.className="hiddenHeadlineChannel";
			if(oEntTR)oEntTR.className="hiddenHeadlineChannel";
			if(oBusinessTR)oBusinessTR.className="hiddenHeadlineChannel";
			if(oSportTR)oSportTR.className="hiddenHeadlineChannel";
			if(oMusicTR)oMusicTR.className="hiddenHeadlineChannel";
			if(oViralTR)oViralTR.className="hiddenHeadlineChannel";
			if(oSciTechTR)oSciTechTR.className="hiddenHeadlineChannel";
			if(oEducationTR)oEducationTR.className="hiddenHeadlineChannel";
			if(oTravelTR)oTravelTR.className="hiddenHeadlineChannel";
			if(oHomeTR)oHomeTR.className="hiddenHeadlineChannel";
			if(oFilmTR)oFilmTR.className="hiddenHeadlineChannel";
			if(oEnvironmentTR)oEnvironmentTR.className="hiddenHeadlineChannel";
			if(oAutomotiveTR)oAutomotiveTR.className="hiddenHeadlineChannel";
			if(oGamingTR)oGamingTR.className="hiddenHeadlineChannel";
			if(oFoodTR)oFoodTR.className="hiddenHeadlineChannel";

			if(!varName) varName = readCookie("blinkxFrontPageWallChannel");

			if(varName == "business" && oBusinessTR) oBusinessTR.className="visibleHeadlineChannel";
			else if (varName == "sport" && oSportTR) oSportTR.className="visibleHeadlineChannel";
			else if (varName == "music" && oMusicTR) oMusicTR.className="visibleHeadlineChannel";
			else if (varName == "viral" && oViralTR) oViralTR.className="visibleHeadlineChannel";
			else if (varName == "scitech" && oSciTechTR) oSciTechTR.className="visibleHeadlineChannel";
			else if (varName == "education" && oEducationTR) oEducationTR.className="visibleHeadlineChannel";
			else if (varName == "travel" && oTravelTR) oTravelTR.className="visibleHeadlineChannel";
			else if (varName == "home" && oHomeTR) oHomeTR.className="visibleHeadlineChannel";
			else if (varName == "film" && oFilmTR) oFilmTR.className="visibleHeadlineChannel";
			else if (varName == "environment" && oEnvironmentTR) oEnvironmentTR.className="visibleHeadlineChannel";
			else if (varName == "automotive" && oAutomotiveTR) oAutomotiveTR.className="visibleHeadlineChannel";
			else if (varName == "gaming" && oGamingTR) oGamingTR.className="visibleHeadlineChannel";
			else if (varName == "food" && oFoodTR) oFoodTR.className="visibleHeadlineChannel";
			else if (varName == "default" && oNewsTR) oNewsTR.className="visibleHeadlineChannel"; // news
			else if (oEntTR)/*varName == "entertainment"*/ oEntTR.className="visibleHeadlineChannel";
		}
		catch(ep)
		{
		}
	}


	function condenastWriteMediaToTable(nItemIn , bRemoveAll)
	{
		var clipsBody	= document.getElementById("id_scratchPadMedia");
		var clipsItems	= clipsBody.getElementsByTagName("tr")  ;
		var TBody		= document.getElementById("id_scratchPadMedia");


		while(clipsItems.length>0 && bRemoveAll == true)
		{
			clipsBody.removeChild(clipsItems[0]);
		}

		if(arrayMediaTitle.length<1)
		{
			var oTR = document.createElement('tr');
			oTR.id = "noResTR";

			var oTD = document.createElement('td');
			oTD.className = "scratchpadEmptyText";
			oTD.innerHTML = "Your playlist is empty.  Drag some videos here to start building your playlist.";

			oTR.appendChild(oTD);
			clipsBody.appendChild(oTR);
		}
		else
		{
			var oNoResTR = document.getElementById('noResTR');
			if(oNoResTR) oNoResTR.parentNode.removeChild(oNoResTR);
			nItem = nItemIn;



			for(  ; nItem <  arrayMediaTitle.length ; nItem++)
			{
				try
				{
					var TRow                = document.createElement('tr');
					condenastWriteMediaToTableItem(TRow , nItem);
					TBody.appendChild(TRow);
				}
				catch(ep)
				{
				}
			}

			nItem = nItemIn;


			for(  ; nItem <  arrayMediaTitle.length ; nItem++)
			{
				var varLayerMask  =  "scratchpadswf" + nItem;

				if(isCorrectFlashVersionInstalled(9,0,28))
				{
					var linkFlashTemp = new SWFObject(varScratchPadImageStore + "/images/linkflash2.swf" , varLayerMask , "40", "30", "7", "#000000");
					linkFlashTemp.addParam("allowScriptAccess", "sameDomain");
					linkFlashTemp.addParam("movie", varScratchPadImageStore + "/images/linkflash2.swf" );
					linkFlashTemp.addParam("quality", "high");
					linkFlashTemp.addParam("wmode", "transparent");
					linkFlashTemp.addParam("bgcolor", "#000000");
					linkFlashTemp.addParam("flashvars", "SizeX=80&Filename="+encodeURIComponent(arrayMediaSWF[nItem])+"&AlternateFilename=" + varScratchPadImageStore + "/" + arrayMediaSWFDefault[nItem]);
					linkFlashTemp.write( varLayerMask );
				}
				else
				{
					replaceContentWithFlashMessage(varLayerMask,replaceContentHtmlMinimal);
				}
			}
		}
	}

	function condenastWriteMediaToTableItem(TRow , nItem)
	{
		var TCol1               = document.createElement('td');
		var TCol2               = document.createElement('td');

		var MediaTitle          = document.createElement('a');
		var MediaDiv            = document.createElement('div');

		var sTitle              = "Add: "+arrayMediaTitle[nItem];
		if(sTitle.length > 49)
		{
			sTitle = sTitle.substring(0,46) + "...";
		}

		MediaTitle.href         = "javascript:void(setCustomAdd("+iCondenastCurrentCompanyID + ","+arrayMediaID[nItem]+",0))";
		MediaTitle.className    = "scratchpadElementTitleDetails";
		MediaTitle.innerHTML    = sTitle;


		MediaDiv.id             = "scratchpadswf" + nItem;
		MediaDiv.height         = "40";
		MediaDiv.width          = "40";
		MediaDiv.style.margin   = "5px";


		//title and remove and swf
		TCol2.appendChild(MediaTitle);
		TCol1.appendChild(MediaDiv);

		TRow.appendChild(TCol1);
		TRow.appendChild(TCol2);

	}

function AreCookiesEnabled()
{
	try
	{
		var 	date 			= new Date()
		var 	sCookieName	= "blinkxCookieTEST" + date.getTime();
		var 	sSavedValue	= "TEST" + date.getTime();

		date.setMilliseconds(date.getMilliseconds()+10000);
		writeCookie(sCookieName, sSavedValue ,date, "/");

		var sReadValue = readCookie(sCookieName);
		return sReadValue && sReadValue==sSavedValue;
	}
	catch(ep)
	{
	}
	return false;
}

//Deprecated, use gup below as in new scripts.
function getRequestParameter(url,name){return gup(name,url);}

function gup(name,url)
{
	name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS="[\\?&]"+name+"=([^&#]*)";
	var regex=new RegExp( regexS );
	var results=regex.exec(url?url:window.location.href);
	if(results==null) return null;
	else return results[1];
}

function addRequestParameter(sURL,sName,sValue)
{
	if(sURL && sName && sValue)
	{
		var r=new RegExp("\\?");
		if(r.test(sURL))
		{
			r=new RegExp("\\?.+");
			if(r.test(sURL)) return sURL+"&"+sName+"="+encodeURIComponent(sValue);
			else return sURL+sName+"="+encodeURIComponent(sValue);
		}
		else return sURL+"?"+sName+"="+encodeURIComponent(sValue);
	}
	return sURL;
}

function lightning_sendBanner(bannerSrc, bannerClickURL,height)
{
	if(typeof handleLightningSendBanner == "function")
	{
		lightning_advertEnded();
		handleLightningSendBanner(bannerSrc, bannerClickURL,height);
	}
}

function lightning_advertEnded()
{
	if(typeof handleLightningAdvertEnded == "function")
	{
		handleLightningAdvertEnded();
	}
}

//Function called form player when needing to open and render an companion banner
function companionBannerHTMLOpen(html,height)
{
	try
	{
		lightning_sendBanner("http://cdn.blinkx.com/images/transparent.gif",null,height);
		var o=document.getElementById('burladvertdiv');
		if(o) o.innerHTML=html;
	}
	catch(e){}
}

//Function called form player when needing to open and render an companion banner
function companionBannerHTMLClose()
{
	try
	{
		lightning_advertEnded();
	}
	catch(e){}
}

function searchStringClean(s)
{
	if(countInstances(s,'"')%2>0) s=s.replace(/\x22/g,' ');
	if(countInstances(s,'(')!=countInstances(s,')')) s=s.replace(/[()]/g,' ');
	return s.replace(/^\s+|\s+$/g, "");
}

function countInstances(string, word)
{
	return string.split(word).length - 1;
}

stopWords = new Array(
		new Array(83,69,88),
		new Array(80,79,82,78),
		new Array(66,79,79,66,73,69,83),
		new Array(78,85,68,69),
		new Array(65,78,65,76),
		new Array(66,65,66,69,83),
		new Array(70,85,67,75),
		new Array(70,85,67,75,73,78,71),
		new Array(65,68,85,76,84),
		new Array(76,69,83,66,79,83),
		new Array(80,85,83,83,89),
		new Array(66,76,79,87,74,79,66),
		new Array(67,82,69,65,77,80,73,69),
		new Array(88,88,88),
		new Array(84,73,84,83),
		new Array(67,85,77),
		new Array(66,79,79,66,83),
		new Array(80,79,82,78,79),
		new Array(86,79,89,69,85,82),
		new Array(77,73,76,70),
		new Array(65,77,65,84,69,85,82),
		new Array(83,89,66,73,65,78),
		new Array(70,65,67,73,65,76),
		new Array(83,80,89,67,65,77),
		new Array(80,79,82,78,83,84,65,82),
		new Array(67,79,67,75),
		new Array(70,65,67,73,65,76,69,68),
		new Array(77,65,83,84,85,82,66,65,84,73,78,71),
		new Array(66,65,66,69),
		new Array(83,72,79,87,69,82),
		new Array(76,65,84,73,78,65),
		new Array(66,82,65,90,73,76,73,65,78),
		new Array(67,72,73,67,75),
		new Array(78,65,75,69,68),
		new Array(76,79,76,73,84,65),
		new Array(65,83,83),
		new Array(76,69,83,66,73,65,78),
		new Array(67,85,77,83,79,78),
		new Array(72,65,82,68,67,79,82,69),
		new Array(79,82,71,65,83,77),
		new Array(83,81,85,73,82,84),
		new Array(67,72,65,78,78,69,76,58,65,68,85,76,84),
		new Array(67,72,65,78,78,69,76,58,72,65,68,85,76,84,53),
		new Array(67,72,65,78,78,69,76,58,80,79,82,78,83,84,65,82),
		new Array(67,72,65,78,78,69,76,58,67,76,85,66,82,69,68,76,73,71,72,84),
		new Array(67,72,65,78,78,69,76,58,80,82,73,86,65,84,69),
		new Array(67,72,65,78,78,69,76,58,84,82,65,70,70,73,67,68,85,68,69),
		new Array(67,72,65,78,78,69,76,58,78,79,79,70),
		new Array(85,80,83,75,73,82,84)
		);

function getWordFromCharCodeArray(aArray)
{
	var sRet = "";
	if(aArray)
	{
		for(var i=0,il=aArray.length; i<il; i++)
		{
			sRet += String.fromCharCode(aArray[i]);
		}
	}
	return sRet;
}

function getCharCodeArrayFromWord(sWord)
{
	var aRet = new Array;
	if(sWord)
	{
		for(var i=0,il=sWord.length; i<il; i++)
		{
			aRet.push(sWord.charCodeAt(i));
		}
	}
	return aRet;
}

function containsStopWords(inText)
{
	var inTextArray = inText.toUpperCase().split(/\s/);
	var found=false;
	for (var k=0,kl=inTextArray.length;!found&&k<kl;k++)
	{
		var inTextWord=inTextArray[k];
		for (var i=0,il=stopWords.length;!found&&i<il;i++)
		{
			var convWord = getWordFromCharCodeArray(stopWords[i]);
			if(inTextWord==convWord)
			{
				found=true;
				break;
			}
		}
	}
	return found;
}

function onSearchKeyUp(event)
{
	if(event.keyCode==13)
	{
		if(bWall)
		{
			wallSearch();
		}
		else
		{
			doSearch();
		}
	}
	return true;
}

function onSearchKeyUpType(event , sType)
{
	if(event.keyCode==13)
	{
		doSearchType(sType);
	}
	return true;
}

function doSearchType(sType)
{
	var varSearch       =     document.getElementById("id_searchtext" + sType ).value;
	varSearch           = encodeURIComponent(varSearch);
	window.location     = "/"+sType+"/"+sType+"Results?query=" +   varSearch;
}

function hideNowThenAd()
{
	try
	{
		document.getElementById("id_newthenAd").style.display = "none";
		var oExpires = new Date();
		oExpires.setTime(oExpires.getTime()+604800000);
		writeCookie('blinkxHideAd', true, oExpires  , "/" , null);
	}
	catch(ep){}
}


function wallSearch()
{
	var varSearch = document.getElementById("id_searchtext").value;

	varSearch = searchStringClean(varSearch);

	if(varSearch.length > 0)
	{
		{
			var url;
			if(readCookie("blinkxSafeSearch2")=="false")
			{
				url = "/wall"+g_ext+"?query=" +   encodeURIComponent(varSearch);
			}
			else if(containsStopWords( document.getElementById("id_searchtext").value) )
			{
				url = "/filter"+g_ext+"?query="+encodeURIComponent(varSearch)+"&url=" +  encodeURIComponent(   "/wall"+g_ext+"?query=" +   encodeURIComponent(varSearch));
			}
			else
			{
				url = "/wall"+g_ext+"?query="+encodeURIComponent(varSearch);
			}

			if(sBlinkxReferrer)
			{
				url += "&blinkxreferrer=" + sBlinkxReferrer;
			}
			location.href = url;
		}
	}
	return false;
}

function wall_OpenMedia(sMediaID)
{
	var adjustHeight = 40;
	var adjustWidth = 15;
	var height = screen.availHeight-adjustHeight;
	var width = screen.availWidth-adjustWidth;
	var winProps = "height="+height+",width="+width+",left=0,top=0,resizable=yes";
	var theWin = window.open("/burl"+g_ext+"?id="+sMediaID+"&referrer=website_wall","theWin");
	theWin.focus();
	blinkx_Stop();
}


var bCalledDoSearch = false;

function doSearch()
{
	try{blinkx_Stop();}catch(ep){};



	var searchValue        = document.getElementById("id_searchtext").value;
	var singleEncodeSearch = encodeURIComponent(searchStringClean(searchValue));
	var doubleEncodeSearch = encodeURIComponent(singleEncodeSearch).replace(/\%2520/g,"+").replace(/\%253A/g,"%3A");

	if(singleEncodeSearch.length)
	{
		var url;
		// redlabel
		if (typeof sRedLabelId!="undefined" && sRedLabelId) {
			if(readCookie("blinkxSafeSearch2")=="false")
			{
				url = '/redlabel/' + sRedLabelId + "/videos/"+doubleEncodeSearch;
			}
			else if(containsStopWords(searchValue))
			{
				url = "/filter"+g_ext+"?query="+singleEncodeSearch+"&url=" +  encodeURIComponent('/redlabel/' + sRedLabelId + "/videos/"+doubleEncodeSearch);
			}
			else
			{
				url = '/redlabel/' + sRedLabelId + "/videos/"+doubleEncodeSearch;
			}
		}
		else {
			if(readCookie("blinkxSafeSearch2")=="false")
			{
				url = "/videos/"+doubleEncodeSearch;
			}
			else if(containsStopWords(searchValue))
			{
				url = "/filter"+g_ext+"?query="+singleEncodeSearch+"&url=" +  encodeURIComponent("/videos/"+doubleEncodeSearch);
			}
			else
			{
				url = "/videos/"+doubleEncodeSearch;
			}
		}

		if(sBlinkxReferrer)
		{
			if(url.indexOf("?")!=-1)
			{
				url += "&blinkxreferrer=" + sBlinkxReferrer;
			}
			else
			{
				url += "?blinkxreferrer=" + sBlinkxReferrer;
			}
		}

		if(typeof g_sAdid != "undefined" && g_sAdid.length)
		{
			if(url.indexOf("?")!=-1)
			{
				url += "&adid=" + g_sAdid;
			}
			else
			{
				url += "?adid=" + g_sAdid;
			}
		}

		if(bCalledDoSearch)
		{
			return ;
		}
		else
		{
			bCalledDoSearch = true;
			location.href = url;
		}
	}
}



function switchBackGround()
{
	if(!g_bWhiteBottomBorder)
	{
		document.body.style.backgroundImage="url('"+g_sStorePrefix+"/images/tv/bkg_body_transparent.gif')";
	}
}

function changeFilter()
{
	var incomingSafeFilter = g_bIsSafeSearchOn;

	var searchValue        = document.getElementById("id_searchtext").value;
	var singleEncodeSearch = encodeURIComponent(searchStringClean(searchValue));
	if(!incomingSafeFilter)
	{
		var oExpires = new Date();
		oExpires.setYear(oExpires.getFullYear()+1);
		writeCookie('blinkxSafeSearch2', true, oExpires, "/" , null);

		/* clean replace: first eliminate unneded params, then clean things like &&, ?&, etc,
		then replace the first & with ?, and finally clean the trailing & or ? */
		var url = location.href.replace(/start=\d*/gi,'').replace(/safefilter=\w*/gi,'').replace(/[?&]+/g,'&').replace(/&/,'?').replace(/[?&]+$/,'').replace(/(http:\/\/.*(\/.*){2})\/\d+/i,'$1');
		if(g_sQueryParam.length<1 && singleEncodeSearch)
		{
			if(url.match(/\&?query=[^&]*/)) url=url.replace(/\&?query=[^&]*/g,"&query="+singleEncodeSearch);
			else
			{
				var aSplitOnQ = url.split(/\?/);
				if(aSplitOnQ.length>1)
				{
					url += "&query="+singleEncodeSearch;
				}
				else
				{
					url += "?query="+singleEncodeSearch;
				}
			}
		}
		else
			url = decodeURIComponent(url);
		location.href = url;
	}
	else
	{
		var forwardurl=location.href;
		if(g_sQueryParam.length<1 && singleEncodeSearch)
		{
			if(forwardurl.match(/\&?query=[^&]*/)) forwardurl=forwardurl.replace(/\&?query=[^&]*/g,"&query="+singleEncodeSearch);
			else
			{
				var aSplitOnQ = forwardurl.split(/\?/);
				if(aSplitOnQ.length>1)
				{
					forwardurl += "&query="+singleEncodeSearch;
				}
				else
				{
					forwardurl += "?query="+singleEncodeSearch;
				}
			}
		}
		var url = "/filter"+g_ext+"?url="+encodeURIComponent(forwardurl);
		if(singleEncodeSearch) url+= "&query="+singleEncodeSearch;
		location.href = url;
	}
}

//Deprecated, keep in as placeholder until all traces removed.
function logChannelClick(a,b,c){}

function wall_search()
{
	window.document.getElementById("newwall").SetVariable("g_search", document.getElementById("squery").value);
	return false;
}

function change_DivRight(content)
{
}

function getN(id){return document.getElementById(id)}

function bbtvopen(url)
{
	document.getElementById("id_bbtv_opener").src = url;
}

function openChannel( nID)
{
	blinkx_Stop();
	window.open("/burl"+g_ext+"?channelid="+nID,'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizeable=1,width=795,height=670');
}

function openChannelViewAll()
{
	var theElement = document.getElementById("id_suggestChannels")
	var selectedPosX = 0;
	var selectedPosY = 0;

	while(theElement != null)
	{
		selectedPosX += theElement.offsetLeft;
		selectedPosY += theElement.offsetTop;
		theElement = theElement.offsetParent;
	}

	window.scrollTo(selectedPosX,selectedPosY);
}
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful.

			// default to the first public version
			version = "WIN 9,0,48,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
				version = -1;
		}
	}

	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;

	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
					tempArrayMinor = descArray[3].split("r");
			} else {
					tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
			flashVer = ControlVersion();
	}
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" ");      // ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];                       // "2,0,0,11"
			versionArray      = tempString.split(",");      // ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

		// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}
// javascript equivalent of php addslashes()
function addslashes(str) {
	return str.replace(/('|"|\\)/g, "\\$1");
}
// javascript equivalent of php stripslashes()
function stripslashes(str) {
	return str.replace(/\\('|"|\\)/g, "$1");
}

//Get data and pass results onto function as single argument
function leaveImpression(sURL)
{
	try
	{
		var oImg=document.getElementById("impressionURL");
		if(oImg) oImpression.parentNode.removeChild(oImpression);

		var oImg=document.createElement("img");
		oImg.style.display="none";

		oImg.width="1";
		oImg.height="1";
		oImg.src=sURL;

		document.body.appendChild(oImg);
	}
	catch(e){}
}

//Temporary alias for leaving an impression from the videowall.
//Remove when function is changed in videowall.swf
wall_call_impressionurl=leaveImpression;

function logAdError(oImg)
{
	if(oImg)
	{
		var src=oImg.src;
		var page=location.href;
		var ua=navigator.userAgent;
		leaveImpression('http://www.blinkx.com/frameadlog?bannerSrc='+encodeURIComponent(src)+'&page='+encodeURIComponent(page)+'&ua='+encodeURIComponent(ua));
	}
}

function qs()
{
	if(typeof window.quantserve=="function")
	{
		window.quantserve=function(){
			if((typeof _qacct =="undefined")||(_qacct.length==0))return;
			if((typeof _qpixelsent !="undefined")&&(_qpixelsent==_qacct))return;
			_qpixelsent=_qacct;
			var r=_qcrnd();
			var ce=(navigator.cookieEnabled)?"1":"0";
			var sr='',qo='',qm='',url='',ref='',je='u',ns='1';
			if(typeof navigator.javaEnabled !='undefined')je=(navigator.javaEnabled())?"1":"0";
			if(typeof _qoptions !="undefined" && _qoptions!=null){for(var k in _qoptions){if(typeof(_qoptions[k])!='string')continue;qo+=';'+k+'='+_qceuc(_qoptions[k]);}_qoptions=null;}
			if(typeof _qmeta !="undefined" && _qmeta!=null){qm=';m='+_qceuc(_qmeta);_qmeta=null;}
			if(self.screen){sr=screen.width+"x"+screen.height+"x"+screen.colorDepth;}
			var d=new Date();
			var dst=_qcdst();
			var dc=_qcgc("__qca");
			var qs="http://pixel.quantserve.com";
			var fp=_qcsc(dc);
			if(window.location && window.location.href)url=_qceuc(window.location.href);
			if(window.document && window.document.referrer)ref=_qceuc("http://www.blinkx.com/?ord="+document.ord);
			/*if(self==top)*/ns='0';
			var img=new Image(1,1);
			img.alt="";
			img.src=qs+'/pixel'+';r='+r+fp+';ns='+ns+';url='+url+';ref='+ref+';ce='+ce+';je='+je+';sr='+sr+';dc='+dc+';dst='+dst+';et='+d.getTime()+';tzo='+d.getTimezoneOffset()+';a='+_qacct+qo+qm;
			img.onload=function() {try{_qvoid();}catch(e){}}
		}
		window._qacct="p-39-CgIWq97RfU";
		window.quantserve();
	}
	else
	{
		setTimeout(qs,500);
	}
}

function dynamicScriptLoad(jsurl)
{
	var s=document.createElement("script");
	s.src=jsurl;
	s.type="text/javascript";
	document.getElementsByTagName("head")[0].appendChild(s);
}

var oDeutscheWelleFrame=null;
function appendDeutscheWelleFrame(parentElement)
{
	if(parentElement)
	{
		if(!oDeutscheWelleFrame)
		{
			oDeutscheWelleFrame=document.createElement("iframe");
			oDeutscheWelleFrame.src="/thirdparty/deutschewelle";
			oDeutscheWelleFrame.frameborder="0";
			oDeutscheWelleFrame.width="440";
			oDeutscheWelleFrame.height="120";
			oDeutscheWelleFrame.style.border="1px solid #336699";
		}
		parentElement.appendChild(oDeutscheWelleFrame);
	}
}



function getSafeNodevalue(node)
{
	if(node && node.firstChild && node.firstChild.nodeValue)
	{
		return node.firstChild.nodeValue;
	}
	return "";
}


var spellingHttp=null;
function getExternalSpellingSuggestions(encodedSearchText)
{
	if(encodedSearchText && encodedSearchText.length && encodedSearchText.indexOf("%3A")==-1)
	{
		var url="/thirdparty/yahoospelling?query="+encodedSearchText;

		spellingHttp=initXMLHttpClient();
		spellingHttp.open("GET",url,true);
		spellingHttp.onreadystatechange=handleSpellingResponse;
		spellingHttp.send(null);
	}
}

function handleSpellingResponse()
{
	try
	{
		if(spellingHttp.readyState==4)
		{
			if(spellingHttp.status==200)
			{
				xml=spellingHttp.responseXML;
				var aSuggestions=new Array,
					sugestionList=xml.getElementsByTagName("suggestion");
				for(var i=0,iMax=sugestionList.length;i<iMax;i++)
				{
					suggestNode=sugestionList.item(i);
					suggestion=getSafeNodevalue(suggestNode);
					if(suggestion) aSuggestions.push(suggestion);
				}
				if(aSuggestions.length) displaySpellingSuggestions(aSuggestions);
			}
		}
	}
	catch(e){}
}

function displaySpellingSuggestions(aSuggestions)
{
	try
	{
		if(aSuggestions.length)
		{
			var spelling=aSuggestions[0];

			var metaTop=document.getElementById("resultsContainer");
			if(metaTop)
			{
				var oDiv=document.createElement("div"),oA=document.createElement("a");
				oDiv.className="spelling";
				oDiv.appendChild(document.createTextNode("Did You Mean \""));
				oA.title="Search for "+spelling+" videos";
				oA.href="/videos/"+encodeURIComponent(spelling);
				oA.appendChild(document.createTextNode(spelling));
				oDiv.appendChild(oA);
				oDiv.appendChild(document.createTextNode("\"?"));
				if(metaTop.hasChildNodes()) metaTop.insertBefore(oDiv,metaTop.firstChild);
			}
		}
	}
	catch(e){}
}

function jumpToBBTVUrl(media_position)
{
	if(arrayBBTVBurlURLs && arrayBBTVBurlURLs[media_position] && arrayBBTVBurlURLs[media_position].length)
	{
		try{blinkx_Stop();}catch(e){}
		location.href=arrayBBTVBurlURLs[media_position];
	}
}

function hideHeadlineBanner()
{
	var aSpans = document.getElementsByTagName("span");
	var oSpan;
	for(var i=0,iMax=aSpans.length;i<iMax;i++)
	{
		oSpan = aSpans[i];
		if(oSpan && oSpan.className.match(/headlineBannerMore/i))
		{
			oSpan.parentNode.removeChild(oSpan);
		}
	}

	var aTRs = document.getElementsByTagName("tr");
	var oTR;
	for(var i=0,iMax=aTRs.length;i<iMax;i++)
	{
		oTR = aTRs[i];
		if(oTR && oTR.className.match(/headlineBannerRow/i))
		{
			oTR.parentNode.removeChild(oTR);
		}
	}
	var aDivs = document.getElementsByTagName("div");
	var oDiv;
	for(var i=0,iMax=aDivs.length;i<iMax;i++)
	{
		oDiv = aDivs[i];
		if(oDiv && oDiv.className.match(/.+WithBanner/i))
		{
			oDiv.className = oDiv.className.substring(0,oDiv.className.length-"WithBanner".length);
		}
	}

	//Locate the headlineOverflow Elements
	aDivs = document.getElementsByTagName("div");
	var aChildDivs,oChildDiv;
	for(var i=0,iMax=aDivs.length;i<iMax;i++)
	{
		oDiv = aDivs[i];
		if(oDiv.className.match(/headlineOverflow.*/i))
		{
			aChildDivs = oDiv.getElementsByTagName("div");
			for(var j=0,jMax=aChildDivs.length;j<jMax;j++)
			{
				oChildDiv = aChildDivs[j];
				if(oChildDiv.className.match(/.+Hidden/i))
				{
					oChildDiv.className = oChildDiv.className.substring(0,oChildDiv.className.length-"hidden".length);
				}
			}
		}
	}
}

// =====================
// EVENTUTIL.JS
var EventUtil=new Object;
EventUtil.addEventHandler=function(oTarget,sEventType,fnHandler){
	if(oTarget)
	{
		if(oTarget.addEventListener)oTarget.addEventListener(sEventType,fnHandler,false);
		else if(oTarget.attachEvent)oTarget.attachEvent("on"+sEventType,fnHandler);
		else oTarget["on"+sEventType]=fnHandler;
	}
};

EventUtil.removeEventHandler=function(oTarget,sEventType,fnHandler){
	if(oTarget)
	{
		if(oTarget.removeEventListener)oTarget.removeEventListener(sEventType,fnHandler,false);
		else if(oTarget.detachEvent)oTarget.detachEvent("on"+sEventType,fnHandler);
		else oTarget["on"+sEventType]=null;
	}
};

EventUtil.formatEvent=function(oEvent){
	if(typeof oEvent.charCode=="undefined")
	{
		oEvent.charCode=(oEvent.type=="keypress")?oEvent.keyCode:0;
		oEvent.isChar=(oEvent.charCode>0);
	}
	if(oEvent.srcElement&&!oEvent.target)
	{
		oEvent.eventPhase=2;
		oEvent.pageX=oEvent.clientX+document.body.scrollLeft;
		oEvent.pageY=oEvent.clientY+document.body.scrollTop;
		if(!oEvent.preventDefault)oEvent.preventDefault=function(){this.returnValue=false;};
		if(oEvent.type=="mouseout")oEvent.relatedTarget=oEvent.toElement;
		else if(oEvent.type=="mouseover")oEvent.relatedTarget=oEvent.fromElement;
		if(!oEvent.stopPropagation)oEvent.stopPropagation=function(){this.cancelBubble=true;};
		oEvent.target=oEvent.srcElement;
		oEvent.time=(new Date).getTime();
	}
	return oEvent;
};

EventUtil.getEvent=function(){
	if(window.event)return this.formatEvent(window.event);
	else return EventUtil.getEvent.caller.arguments[0];
};
// =====================

//Viewable height
function windowHeight()
{
	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;
}

function scrollHeight()
{
	if(window.innerHeight && window.scrollMaxY)
	{// Firefox
		return window.innerHeight+window.scrollMaxY;
	}
	else if(document.body.scrollHeight>document.body.offsetHeight)
	{ // all but Explorer Mac
		return document.body.scrollHeight;
	}
	else
	{ // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		return document.body.offsetHeight;
	}
}

//Switching Background Advert
function setBackgroundAd(image,url,impressionUrl)
{
	var oBodyContainer=document.getElementById("bodyContainer");
	if(oBodyContainer)
	{
		//add cachbuster to url an impressionurl
		if(!getRequestParameter(url,"nocache"))
		{
			url=addRequestParameter(url,"nocache",parseInt(Math.random()*10000000));
		}
		if(!getRequestParameter(impressionUrl,"nocache"))
		{
			impressionUrl=addRequestParameter(impressionUrl,"nocache",parseInt(Math.random()*10000000));
		}


		//Max Height to set
		var adHeight=Math.max(windowHeight(),scrollHeight());

		//Leaves ImpressionURL
		if(impressionUrl && impressionUrl.length) leaveImpression(impressionUrl);

		//Sets the Image
		oBodyContainer.style.backgroundAttachment="fixed";
		oBodyContainer.style.backgroundImage="url("+image+")";
		oBodyContainer.style.backgroundRepeat="no-repeat";
		oBodyContainer.style.backgroundPosition="top center";
		oBodyContainer.style.height=adHeight+"px";

		//Handles clicks on backgrounds container only
		EventUtil.addEventHandler(document.documentElement,"click",function(e)
		{
			if(!e) var e=window.event;
			if(e)
			{
				var target=(e.target)?e.target:e.srcElement;
				if(target==document.documentElement || target==document.body || (target.id && target.id=="bodyContainer"))
				{
					try{blinkx_Stop();}catch(ep){};
					location.href=url;
				}
			}
		});
	}
}

//Switching Background Advert for multiple impressions
function setBackgroundAdMultipleImp(image,url,aImpressionURLs)
{
	var oBodyContainer=document.getElementById("bodyContainer");
	if(oBodyContainer)
	{
		//add cachbuster to url an impressionurl
		if(!getRequestParameter(url,"nocache"))
		{
			url=addRequestParameter(url,"nocache",parseInt(Math.random()*10000000));
		}

		//Max Height to set
		var adHeight=Math.max(windowHeight(),scrollHeight());

		//Leaves ImpressionURLs from array if present, otherwise, use single impressionURL
		if(aImpressionURLs && aImpressionURLs.length && aImpressionURLs.length>0)
		{
			var impURL,i;
			for(i=0,iMax=aImpressionURLs.length;i<iMax;i++)
			{
				impURL=aImpressionURLs[i];
				if(!getRequestParameter(impURL,"nocache"))
				{
					impURL=addRequestParameter(impURL,"nocache",parseInt(Math.random()*10000000));
				}
				if(impURL) leaveImpression(impURL);
			}
		}

		//Sets the Image
		oBodyContainer.style.backgroundAttachment="fixed";
		oBodyContainer.style.backgroundImage="url("+image+")";
		oBodyContainer.style.backgroundRepeat="no-repeat";
		oBodyContainer.style.backgroundPosition="top center";
		oBodyContainer.style.height=adHeight+"px";

		//Handles clicks on backgrounds container only
		EventUtil.addEventHandler(document.documentElement,"click",function(e)
		{
			if(!e) var e=window.event;
			if(e)
			{
				var target=(e.target)?e.target:e.srcElement;
				if(target==document.documentElement || target==document.body || (target.id && target.id=="bodyContainer"))
				{
					try{blinkx_Stop();}catch(ep){};
					location.href=url;
				}
			}
		});
	}
}

function setFrontPageCookie()
{
	writeCookie('fp', '1', null, "/" , '.blinkx.com');
}

