var host = "http://"+document.domain+"/";
var golinc = true;
var login = false;
window.login = login;
function initradio()
{
	var radfun = function(e){ 
		var a = this.firstChild.name;
		this.className='radioc'; if(window.oldsradio[a]){window.oldsradio[a].className='radio';} window.oldsradio[a] = this; 
		this.firstChild.checked = true;
	}
	var checfun = function(e){ 
		if(!this.firstChild.checked)
		{
			this.firstChild.checked = true;
			this.className='checc';
		}
		else
		{
			this.firstChild.checked = false;
			this.className='chec';
		}
	}
	
	var oldsradio = new Array();
	window.oldsradio = new Array();
	var sp=document.getElementsByTagName("SPAN");
	for(var x=0;x<sp.length;x++)
	{
		var s = sp[x];
		switch(s.className)
		{
			case "radio":
				s.onclick = radfun;
				break;
			case "radioc":
				{
					s.onclick = radfun;
					window.oldsradio[s.firstChild.name] = s;
				}
				break;
			case "chec":
				s.onclick = checfun;
				break;
			case "checc":
				s.onclick = checfun;
				break;
		}
	}
}


function alertSystem(type,info,title)
{
	alert("test");
}

var sys_value = 0;


function addToFavorite(val)
{
	showAlert("",370,390);
	alertSetHTML(val);
	return false;
}

function showAlertBg()
{
	if (!window.alertBg)
	{
		var alertBg = createElement("div");
		$(alertBg).get(0).className = "alert_bg";
		$(alertBg).css("width", $(document).width()).css("height", $(document).height()).css({opacity: 0.7}).css("display", "none");
		window.alertBg = alertBg;
	}
	$(window.alertBg).css("display","");
	document.body.appendChild(window.alertBg);
}

function showAlert(text,w,h,b)
{
	showAlertBg();
	if (!window.alerty)
	{
		var alerty = createElement("div");
		$(alerty).get(0).className = "alert_win";
		$(alerty).css("display", "none");
		window.alerty = alerty;
	}
	
	if(!w) w = 320;
	if(!h) h = 240;
	
	//b - button bool
	
	$(window.alerty).css("width", w).css("height", h).css("left", "50%").css("top", "50%");
	$(window.alerty).css("marginLeft", -(w/2)).css("marginTop", -(h/2)).css("left", "50%").css("top", "50%");
	$(window.alerty).css("display","");
	
	//$(window.alertBg).click(function(){closeAlert();})
	
	document.body.appendChild(window.alerty);
}

function alertSetHTML(html)
{
	$(window.alerty).html(html);
}

function alertGetHTML()
{
	return $(window.alerty).html();
}

function alertGetHANDLE()
{
	return $(window.alerty).get(0);
}

function closeAlert()
{
	$(window.alerty).css("display","none");
	$(window.alertBg).css("display","none");
	alertSetHTML("");
}


function createElement(name)
{
	var e = document.createElement(name);
	return e;
}



function goUrl(path)
{
	if(golinc)
	{
		window.location = host+path;
	}
	golinc = true;
}

function checkLogin(c)
{
	var s = createElement("script");
	s.src = host + "islogin.php?c="+c;
	$("HEAD").get(0).appendChild(s);
	window.setTimeout(function(){$("HEAD").get(0).removeChild(s);},100); //IE hack

	//return getLoginStat();
}

function _login(c)
{
	showAlert("",330,170);
	post="c="+c;
	system_i.push_last(new Array(host+"login_empty.php",post,function(val){
		alertSetHTML(val);
	} ));
	
	return false;
}

function getLoginStat()
{
	//alert(window.login);
//	return window.login;
}

checkLogin('');
