/* cross broswer object retrieval */
var DOM = (document.getElementById)? true : false;
var OP = (window.opera)? true : false;
var NS = (window.outerWidth && !OP)? true : false;
var NS4 = (NS && !DOM)? true : false;
var IE = (document.all && !OP)? true : false;
var IE4 = (IE && !DOM)? true : false;
var isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
function myObj(objName){
	if(IE4)		{return document.all[objName];}
	else if(DOM){return document.getElementById(objName);}
	else if(NS4){return document.layers[objName];}
}

try{
if(document.uniqueID && !window.XMLHttpRequest ){
	document.execCommand("BackgroundImageCache",false,true) // fixes IE6 background image cache problems
}
}catch(e){}

/*	COOKIE SET/GET */
function SetCookie(name,value,days){
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function GetCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

/* HELPERS */
function ShowLayer(obj)	{obj.style.display="block";}
function HideLayer(obj)	{obj.style.display="none";}

function Redirect(url)	
{
    try
    {
        //Override bitrate requests to be 300 whenever site is in media player.
        var affidIsSet = GetCookie("affid");
        if(affidIsSet == "219")
        {
            var reg = new RegExp("bitrate=700","g");
            url = String(url).replace(reg, "bitrate=300");
        }
    }
    catch(e)
    {}
    window.location.href = url;
}
function goToUrl(url)	{Redirect(url);}
function trim(str)		{return str.replace(/^\s*|\s*$/g,"");}

function gettop(thisobj) {yacc=0;tobj="";do{yacc+=parseInt(thisobj.offsetTop);try{thisobj=thisobj.offsetParent;tobj=thisobj.tagName}catch(e){break}}while(tobj!="HTML");return yacc}
function getleft(thisobj) {xacc=0;tobj="";do{xacc+=parseInt(thisobj.offsetLeft);try{thisobj=thisobj.offsetParent;tobj=thisobj.tagName}catch(e){break}}while(tobj!="HTML");return xacc}
function getbot(thisobj) {hacc=parseInt(thisobj.offsetParent.offsetHeight);yacc=gettop(thisobj);return yacc+hacc}
function getright(thisobj) {wacc=parseInt(thisobj.offsetParent.offsetWidth);xacc=0;getleft(thisobj);return xacc+wacc}

function openpopup(thisurl,thisname) {popup = window.open(thisurl,thisname,"channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,width=529,height=386,top=10,left=10")}


function tabNext(obj,target){
	var e = window.event;
	if ((e.which && e.which >= 65 && e.which<=105) || (e.which && e.which >= 48 && e.which<=57) || (e.keyCode && e.keyCode>= 65 && e.keyCode<=105)|| (e.keyCode && e.keyCode>= 48 && e.keyCode<=57)){
		if (obj.getAttribute&&obj.value.length==obj.getAttribute("maxlength")){
			try {target.focus()} catch(e) {}
		}
	};
}
function InsertCharacter(obj,chr,pos){
	var e = window.event;
	if ((e.which && e.which >= 65 && e.which<=105) || (e.which && e.which >= 48 && e.which<=57) || (e.keyCode && e.keyCode>= 65 && e.keyCode<=105)|| (e.keyCode && e.keyCode>= 48 && e.keyCode<=57)){
		if (obj.value.length==5){obj.value+=chr}
	};
}




/*Query Strings*/
function QueryString(doc,fromFormAction,fromString){
	var query = "";
	if (fromString!=null) {
		query = fromString;
	}else if (fromFormAction!=null){
		var index = 1;
		query = document.forms[0].action;
		index = query.indexOf("?")
		query = query.substring(index+1)
	} else {
		if (!doc) {doc = window};
		query = doc.location.search.substring(1);
	}
	var pairs = query.split("&");
	this.keys = new Array();
	this.values = new Array();

	for (var i=0;i<pairs.length;i++){
		var pos = pairs[i].indexOf('=');

		if (pos >= 0){
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			this.keys[this.keys.length] = argname.toLowerCase();
			this.values[this.values.length] = value;
			//alert(argname + ' ' + value);
		}
	}

};
QueryString.prototype.select = function(key){
	var value = null;

	for (var i = 0; i < this.values.length; i++)
	{
		if ( this.keys[i].toLowerCase() == key.toLowerCase())
		{
			value = this.values[i];
			return value;
			break;
		}
	}

	return value;
};


//alows to bind property of one object to another (clone)
Function.prototype.bind = function(object) {
	var __method = this;
	return function() {
		return __method.apply(object, arguments);
	}
}

// Object Insertion
function insertElementNextTo(obj,element,classname){
    var d = document.createElement(element);
	d.className = classname;
    if (obj){
        var parentObj = obj.parentNode;
        parentObj.insertBefore(d, obj);
    }
}
function insertElementInTo(obj,element,classname,src){
    var d = document.createElement(element);
    if (classname!=''){d.className = classname;};
    if (src!=''){d.src = src;};
	obj.appendChild(d)
	return d
}



// returns current style of an object
function getStyle(el,styleProp){
	var x = el;
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}


/* Opacity Object */
function opacityObject(obj,step,evtType,evtFunction){
	this.obj = obj;
	this.step = 25;
	//if (evtType){evtType=''};
	//if (evtFunction){evtType=''}
	this.evtType = evtType;
	this.evtFunction = evtFunction;
	this.evtFunctionOG = evtFunction;
	this.alpha = this.getAlpha();
	this.fadeID = 0
	this.fadeWaitID = 0

};

opacityObject.prototype.removeEvent= function(){
	if (this.evtType){
		//if (eval('this.obj.on' + this.evtType)){
			//alert(eval('this.obj.on' + this.evtType))
		//}
		//eval('this.obj.on' + this.evtType +'=""')

	}

}

opacityObject.prototype.restoreEvent= function(){
	if (this.evtType){
		 //alert('restore');
		//eval('this.obj.on' + this.evtType +'=' + this.evtFunction)
	}
}


opacityObject.prototype.fadeIn= function(){
	if (this.fadeID ==0){
		//this.fadeWaitID =0
		this.fadeStart = 0;
		this.fadeFinish = 110;
		this.fadeIncrement= 25;
		this.fadeIncemenetIncrease = 5
		this.removeEvent();

		this.doFade()
	} else {
		if (this.fadeWaitID ==0){
			//setTimeout(this.fadeIn.bind(this),50);
		}
	}
}
opacityObject.prototype.fadeOut= function(){
	if (this.fadeID ==0){
		if (this.fadeWaitID!=0){
			//clearInterval(this.fadeWaitID)
		}
		this.fadeWaitID =0
		this.fadeStart = 100;
		this.fadeFinish = 0;
		this.fadeIncrement= -25;
		this.fadeIncemenetIncrease = -5
		this.removeEvent();

		this.doFade()
	} else {
		if (this.fadeWaitID ==0){
			//this.fadeWaitID = setInterval(this.fadeOut.bind(this),500);
		}
	}

}

opacityObject.prototype.doFade= function(){
	if (this.fadeStart!=this.fadeFinish  ){

			this.fadeStart = this.fadeStart + this.fadeIncrement

			if ((this.fadeIncrement >=0 && this.fadeStart>this.fadeFinish)|| (this.fadeIncrement <=0 && this.fadeStart<this.fadeFinish)){
				this.fadeStart=this.fadeFinish;
			};

			this.alpha =this.fadeStart
			this.changeOpacity(this.alpha)

			this.fadeID = setTimeout(this.doFade.bind(this),1);




		//}
	}else {

		//alert('fadeDone:' + this.fadeID)
		//alert(this.alpha)
		this.isActive = false;
		this.fadeStart=this.fadeFinish;

		clearTimeout(this.fadeID)

		this.fadeID = 0

		//this.changeOpacity(this.fadeFinish)

		this.restoreEvent();

		return

	}



}


opacityObject.prototype.getAlpha = function(){
	var toReturn = 0;
	try{
		toReturn = Math.round(this.obj.filters.alpha.opacity)
	}catch (ex){
		toReturn = this.obj.style.opacity
		//alert(this.obj.style.visibility);
		if (toReturn ==''){
			if (getStyle(this.obj,'visibility')=='hidden'){
				toReturn = 0
			} else { toReturn=100 }
		}

	}
	if ( isNaN(toReturn) ){toReturn = 100}
	return toReturn
}

opacityObject.prototype.changeOpacity = function(value){
	this.obj.style.opacity = value/100;
	this.obj.style.filter = 'alpha(opacity=' + value + ')';

}
/* Opacity Object */





/* Keyboard Tracking */
function onKeyPressed(submitButton){
	e = evtKey;
	if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)){
		submitButton.click();
		return false;
	} else {
		return true;
	}
}

