// JavaScript Document
if ( typeof(AFR) == 'undefined' ) AFR = function() {};
if ( typeof(AFR.config) == 'undefined' ) AFR.config = function() {};
AFR.poweredby ='AFRMEDIA';

AFR.decode = function(input,eq){var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output = "";var chr1, chr2, chr3 = "";var enc1, enc2, enc3, enc4 = "";var i = 0;if(eq!="" && eq>0)for(j=0;j<eq;j++)input+="=";input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");	do {enc1 = keyStr.indexOf(input.charAt(i++));enc2 = keyStr.indexOf(input.charAt(i++));      enc3 = keyStr.indexOf(input.charAt(i++));enc4 = keyStr.indexOf(input.charAt(i++));chr1 = (enc1 << 2) | (enc2 >> 4);chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);chr3 = ((enc3 & 3) << 6) | enc4;output = output + String.fromCharCode(chr1);if (enc3 != 64) {output = output + String.fromCharCode(chr2);}if (enc4 != 64) {output = output + String.fromCharCode(chr3);}chr1 = chr2 = chr3 = "";enc1 = enc2 = enc3 = enc4 = "";} while (i < input.length);return output;}

AFR.loading = function(oId)
{
	h=document.getElementById(oId).offsetHeight;
	var html='';
	html += '		<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	html += '            <tr>';
	html += '              <td height="'+ h +'" align="center" style="font-family:Tahoma;font-size:11px;">';
	html += '              <object width="150" height="20">';
	html += '              <embed src="http://www.azeri.net/video/images/loading.swf" quality="high" width="150" wmode="transparent" height="20" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	html += '              </object>';
	html += '              <br>Yüklenir...</td>';
	html += '            </tr>';
	html += '          </table>';
	document.getElementById(oId).innerHTML = html;
}

function printLink(input)
{
	input = AFR.decode(input);
	document.write(input);
}
function anseyfeet(x)

{

	x.style.behavior='url(#default#homepage)';

	x.setHomePage('http://www.azeri.net');

}

function sikkullanilan()

{

	window.external.AddFavorite('http://www.azeri.net','Azeri.NET');

}



function opRadio()

{

	PositionX = 100;

	PositionY = 100;

	defaultWidth = 250;

	defaultHeight = 360;

	var AutoClose = true;

	if (parseInt(navigator.appVersion.charAt(0))>=4){

	var isNN=(navigator.appName=="Netscape")?1:0;

	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}

	var optNN='directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;

	var optIE='directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,width=250,height=360,left='+PositionX+',top='+PositionY;

		

	if (isNN){opWin=window.open('http://radio.azeri.net/?right_menu=1','',optNN);}

	if (isIE){opWin=window.open('http://radio.azeri.net/?right_menu=1','',optIE);}

			

}



function writeCookie(name, value, hours)



{



  var expire = "";



  if(hours != null)



  {



    expire = new Date((new Date()).getTime() + hours * 3600000);



    expire = "; expires=" + expire.toGMTString();



  }



  document.cookie = name + "=" + escape(value) + expire;



}







function readCookie(name)



{

  var cookieValue = "";



  var search = name + "=";



  if(document.cookie.length > 0)



  { 



    offset = document.cookie.indexOf(search);



    if (offset != -1)



    { 



      offset += search.length;



      end = document.cookie.indexOf(";", offset);



      if (end == -1) end = document.cookie.length;



      cookieValue = unescape(document.cookie.substring(offset, end))



    }



  }



  return cookieValue;



}



function afrStyle(x)

{

	writeCookie("afr_style", x, 48);

	location.reload();

}

function blinkIt()
{
	var tag = document.getElementsByTagName('blink');
	for(i=0; i<tag.length; i++)
	{
		s=tag[i];
		s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
	}
	
}
setInterval('blinkIt()',400);

function fixImage() 
{
	var supported = /MSIE ((5\.5)|[6789])/.test(navigator.userAgent) && navigator.platform == "Win32";
	var tag = document.getElementsByTagName("img");
	var blankSrc = "http://www.azeri.net/themes/iCGstation/blank.gif";
	if (supported && tag.length>0)
	{
		for(i=0;i<tag.length;i++)
		{
			var element = tag[i];
			var src = element.src;
			var end = src.indexOf("azeri.net");
			var ext=src.substring(src.lastIndexOf(".") + 1,src.length);
			if(ext=="png" && end!=-1)
			{
				element.src = blankSrc;
				element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
			}
		}
	}
}
var nextTimer = new Array();
function NextScr(oDiv,p,m,t)
{
	if ( typeof(nextTimer[oDiv]) == 'undefined' )nextTimer[oDiv]=0;
	if(nextTimer[oDiv]==-1)return;
	
	var margin = parseInt(document.getElementById(oDiv).style.marginLeft.replace('px', ''));
	var width = parseInt(document.getElementById(oDiv).style.width.replace('px', ''));
	var z = margin + width;
	
	if(z<=p){nextTimer[oDiv] = 0;return;}
	
	if(m > 0)
	{
		nextTimer[oDiv] = 1;
		if((m - 10) < 50 && t>1) t--;
		m = m - t;
		margin = margin - t;
		document.getElementById(oDiv).style.marginLeft = margin + 'px';
		setTimeout("NextScr('"+ oDiv +"',"+ p +","+ m +","+ t +");", 1);
	}
	else nextTimer[oDiv] = 0;
}
function PrevScr(oDiv,m,t)
{
	if ( typeof(nextTimer[oDiv]) == 'undefined' )nextTimer[oDiv]=0;
	if(nextTimer[oDiv]==1)return;
	
	var margin = parseInt(document.getElementById(oDiv).style.marginLeft.replace('px', ''));
		
	if(margin == 0){nextTimer[oDiv] = 0;return;}
	
	if(m > 0)
	{
		nextTimer[oDiv] = -1;
		if((m - 10) < 50 && t>1) t--;
		m = m - t;
		margin = margin + t;
		document.getElementById(oDiv).style.marginLeft = margin + 'px';
		setTimeout("PrevScr('"+ oDiv +"',"+ m +","+ t +");", 1);
	}
	else nextTimer[oDiv] = 0;
}
function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}
function printVideo(yId,oId)
{
	var path='';
	var html='';

	url = 'http://www.azeri.net/video/getLink.php?link=' + yId +'&uniq=' + randomNumber(10000000);
	var http = createRequestObject();
	http.open('get', url);
	http.onreadystatechange = function()
	{
		if(http.readyState == 4)
		{
			video_t = http.responseText;
			if(video_t!='')
			{	
				path='http://www.youtube.com/player2.swf?video_id=' + yId + '&t=' + video_t;
			}
			else path='http://www.youtube.com/v/' + yId;
				
			html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="425" height="350">';
			html += '      <param name="movie" value="'+ path +'" />';
			html += '		<param name="flashvars" value="&rs=1&sn=1&iurl=http%3A//img.youtube.com/vi/'+yId+'/default.jpg"></param>';
			html += '      <param name="quality" value="high" />';
			html += '      <param name="wmode" value="transparent">';
			html += '      <embed src="'+ path +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"  wmode="transparent"  width="425" height="350" flashvars="&rs=1&sn=1&iurl=http%3A//img.youtube.com/vi/'+yId+'/default.jpg"></embed>';
			html += '    </object>';
			document.getElementById(oId).innerHTML = html;
		}
		else AFR.loading(oId);
	}
	http.send(null);
}

var getVideo_id=0;
function getVideoFile(yId,oId)
{
	url = 'http://www.azeri.net/video/getVideoFile.php?link=' + yId;
	var http = createRequestObject();
	http.open('get', url);
	http.onreadystatechange = function()
	{
		if(http.readyState == 4)
		{
			video_t = http.responseText;
			var so = new SWFObject("http://www.azeri.net/video/js/flvplayer.swf","mpl","425","350","8"); 
			so.addParam("allowscriptaccess","always"); 
			so.addParam("allowfullscreen","true"); 
			so.addVariable("height","350"); 
			so.addVariable("width","425"); 
			so.addVariable("file",video_t); 
			so.addVariable("autostart","false");
			so.addVariable("image","http://img.azeri.net/video/" + yId +".jpg"); 
			so.write(oId); 
		}
		else AFR.loading(oId);
	}
	http.send(null);
}
function randomNumber(limit){
  return Math.floor(Math.random()*limit);
}
