//Full screen function

function playfullscreen(movielink){
	width = screen.width;
	height = screen.height;
 window.open ("http://localhost/new3arab/3arabtv/fullscreen.php?id="+movielink+"&w="+height,"3arabwindow",'scrollbars=no,width='+height+',height='+height+',left=0,top=0');
}

 function writemovie(movielink,type){
	movielink = escape(movielink);
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  //width = (window.innerWidth / 2) - 50;
	  width = 400;
	 }
	 else if (navigator.appName.indexOf("Microsoft")!=-1) {
	 	width  = (document.body.offsetWidth / 2) -50;
	 }
	 else {
	 	width = 400;
	 }
	}
	height = width;
		if(type == 'flv' || type == 'youtube')
	{
		movie = '<embed src="http://static.3arabchannel.com/3arabtv/scripts/player/player.swf" allowfullscreen="true"' +
		'type="application/x-shockwave-flash" flashvars="file='+movielink+'&logo=http://static.6rbiyat.com/3arabtv/scripts/player/logo.png&autostart=true" width="'+width+'" height="'+height+'" bgcolor="#000000"></embed>';
	}
	else if(type=='google')
	{
  	movie = '<EMBED id=VideoPlayback ';
	movie += 'style="WIDTH: '+width+'px; HEIGHT: '+height+'px" ';
	movie += 'src="http://video.google.com/googleplayer.swf?docId='+movielink+'"';
	movie += 'type=application/x-shockwave-flash ';
	movie += 'FlashVars="playerMode=normal&amp;autoPlay=true&amp;playerId=gvuniqueid&fs=true" ';
	movie += 'salign="TL" scale="noScale" bgcolor="#000000" quality="best" ';
	movie += 'allowScriptAccess="always" allowfullscreen="true">';
	}
	else if (type == 'asx')
	{
		movie = '<object width="'+width+'" height="'+height+'" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" name="mediaplayer1"  id="mediaplayer1">';
	movie += ' <param name="Filename" value="'+movielink+'?k=1">';
	movie += '<param name="EnableContextMenu" value="1"> ';
	movie += ' <param name="AutoStart" value="True">';
	movie += ' <param name="ShowControls" value="true">';
	movie += '<param name="ShowStatusBar" value="true">';
	movie += ' <param name="ShowDisplay" value="False">';
	movie += '<param name="volume" value="100">';
	movie += '<param name="uiMode" value="full">';
	movie += '<param name="windowlessVideo" value="0">';
	movie += '<param name="fullScreen" value="0">';
	movie += '<param name="AutoRewind" value="True">';
	movie += '<param name="enableErrorDialogs" value="0">';
	movie += '<embed pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&" src="'+movielink+'" width='+width+'" height="'+height+'" autostart="True" showcontrols="True" showstatusbar="False"  showdisplay="true" autorewind="True" enableContextMenu=1 windowlessVideo=1 uiMode=full stretchToFit=1 fullscreen=1> </embed>';
	movie += '</object>';
	}
	else if (type == 'yimg')
	{
		movie = '<embed height="'+height+'" width="'+width+'" ';
		movie += 'bgcolor="#000000" allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" src="http://d.yimg.com/static.video.yahoo.com/yep/YV_YEP.swf?ver=2.2.18.2" flashvars="'+movielink+'&amp;autoPlay=1"/>';
	}
	else if (type == 'mbc')
	{
		movie = '<embed id="LIB_MediaPreview_flashObject" ';
		movie += 'height="'+height+'" width="'+width+'" menu="false" allowfullscreen="true" allownetworking="all" allowscriptaccess="always" ';
		movie += 'flashvars="file='+movielink+'&height='+height+'&width='+width+'&autostart=true&enablejs=true&bcategory=&backcolor=0x002335" ';
		movie += 'wmode="Window" quality="high" name="LIB_MediaPreview_flashObject" style="" ';
		movie += 'src="http://vramadan.mbc.net/locallib/flvPlayer/jwflvplayer_viz1.swf?v=1" type="application/x-shockwave-flash" />';	
	}
	else if (type == 'myspace')
	{
		movie = '<embed height="'+height+'" width="'+width+'" ';
		movie += 'allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" src="'+movielink+'" />';
	}
	else if (type == 'b7cc')
	{
		movie = '<embed height="'+height+'" width="'+width+'" ';
		movie += 'allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" src="http://www.longtailvideo.com/jw/embed/player.swf" flashvars='+movielink+' />';
			}
	else if (type == '.swf')
	{
		
		movie = '<embed height="'+height+'" width="'+width+'" flashvars="autostart=true"';
		movie += 'bgcolor="#000000" allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" src="'+movielink+'"/>';
			}
	else if (type == 'youtube')
	{
		movie = '<embed height="'+height+'" width="'+width+'" bgcolor="#000000" allowscriptaccess="always" wmode="transparent" type="application/x-shockwave-flash"  allowfullscreen="true" src="'+movielink+'&autoplay=1&loop=1&fs=1"></embed>';
			}
	else if (type == 'rekza')
	{
		movie = '<embed type="application/x-shockwave-flash" src="http://rekza.com/linesplayer.swf" style="" id="single" name="single" quality="high" allowfullscreen="true" flashvars="file='+movielink+'&amp;volume=50" width="'+width+'" height="'+height+'">';
	}
	else if (type == 'd1g')
	{
		movie = '<embed type="application/x-shockwave-flash" src="http://www.d1g.com/swf/flvplayer.swf" style="" id="mpl" name="mpl" quality="high" allowfullscreen="true" wmode="transparent" flashvars="file='+movielink+'&amp;height='+height+'&amp;width='+width+'&amp;showfsbutton=true&amp;fullscreenpage='+movielink+'&amp;show_ad=true&amp;id=3048266&amp;overstretch=fit&amp;shuffle=false&amp;repeat=list&amp;v_lang=arabic&amp;isplaylist=false&amp;bufferlength=20" width="'+width+'" height="'+height+'">';
	}
	else if (type == 'viddler')
	{
		movie = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+width+'" height="'+height+'" id="viddler_b1367819"><param name="flashvars" value="fake=1&autoplay=t" /><param name="movie" value="'+movielink+'" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src="'+movielink+'" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash" allowScriptAccess="always" flashvars="fake=1&autoplay=t" allowFullScreen="true" name="viddler_b1367819"></embed></object>';
	}
	else if(type == 'blip')
	{
		movie = '<embed src="'+movielink+'?autostart=true" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" allowscriptaccess="always" allowfullscreen="true"></embed>';
	}
	else if(type == 'vimeo')
	{
		movie = '<object width="'+width+'" height="'+height+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?'+movielink+'&autoplay=1" /><embed src="http://vimeo.com/moogaloop.swf?'+movielink+'&autoplay=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+width+'" height="'+height+'"></embed></object>';
	}

	writit(movie,'obj');
  }
  
 
  
  function writit(text,id)
	{
		text = unescape(text);
		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 **********************/