var evtKey = null;	document.onkeydown = registerStroke;	document.onkeypres = registerStroke;	document.onkeyup = registerStroke;
function registerStroke(e){
	if (!e) e = window.event;
	evtKey = e
	return true;
}

function onKeyPressedSearch(){
	e = evtKey;
	if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)){
		MiniSearch();
		return false;
	} else {
		return true;
	}
}


/* Spacing on Selects*/


function fixSelectSpacing(drp){
	var space = /_/g;
	for (var i = 0; i < drp.length; i++) {
		drp.options[i].text = drp.options[i].text.replace(space,"   ")
	}
}


// Returns first element found with the specified class name
function getElementsByClassName(container,className,elementType) {
	var elm = myObj(container).getElementsByTagName(elementType);
	//var ar[] = new Array()
	//var c = 0
	for (var i=0;i<elm.length;i++){
		if (elm[i].className==className){
			return elm[i]
			//ar[c] = elm[i];
			//c+=1;
		}
	}
	return null
}

function getQueryValue(qName) {
    try {
        var qValue1 = null;
        var qstring1 = location.search.split("?")[1];
        var queries1 = qstring1.split("&");
        for (var i = 0; i< queries1.length; i++) {
            var query1 = queries1[i].split("=");
            if (query1[0] == qName) {
                qValue1 = query1[1];
                return qValue1;
            }
        }
    }
    catch (err) {
        return null;
    }
}

