var hashing=window.location.hash;
var ha='index.php';

if (hashing!=null && hashing!='' && hashing!=' '){
	ha=hashing.replace('#/','');
}

//document.open();
//document.clear();
var IE4 = (document.all)? true : false;
var ua = navigator.userAgent.toLowerCase();
isIE = (ua.indexOf("msie") != -1); 
isOpera = (ua.indexOf("opera") != -1);
var browser = navigator.appName;
if (browser == "Microsoft Internet Explorer"){
    var b_version = navigator.appVersion;
    var re = /\MSIE\s+(\d\.\d\b)/;
    var res = b_version.match(re);
    if (res[1] <= 6){
//		document.write('<body id="body" style="padding:0;margin:0;width:100%;height:100%;background:#000000;"><iframe src="http://tornado.com/'+ha+'" id="f1" name="f1" frameborder="none" style="border:none;position:absolute;top:0px;left:0px;width:100%;height:100%;" SCROLLING="auto"></iframe><div style="width:1002px;margin:0 auto;padding-left:78px;"><div style="overflow:hidden;width:962px;height:30px;display:none;position:absolute;bottom:0px;background:transparent;z-index:3" id="z" align="center">1</div></div><div style="height:17px;width:100%;position:absolute;bottom:0px;background:#000000;z-index:2;font-size:0;"></div></body>');
		document.write('<body id="body" style="padding:0;margin:0;width:100%;height:100%;background:#000000;"><iframe src="http://tornadomusic.ru/'+ha+'" id="f1" name="f1" frameborder="none" style="border:none;position:absolute;top:0px;left:0px;width:100%;height:100%;" SCROLLING="auto"></iframe><div style="width:1002px;margin:0 auto;padding-left:78px;"><div style="overflow:hidden;width:962px;height:30px;display:none;position:absolute;bottom:0px;background:transparent;z-index:3" id="z" align="center">1</div></div><div style="height:17px;width:100%;position:absolute;bottom:0px;background:#000000;z-index:2;font-size:0;"></div></body>');
    }else{
//    	document.write('<body id="body" style="padding:0;margin:0;width:100%;height:100%;background:#000000;"><iframe src="http://tornado.com/'+ha+'" id="f1" name="f1" frameborder="none" style="border:none;position:absolute;top:0px;left:0px;width:100%;height:100%;" SCROLLING="auto"></iframe><div style="width:1002px;margin:0 auto;padding-left:64px;"><div style="overflow:hidden;width:962px;height:0px;display:none;position:absolute;bottom:0px;background:transparent;z-index:3" id="z" align="center"></div></div></body>');
	document.write('<body id="body" style="padding:0;margin:0;width:100%;height:100%;background:#000000;"><iframe src="http://tornadomusic.ru/'+ha+'" id="f1" name="f1" frameborder="none" style="border:none;position:absolute;top:0px;left:0px;width:100%;height:100%;" SCROLLING="auto"></iframe><div style="width:1002px;margin:0 auto;padding-left:64px;"><div style="overflow:hidden;width:962px;height:0px;display:none;position:absolute;bottom:0px;background:transparent;z-index:3" id="z" align="center"></div></div></body>');
    }
}else{
//	document.write('<body id="body" style="padding:0;margin:0;width:100%;height:100%;background:#000000;"><iframe src="http://tornado.com/'+ha+'" id="f1" name="f1" frameborder="none" style="border:none;position:absolute;top:0px;left:0px;width:100%;height:100%;" SCROLLING="auto"></iframe><div style="width:1002px;margin:0 auto;padding-left:64px;"><div style="overflow:hidden;width:962px;height:0px;display:none;position:absolute;bottom:0px;background:transparent;z-index:3" id="z" align="center"></div></div></body>');
	document.write('<body id="body" style="padding:0;margin:0;width:100%;height:100%;background:#000000;"><iframe src="http://tornadomusic.ru/'+ha+'" id="f1" name="f1" frameborder="none" style="border:none;position:absolute;top:0px;left:0px;width:100%;height:100%;" SCROLLING="auto"></iframe><div style="width:1002px;margin:0 auto;padding-left:64px;"><div style="overflow:hidden;width:962px;height:0px;display:none;position:absolute;bottom:0px;background:transparent;z-index:3" id="z" align="center"></div></div></body>');
}
//document.close();

