function open_vote_window(vote_id) {
    vote_window = open("vote.php?id="+vote_id,"votewindow","width=550,height=250,top="+(screen.height-250)/2+",left="+(screen.width-550)/2+",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
}
function open_prev_window() {
        vote_window = open(server_url+"/voting/prev/","votewindow","width=550,height=250,top="+(screen.height-250)/2+",left="+(screen.width-550)/2+",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
}

function show_div(id) 
{
	var alldivs = document.getElementsByTagName('div');
	for(var i=0;i<alldivs.length;i++)
	{
		if((alldivs[i].className == "hide_all") && (alldivs[i].id != "div_"+id))
			alldivs[i].style.display = 'none';
	}
	
    var dp = document.getElementById("div_"+id);
    if(dp.style.display == '') {
        dp.style.display = 'none';
    }else{
        dp.style.display = '';
    }
}


function calling_another_function()
{
	//alert("TEST");
}

function login()
{
//	var username = document.forms['form1'].elements['username'].value;
//	var password = document.forms['form1'].elements['password'].value;
//	document.getElementById("container").innerHTML="<center><img src='http://www.jhzsch.com/webadmin/images/loading.gif'></center>";
	var username = document.frm.username.value;
	var password = document.frm.password.value;
	var url = server_url+'/ajax.php';
    var pars = 'login_visitor=ok&username='+username+'&password='+password;
    var target = 'container';
    var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars, onComplete: calling_another_function  });
}

function register()
{
	// اسم الزائر
	var textinput = document.getElementById('textinput').value;
	// بريد الزائر
	var new_emailinput = document.getElementById('new_emailinput').value;
	var new_username   = document.getElementById('new_username').value;
	var new_password   = document.getElementById('new_password').value;
	var confpassword   = document.getElementById('confpassword').value;
//	document.getElementById("container").innerHTML="<center><img src='http://www.jhzsch.com/webadmin/images/loading.gif'></center>";
	if((textinput != "") && (new_emailinput != "") && (new_username != "") && (new_password != "") && (confpassword != ""))
	{
		if(new_password == confpassword)
		{
			var url = server_url+'/ajax.php';
		    var pars = 'register_visitor=ok&textinput='+textinput+'&new_emailinput='+new_emailinput+'&new_username='+new_username+'&new_password='+new_password;
		    var target = 'container';
		    var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars, onComplete: calling_another_function  });
		}
		else
		{
			alert('عفواً .. لابد من تطابق كلمة المرور مع تأكيد كلمة المرور');
		}
	}
	else
	{
		alert('عفواً لا بد من إدخال جميع البيانات بصورة صحيحة وعدم تركها فارغة');
	}
}

function replaceText(text){
    while(text.lastIndexOf("&") > 0){
	      text = text.replace('&', '[i-Stats]');
    }
    return text;
}

function vote_now()
{
//	document.getElementById("vote_now_div").innerHTML="<center><img src='http://www.jhzsch.com/webadmin/images/loading.gif'></center>";
	var vote_data_id = 0;
	for( i = 0; i < document.frm_vote.chooses.length; i++ )
	{
		if( document.frm_vote.chooses[i].checked == true )
			vote_data_id = document.frm_vote.chooses[i].value;
	}
	
	var url = server_url+'/ajax.php';
    var pars = 'lgi_vote=1&vote_data_id='+vote_data_id;
    var target = 'vote_now_div';
    var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars, onComplete: calling_another_function  });
}