function showDiv(dName) {
    var myDiv = document.getElementById(dName);
    if (myDiv) {
        myDiv.style.visibility = "visible";
    }
}

function setHREF(id, url) {
    var myAnchor = document.getElementById(id);
    if (myAnchor) {
        myAnchor.href = url;
    }
}


function isValidDRMClient(){
	return true;
	if (window.navigator.userAgent.indexOf('Windows NT 5.1')>-1 && window.navigator.userAgent.indexOf('Media Center')==-1) {
		if (isIBXInstalled()) {
			if (isValidFormatSDK()) return true;
		}
		return false;
	}
	return true
}


function isIBXInstalled()   {
	return true;
    try{
        var nObj = null;
	    var redirectURL = '';
	    if (window.ActiveXObject){
		    nObj = new ActiveXObject("DRM.GetLicense.1"); //clsid:A9FC132B-096D-460B-B7D5-1DB0FAE0C062
	    }
	    if (nObj){
		    var drmVer = nObj.GetDRMSecurityVersion();
		    var ibxV = drmVer.split(".");
		    if ((ibxV[0] == '2' && ibxV[1] >= '8') || (ibxV[0] > '2')){
			    return true;
		    } else {
			    return false
		    }
		    nObj = null
	    }
	} catch (e) { }
	return false;
}

function getIBXVer() {
    try {
        var nObj = null;
	    if (window.ActiveXObject){
		    nObj = new ActiveXObject("DRM.GetLicense.1"); //clsid:A9FC132B-096D-460B-B7D5-1DB0FAE0C062
	    }
	    if (nObj){
		    var drmVer = nObj.GetDRMSecurityVersion();
		    return drmVer;
		}
		else {
		    return 0;
		}
	} catch (err) { return 0;}
}

function getWmpClientVer(){
    var nObj = null;
	var clientVersion = '';
	try {
	    if (window.ActiveXObject){
		    nObj = new ActiveXObject("DRM.GetLicense.1"); //clsid:A9FC132B-096D-460B-B7D5-1DB0FAE0C062
	    }
	    if (nObj){
		    var drmVer = nObj.GetDRMSecurityVersion();
		    clientVersion = nObj.GetDRMVersion();
	    }
	} catch (err) { }
	return clientVersion;
}



function isValidFormatSDK(){
	return true
    var nObj = null;
	var clientVersion = '';
	try {
	    if (window.ActiveXObject){
		    nObj = new ActiveXObject("DRM.GetLicense.1"); //clsid:A9FC132B-096D-460B-B7D5-1DB0FAE0C062
	    }
	    if (nObj){
		    var drmVer = nObj.GetDRMSecurityVersion();
		    clientVersion = nObj.GetDRMVersion();
		    nObj = null;
		    return isValidFormatSDK_c(clientVersion);
	    }
	    else return false;
	} catch (err) {return false;}
}


function isValidFormatSDK_c(clientVersion) {
    try{
		var v = clientVersion.split(".")

		if (window.navigator.userAgent.indexOf('Media Center')>-1) {return true} //mce rollup 2
		if (window.navigator.userAgent.indexOf('Windows NT 5.2')>-1) {return true}  //win2k3 server

		if (window.navigator.userAgent.indexOf('Windows NT 5.1')>-1) {
			if (v[0] == 9) {return false} //version 9.0.*
			if (v[0] == 10 && v[3] < 3802) {return false} //version 9.5 no patch
			if 	(v[0] == 11 && v[3] < 5043) {return false}
		}

		return true
	} catch (e) { return false;	}
}




function getBackground(objName){
	return getStyle($(objName),'backgroundImage').replace('url("','').replace('")','')
}

colshow = 0
function goright(goamt) {
if (colshow==1) {return}
fx('scrolldiv',10,false,null,'left,0,-'+goamt)
fx('gorightimg',10,false,null,'opacity,100,30')
fx('goleftimg',10,false,null,'opacity,30,100')
colshow = 1
}

function goleft(goamt) {
if (colshow==0) {return}
fx('scrolldiv',10,false,null,'left,-'+goamt+',0')
fx('gorightimg',10,false,null,'opacity,30,100')
fx('goleftimg',10,false,null,'opacity,100,30')
colshow = 0
}