function get_cookie(name){
	cookie_name = name + "=";
	cookie_length = document.cookie.length;
	cookie_begin = 0;
		while (cookie_begin < cookie_length){
			value_begin = cookie_begin + cookie_name.length;
			if (document.cookie.substring(cookie_begin, value_begin) == cookie_name){
				var value_end = document.cookie.indexOf (";", value_begin);
				if (value_end == -1){
					value_end = cookie_length;
				}
			return unescape(document.cookie.substring(value_begin, value_end));
			}
			cookie_begin = document.cookie.indexOf(" ", cookie_begin) + 1;
			if (cookie_begin == 0){
				break;
			}
		}
	return null;
}
function sver_radio(){
	if (browser == "Microsoft Internet Explorer"){
	    var b_version = navigator.appVersion;
	    var re = /\MSIE\s+(\d\.\d\b)/;
	    var res = b_version.match(re);
	    if (res[1] <= 6){
//			document.frames['f2'].getElementById('z').style.height='25px';
			$('z').style.height='25px';
	    }else{
	    	$('z').style.height='25px';
	    }
	}else{
		$('z').style.height='25px';
	}
}
function razv_radio(){
	if (browser == "Microsoft Internet Explorer"){
	    var b_version = navigator.appVersion;
	    var re = /\MSIE\s+(\d\.\d\b)/;
	    var res = b_version.match(re);
	    if (res[1] <= 6){
//			document.frames['f2'].getElementById('z').style.height='74px';
			$('z').style.height='74px';
	    }else{
	    	$('z').style.height='74px';
	    }
	}else{
		$('z').style.height='74px';
	}
}
function select_radio(){
	fon();
	fix();
	var h=getClientHeight();
	var w=getClientWidth();
	new Insertion.After('fon_box', '<div id="box" style="position:absolute;width:500px;background:#cdcdcd;z-index:120;top:'+(h/2-200)+'px;left:'+(w/2-250)+'px;border:solid 1px #505050;"><div style="height:20px;background:#333333;color:#00c000;position:relative;" align="center">Выберите канал<div id="cl" style="background:url(/images/profile/cl.png) no-repeat;position:absolute;top:0px;right:0px;width:14px;font-size:13px;height:14px;color:#000000;cursor:pointer;"></div></div><div id="box_cont" align="center" style="padding:40px 0px;background:#ffffff;"><br /><img src="images/loading.gif"><br /></div></div>');
	var url = 'ajax/ganr.php';
	var pars = '';
	var myAjax = new Ajax.Updater({success:'box_cont'},url,{method:'post',parameters:pars,onComplete:function(){fix();}});
	$('cl').observe('click', function(){$('box').remove();fon_off();});
}
function fon(){
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });
	window.frames['f1'].$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });

	var h=getClientHeight();
	var w=getClientWidth();
	new Insertion.Bottom('body', '<div id="fon_box" style="position:absolute;width:100%;height:'+h+'px;background: #c0c0c0;z-index:100;top:0px;left:0px;"></div>');
	$('fon_box').setOpacity(0.6);
}
function fon_off(){
	$('fon_box').remove();
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });
	window.frames['f1'].$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });
}
Event.observe(window, 'resize', function() { res(); });
function getClientWidth(){
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}
function getClientHeight(){
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}
function res(){
	if ($('fon_box')){
		var h=getClientHeight();
		$('fon_box').setStyle({height: h+'px'}); 
	}
}
$('z').update('<embed src="swf/mp3_player.swf?skins='+get_cookie("fon")+'&path=xml/songs_xml.php" quality="high" wmode="transparent" bgcolor="#000000" width="962" height="74" name="player_radio" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" id="sw"/>');
$('z').style.display='';
$('z').style.height='74px';
function sel_can(){
	$('z').style.height='74px';
	$('z').style.display='';
	$('z').update('<embed src="swf/mp3_player.swf?skins='+get_cookie("fon")+'&path=xml/radio_xml.php?g='+$F('ganr')+'" quality="high" wmode="transparent" bgcolor="#000000" width="962" height="74" name="player_radio" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" id="sw"/>');
	$('box').remove();
	fon_off();
}
function fix(){
	var IE4 = (document.all)? true : false;
	var ua = navigator.userAgent.toLowerCase();
	isIE = (ua.indexOf("msie") != -1); 
	isOpera = (ua.indexOf("opera") != -1);
	var browser = navigator.appName;
  if (browser == "Microsoft Internet Explorer"){
    var b_version = navigator.appVersion;
    var re = /\MSIE\s+(\d\.\d\b)/;
    var res = b_version.match(re);
    if (res[1] <= 6){
      pngfix();
    }
  }
}
var clear="images/clear.gif"

pngfix=function(){
	var els=document.getElementsByTagName('*');
	var ip=/\.png/i;
	var i=els.length;
	while(i-- >0){
		var el=els[i];
		var es=el.style;
		if(el.src&&el.src.match(ip)&&!es.filter){
			es.height=el.height;
			es.width=el.width;
			es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='crop')";
			el.src=clear;
		}else{
			var elb=el.currentStyle.backgroundImage;
			if(elb.match(ip)){
				var path=elb.split('"');
				var rep=(el.currentStyle.backgroundRepeat=='no-repeat')?'crop':'scale';
				es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path[1]+"',sizingMethod='"+rep+"')";
				es.height=el.clientHeight+'px';
				es.backgroundImage='none';
			}
		}
	}
}
