﻿function $(element) {
  return document.getElementById(element);
}



//------------------------------------------------------------
if( SagoolTv == undefined ){
	var SagoolTv = function(){}
}





//WINDOW
SagoolTv.Browser = {
	
	
	//WINDOW
	getWindowWidth:function(){
		if(window.innerWidth){
			return window.innerWidth;
		}else if(document.documentElement && document.documentElement.clientWidth){
			return document.documentElement.clientWidth;
		}else if ( document.body && document.body.clientWidth){
			return document.body.clientWidth;
		}
	},

	getWindowHeight:function(){
		if(window.innerHeight){
			return window.innerHeight;
		}else if(document.documentElement && document.documentElement.clientHeight){
			return document.documentElement.clientHeight;
		}else if ( document.body && document.body.clientHeight){
			return document.body.clientHeight;
		}
	}
	
	
	
}



//FLASH
SagoolTv.Flash = {
	/**
	* create sagoolTV Flash Object
	* @param    flashvars
	* @param    params
	* @param    attributes
	**/
	createFlashObject:function( flashvars , params , attributes ){
	    //document.write( escape( _getUrchinFlashVars() ) );
	    if( flashvars == undefined || flashvars == null ){
	        flashvars = new Object();
	    }
		//FlashVars
	    flashvars._urchinVariables = escape( SagoolTv.Flash._getUrchinFlashVars() );
	    swfobject.embedSWF( "/swf/CoSagoolTv.swf?c=" + ( new Date() ).getTime() , "content", "100%", "100%", "9.0.0" , null , flashvars , params , attributes );
		
		
		//alert( swfobject.hasFlashPlayerVersion("9.0.0") );
		
	},
	
	
	/**
	* Wrapped get Urchin Variables
	* 
	**/
	_getUrchinFlashVars:function(page) {
	    var p,s="",pg=_udl.pathname+_udl.search;
	    if (page && page!="") pg=escape(page);
	    _ur=_ubd.referrer;
	    if (!_ur || _ur=="") { _ur="-"; }
	    else {
	        p=_ur.indexOf(_ubd.domain);
	        if ((p>=0) && (p<=8)) { _ur="0"; }
	        if (_ur.indexOf("[")==0 && _ur.lastIndexOf("]")==(_ur.length-1)) { _ur="-"; }
	    }
	    s+="&utmn="+_uu;
	    if (_ufsc) s+=_uBInfo(page);
	    if (_uctm && (!page || page=="")) s+=_uCInfo();
	    if (_utitle && _ubd.title && _ubd.title!="") s+="&utmdt="+escape(_ubd.title);
	    if (_udl.hostname && _udl.hostname!="") s+="&utmhn="+escape(_udl.hostname);
	    if (!page || page=="") s+="&utmr="+_ur;
	    s+="&utmp="+pg;
	    if (_userv==0 || _userv==2) {
	        return "utmwv="+_uwv+s;
	    }
	    if (_userv==1 || _userv==2) {
	        return "utmwv="+_uwv+s+"&utmac="+_uacct+"&utmcc="+_uGCS();
	    }
	    return;
	}
}





window.onresize = function(){
	var windowW = SagoolTv.Browser.getWindowWidth();
	var windowH = SagoolTv.Browser.getWindowHeight();
    var sh= 95;
	var w = Math.max( 750 , ( windowW - 5 ) );
	var h = Math.max( 450 , ( windowH - 5 - sh - 1 ) );
	
	$( "contentContainer" ).style.width  = w + "px";
	$( "contentContainer" ).style.height = h + "px";
}

