//writing the tv object
 function writeobj(file,type,flashvars,tvor){
	 fileurl = '';
  	//width = (window.screen.width / 2) - 50;
	 for (i = 0; i <= file.length; i++) {
		fileurl = file.charAt (i) + fileurl
	  } 
	//Adding randon number
	//fileurl = fileurl + '?r=' + Math.random();
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  //width = (window.innerWidth / 2) - 50;
	  width = 450;
	 }
	 else if (navigator.appName.indexOf("Microsoft")!=-1) {
	 	width  = (document.body.offsetWidth / 2) -50;
	 }
	 else {
	 	width = 450;
	 }
	}
	if (tvor == 0 || tvor == 2 || tvor == 3)
	height = (width - 150);
	else
	height = 40;
  	asx = '<object width="'+width+'" height="'+height+'" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" name="mediaplayer1"  id="mediaplayer1">';
	asx += ' <param name="Filename" value="'+fileurl+'">';
	asx += '<param name="EnableContextMenu" value="1">';
	asx += ' <param name="AutoStart" value="True">';
	asx += ' <param name="ShowControls" value="true">';
	asx += '<param name="ShowStatusBar" value="true">';
	asx += ' <param name="ShowDisplay" value="false">';
	asx += '<param name="volume" value="100">';
	asx += '<param name="uiMode" value="full">';
	asx += '<param name="windowlessVideo" value="0">';
	asx += '<param name="fullScreen" value="-1">';
	asx += '<PARAM NAME="EnableFullScreenControls" VALUE="true"> ';
	asx += '<param name="AutoRewind" value="True">';
	asx += '<param name="enableErrorDialogs" value="0">';
	asx += '<embed pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&" src="'+fileurl+'" width='+width+'" height="'+height+'" autostart="True" showcontrols="True" showstatusbar="False"  showdisplay="true" autorewind="True" enableContextMenu=1 windowlessVideo=1 uiMode=full stretchToFit=1 fullscreen=0> </embed>';
	asx += '</object>';
	ram = '<EMBED src="'+fileurl+'" width="'+width+'" height="'+height+'" ';
	ram += ' type=audio/x-pn-realaudio-plugin AUTOSTART="TRUE" ';
	ram += ' CONTROLS="imagewindow" EnableFullScreenControls="true">';
	ram += '<EMBED SRC="'+fileurl+'" type=audio/x-pn-realaudio-plugin CONTROLS=ControlPanel WIDTH="'+width+'" HEIGHT="25" CONSOLE=1 NOJAVA=true >';
	
	swf = '<embed type="application/x-shockwave-flash" ';
	swf += 'src="' +fileurl+'?r=' + Math.random()+'" ';
	swf += 'bgcolor="#2b333c" quality="high" allowfullscreen="true" allowscriptaccess="always" ';
	swf += 'wmode="window" flashvars="'+flashvars+'" ';
	swf += 'height="'+height+'" width="'+width+'"></embed>';
	
	dish2net='<div id="Dish2net" style="width:350;height:262px;text-align:center;background-color:black;"><object id="Dish2netPlayer" data="data:application/x-silverlight," type="application/x-silverlight-2" width="'+width+'"  height="'+height+'" style="margin:0 auto;">' ;
	dish2net+='<param name="enableHtmlAccess" value="true"/>';
	dish2net+='<param name="source" value="'+fileurl+'"/>';
	dish2net+='<param name="onerror" value="onSilverlightError" />';
	dish2net+='<param name="background" value="black" />';
	dish2net+='<param name="minRuntimeVersion" value="2.0.31005.0" />';
	dish2net+='<param name="initParams" value="'+flashvars+'"/>';
	dish2net+='<param name="autoUpgrade" value="true" />';
	dish2net+='<a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"><img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/></a>';
	dish2net+='</object><iframe style=\'visibility:hidden;height:0;width:0;border:0px\'></iframe> </div>';
	
	
	if (type == 'asx')
	writit(asx,'obj');
	else if (type == 'ram')
	writit(ram,'obj');
	else if (type == 'swf')
	writit(swf,'obj');
	else if (type == 'xap')
	writit(dish2net,'obj');
  }
  
 
  
  function writit(text,id)
	{
		if (document.getElementById)
		{
			x = document.getElementById(id);
			x.innerHTML = '';
			x.innerHTML = text;
		}
		else if (document.all)
		{
			x = document.all[id];
			x.innerHTML = text;
		}
		else if (document.layers)
		{
			x = document.layers[id];
			text2 = '<P CLASS="testclass">' + text + '</P>';
			x.document.open();
			x.document.write(text2);
			x.document.close();
		}
	}

 //Bookmark script
function bookmarkthis(){
	var BookmarkURL=location.href;
	var BookmarkTitle="3arabTV.com"
	
	// If the browser is Internet Explorer
	if (document.all)
	{
			// Add to Favorites (Internet Explorer)
			window.external.AddFavorite(BookmarkURL,BookmarkTitle)
	}
	else
	{
			// Add to Bookmarks (Mozilla Firefox)
			window.sidebar.addPanel(BookmarkTitle, BookmarkURL, '');
	}
}

//script to change the CSS upon to the browser width

function dynamicLayout(){
    var browserWidth = getBrowserWidth();

    //Load Thin CSS Rules
    if (browserWidth < 1000){
        changeLayout("thin");
    }
	else{
		changeLayout("wide");
		}
}
function getBrowserWidth(){
    if (window.innerWidth){
        return window.innerWidth;}  
    else if (document.documentElement && document.documentElement.clientWidth != 0){
        return document.documentElement.clientWidth;    }
    else if (document.body){return document.body.clientWidth;}      
        return 0;
}

function changeLayout(description){
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++){
if(a.getAttribute("title") == description){a.disabled = false; }
else if(a.getAttribute("title") != "default"){a.disabled = true;}
//else {a.disabled = true;}
}
}
//addEvent() by John Resig
function addEvent( obj, type, fn ){ 
   if (obj.addEventListener){ 
      obj.addEventListener( type, fn, false );
   }
   else if (obj.attachEvent){ 
      obj["e"+type+fn] = fn; 
      obj[type+fn] = function(){ obj["e"+type+fn]( window.event ); } 
      obj.attachEvent( "on"+type, obj[type+fn] ); 
   } 
} 

function getActiveStyleSheet() {
var i, a;
 for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
  if(a.getAttribute("rel").indexOf("style") != -1
  && a.getAttribute("title")
  && !a.disabled) alert(a.getAttribute("title"));
  }
  return null;
}

//Run dynamicLayout function when page loads and when it resizes.
addEvent(window, 'load', dynamicLayout);
addEvent(window, 'resize', dynamicLayout);

/************ End of Style javascript code **********************/

