function roll_over(img_name, img_src)
{
document[img_name].src = img_src;
}

function show(menu) {
var d=document,
elemS=(d.getElementById(menu)||d.all[menu]).style
elemS.display=elemS.display=='none'?'block':'none'
}

function ShowPage(){
document.getElementById('page').style.display = 'block';
}

function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}

function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}

function createCookie(name,value) {
var date = new Date();
date.setTime(date.getTime()+(12*60*60*1000));
var expires = "; expires="+date.toGMTString();
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

function voterf() {
if (readCookie("voteRF") == null) {
window.open('http://rf.mmotop.ru/vote/2653/','mywindow','scrollbars=yes,width='+screen.width+',height='+screen.height);
createCookie("voteRF", "yes");
}
}

function popup(url, width, height) {
childWindow = open(url, "_blank", "width=" + width + ",height=" + height + ",left=" + (screen.width/2 - width/2) + ",top=" + (screen.height/2 - height/2) + "toolbar=0,location=0,directories=0,menubar=0,scrollbars=0,resizable=0,status=0");
if (childWindow.opener == null) childWindow.opener = self;
};

function doLogin() {
var login = $("#login").val();
var password = $("#password").val();
var server = jQuery('select :selected').val();
$.post("post/userlogin.php", { login: login, pass: password, serv: server }, function(data) { document.location.reload(); }, "text");
}

function naviUpload(status) {
if (status == "bar") {
$("#uploadstatustext").css("display", "none");
$("#uploadstatus").css("display", "block");
} else {
$("#uploadstatus").css("display", "none");
$("#uploadstatustext").css("display", "block");
}
}

function barUpload(percentage) {
$("#progressbar").css("width", percentage + "%");
$("#progressbarpec").text(percentage + "%");
}

function startUpload(key) {
uid = "showUpload('" + key + "')";
naviUpload("bar");
document.uploadform.submit();
setTimeout(uid, 1500);
}

function showUpload(key) {
uid = "showUpload('" + key + "')";
$.get("upload/upload.php?uid=" + key, function(data) {
var response; eval("response = " + data);
if (!response) { eval("response = ({'current':'0','total':'0'})"); }
percentage = Math.floor(100 * parseInt(response['current']) / parseInt(response['total']));

if (isNaN(percentage)) {

naviUpload("text");
$("#uploadstatustext").text("Uploaded screenshots size limit is 10MB");
setTimeout("window.location.replace(window.location.href)", 2000);
return;

} else if (percentage < 100) {

barUpload(percentage);
setTimeout(uid, 750);

} else {
percentage = 100;
barUpload(percentage);
setTimeout("showStatus()", 1000);
}

});
}

function showStatus() {
naviUpload("text");
var myIFrame = document.getElementById('loader');
var content = myIFrame.contentWindow.document.body.innerHTML;
$("#uploadstatustext").text(content);
if (content != "Image type is not supported" && content != "Error uploading image") {
setTimeout("window.close(); opener.location.reload();", 2000);
} else {
setTimeout("window.location.replace(window.location.href)", 2000);
}
}

function acceptor(msg) {
if (confirm(msg)) {
	return true;
} else {
	return false;
}
}

function buyitem_sms(id) {var url = "/modules/smsshop/main.php?p=4&id=" + escape(id);
$.get(url, function(data) { alert(data); }, "text");
}