// ################################################################################################
//Main
// ################################################################################################

var loading = '<div class="window_loading"><b>Loading data ...</b><br>Please wait - connect to server</div>';
var Loader = '';

$(document).ready(function(){
	//$(".textbox").corner("slide");
	$(".window").draggable();
	$(".textbox").focus(function(e){
		$(this).css({border:"1px solid #000", background:"#F6F6F6"});
	});
	$(".textbox").blur(function(e){
		$(this).css({border:"1px solid #0062C4", background:"#fff"});
	});
	
	show_pages('x/user_online', '__notext');
	show_pages('x/live_support', '__live_support_status');
	setInterval("show_pages('x/user_online', '__notext')", 600000);
	setInterval("show_pages('x/live_support', '__live_support_status')", 120000);
	init();
	
});

// #################################################################### //

function show_and_hide(hide_id, show_id, type){
	if(type == 1){
	$("#"+hide_id).hide("slow");
	$("#"+show_id).show("slow");
	}
	else if(type == 2){
	$("#"+hide_id).slideUp("slow");
	$("#"+show_id).slideDown("slow");
	}
	else if(type == 3){
	document.getElementById(hide_id).style.display = 'none';
	document.getElementById(show_id).style.display = 'block';
	}
};

function hide_or_show(id, type){
	if(type == 1){
		$("#"+id).slideToggle("slow");
	}
	else if(type == 0) {
		$("#"+id).toggle();
	}
	else if(type == 2) {
		$("#"+id).hide("slow");
	}
	else if(type == 3) {
		$("#"+id).fadeOut("slow");
	}
	else if(type == 4) {
		$("#"+id).slideUp("slow");
	}
	else if(type == 5) {
		$("#"+id).show();
	}
};

function hide_div(id){
	document.getElementById(id).style.display = 'none';
};

function setAndExecute(divId, innerHTML){
var div = self.parent.document.getElementById(divId);
div.innerHTML = innerHTML;
var x = div.getElementsByTagName("script");
for(var i=0;i<x.length;i++) {
eval(x[i].text);
}
};

function insert_to_textbox(id, text){
	var ins = document.getElementById(id).value = text;
};

function black_layer(){
//var w = $(window).width();
//var h = $("body").height();
//var wh = $(".main").height();
//	if(h < wh){
var h = $(".main").height() + 23;
//	}
		$("#layer").css({height:h+"px", opacity:0.72});
		$("#layer").fadeIn("fast");
};

function show_window(data, title, w){

$(".window").css({width: w+"px"});
$(".window").fadeIn("slow");
$("#window_title").html(title);
$(".window_content").html(loading);

black_layer();

show_pages(data, "window_content");

};

function show_i_window(data, title, dir, ta, height){

black_layer();
$(".window").css({width: "350px"});
$(".window").fadeIn("slow");
$("#window_title").html(title);
$(".window_content").html("<div style=\"direction:"+dir+"; text-align:"+ta+"; height:"+height+"px; overflow:auto\">"+data+"</div>");

};

function close_window(){
	if($(".msg-error1").css("display") != 'block'){
		$("#layer").slideUp(300);
	}
	setTimeout("$(\".window\").hide(\"fast\")", 325);
};

function close_loading(){
	$(".Loading").fadeOut("fast");
};

function domains(plan, type){

var host_price = 0;
var domain_price = 0;

if(type == 1){
	$("#order_host").slideDown("slow");
	document.getElementById("plan").innerHTML = "<b>plan "+plan+"</b>";
	if(plan != ""){
		switch(plan){
			case '1' :
			host_price = 155000;
			break;
			case '2' :
			host_price = 255000;
			break;
			case '3' :
			host_price = 455000;
			break;
			case '4' :
			host_price = 805000;
			break;
			case '5' :
			host_price = 955000;
			break;
			case '6' :
			host_price = 1250000;
			break;
		}
	}
	
		$("#ph_host_price_h").val(host_price);
		$("#ph_plan").val(plan);
}
else if(type == 0) {
	var d = document.getElementById("ph_domains").value;
	var status = document.getElementById("ph_domain_status").value;
	
	if(status == 1){
		
		switch(d){
			case '.com' :
			domain_price = 89000;
			break;
			case '.net' :
			domain_price = 89000;
			break;
			case '.org' :
			domain_price = 89000;
			break;
			case '.edu' :
			domain_price = 89000;
			break;
			case '.ir' :
			domain_price = 39000;
			break;
			case '.id.ir' :
			domain_price = 46000;
			break;
			case '.co.ir' :
			domain_price = 46000;
			break;
			case '.sch.ir' :
			domain_price = 46000;
			break;
			case '.net.ir' :
			domain_price = 46000;
			break;
			case '.gov.ir' :
			domain_price = 46000;
			break;
			case '.org.ir' :
			domain_price = 46000;
			break;
			case '.ac.ir' :
			domain_price = 46000;
			break;
			case '.ایران' :
			domain_price = 46000;
			break;
			case '.info' :
			domain_price = 89000;
			break;
			case '.biz' :
			domain_price = 89000;
			break;
			case '.cn' :
			domain_price = 209000;
			break;
			case '.in' :
			domain_price = 209000;
			break;
		}
		
		$("#ph_domain_price_h").val(domain_price);
	}
	else if(status == 0){
			$("#domain_price").html(0+" ریال");
			$("#ph_domain_price_h").val(0);
	}
}
else if (type == "up"){
	if(document.getElementById("ph_year").value <= 4){
	val = document.getElementById("ph_year").value;
	val2 = parseInt(val) + 1;
	document.getElementById("ph_year").value = val2;
	$("#year").html(val2+" سال");
	}
}
else if (type == "down"){
	if(document.getElementById("ph_year").value >= 2){
	val = document.getElementById("ph_year").value;
	val2 = parseInt(val) - 1;
	document.getElementById("ph_year").value = val2;
	$("#year").html(val2+" سال");
	}
}

	$("#year").html(document.getElementById("ph_year").value+" سال");
	y = document.getElementById("ph_year").value;
	hp = parseInt(document.getElementById("ph_host_price_h").value) * parseInt(y);
	dp = parseInt(document.getElementById("ph_domain_price_h").value) * parseInt(y);
	
///////// temporary ========================
//hp_s = (hp / 100) * parseInt(document.getElementById("ph_user_s").value);
//$("#host_price_s").html(hp_s+" ریال");
///////// temporary ========================

	sum = parseInt(hp) + parseInt(dp);
	//sum = parseInt(hp_s) + parseInt(dp);
	document.getElementById("ph_total").value = sum;
	$("#host_price").html(hp+" ریال");
	$("#domain_price").html(dp+" ریال");
	$("#total_price").html(sum + " ریال");
};

function domains2(type){

var domain_price = 0;

	$("#order_domain").slideDown("slow");
	var d = document.getElementById("ph_domains").value;
	
	if(type == 1){
		
		switch(d){
			case '.com' :
			domain_price = 99000;
			break;
			case '.net' :
			domain_price = 99000;
			break;
			case '.org' :
			domain_price = 99000;
			break;
			case '.edu' :
			domain_price = 99000;
			break;
			case '.ir' :
			domain_price = 49000;
			break;
			case '.id.ir' :
			domain_price = 46000;
			break;
			case '.co.ir' :
			domain_price = 46000;
			break;
			case '.sch.ir' :
			domain_price = 46000;
			break;
			case '.net.ir' :
			domain_price = 46000;
			break;
			case '.gov.ir' :
			domain_price = 46000;
			break;
			case '.org.ir' :
			domain_price = 46000;
			break;
			case '.ac.ir' :
			domain_price = 46000;
			break;
			case '.ایران' :
			domain_price = 46000;
			break;
			case '.info' :
			domain_price = 99000;
			break;
			case '.biz' :
			domain_price = 99000;
			break;
			case '.cn' :
			domain_price = 219000;
			break;
			case '.in' :
			domain_price = 219000;
			break;
		}
		
		$("#ph_domain_price_h").val(domain_price);
	}
else if (type == "up"){
	if(document.getElementById("ph_year").value <= 4){
	val = document.getElementById("ph_year").value;
	val2 = parseInt(val) + 1;
	document.getElementById("ph_year").value = val2;
	$("#year").html(val2+" سال");
	}
}
else if (type == "down"){
	if(document.getElementById("ph_year").value >= 2){
	val = document.getElementById("ph_year").value;
	val2 = parseInt(val) - 1;
	document.getElementById("ph_year").value = val2;
	$("#year").html(val2+" سال");
	}
}
	$("#year").html(document.getElementById("ph_year").value+" سال");
	y = document.getElementById("ph_year").value;
	dp = parseInt(document.getElementById("ph_domain_price_h").value) * parseInt(y);
	$("#domain_price").html(dp+" ریال");
};

function get_fe_name(n){
	return document.getElementById("ph_"+n).value;
};

function get_fe_len(n){
	return document.getElementById("ph_"+n).length;
};

function msg_error(type, msg){
	if(type == 1){
		black_layer();
		$(".msg-error1").html("<br><br>"+msg+"<br><br><button onClick=\"msg_error(0, '')\" class=\"buttons\">بستن</button><br><br>");
		$(".msg-error1").slideDown("fast");
		if($(".window").css("display") != 'block'){
			setTimeout("$(\"#layer\").slideUp(300)", 4700);
			setTimeout("$(\".msg-error1\").slideUp(300)", 5000);
		}
		else {
			setTimeout("$(\".msg-error1\").slideUp(\"fast\")", 5000);
		}
		
	}
	else if(type == 0){
		if($(".window").css("display") != 'block'){
			$("#layer").slideUp(300);
		}
		setTimeout("$(\".msg-error1\").slideUp(\"fast\")", 320);
	}
};

function hide_row(id){
	$("#tr_"+id).fadeOut("slow");
};

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
};

function insert_in_el(id, text){
	$("#"+id).html(text);
	$("#"+id).show();
};

function change_bg_color(id, color){
	$("#"+id).css({background:"#"+color});
};

function ch_fsrc(url){
	document.getElementById("chat_frame").src = url;
};

function na_insert_img_link(type){
  if(type == 1){
	var url = prompt("آدرس عکس :","http://");
	var width = prompt("طول عکس :","");
	var height = prompt("عرض عکس :","");
	document.getElementById("ph_news_article_text").value += '<img src="'+url+'" width="'+width+'" height="'+height+'" title="'+url+'" alt="'+url+'">';
  }
  else if(type == 2){
	var title = prompt("عنوان لینک :","");
	var url = prompt("آدرس لینک :","http://");
	document.getElementById("ph_news_article_text").value += '<a href="'+url+'" title="'+title+'">'+title+'</a>';
  }
};

function insert_t_smile(tag, id){
	document.getElementById(id).value += tag;
};

function display_tooltip(id, text){
$("#tooltip").css({opacity: 0.7});
$(id).mousemove(function(e){
	x = parseInt(e.pageX) + 15;
	y = parseInt(e.pageY);
		$("#tooltip").css({left : x+'px', top : y+'px'});
		$(".tooltip").html(text);
}); 
$(".tooltip").fadeIn(200);
};

function bg_clouds(){
		$(".bg-clouds").css({left: 0})
		$(".bg-clouds").animate({ 
  		left:1280
	}, 20000);
};

// ################################################################################################
//Forms
// ################################################################################################

function WHOIS() {
dn = document.getElementById("domain_name");
domain_name = dn.value;
domain_len = dn.length;
input = document.getElementsByTagName('input'); 
number = 0;
	if(domain_name == false) {
		alert('! نام دامین را وارد کنید');	
		document.getElementById("domain_name").focus();
	}
	else if(domain_len < 3){
		alert('! نام دامین نباید از 3 حرف کمتر باشد');	
	}
	else if(domain_len > 57){
		alert('! نام دامین نباید از 57 حرف بیشتر باشد');	
	}
	else {
      for (i=0;i<input.length;i++){
         if(input[i].checked == true) { 
			if(input[i].name == 'pn') { 
				number ++;
				d = input[i].value;
				//RFSD_id = input[i].id
				rand = Math.random();
				$("#RES").append("<div id='RFSD_"+rand+"'></div>");
				connect2(url+'main/send/whois',"domain_name="+domain_name+"&pn="+d+"&w_id=RFSD_"+rand,"RFSD_"+rand, '<div align="center"><table border="0" width="450" id="whois_table" cellpadding="3" cellspacing="3" dir="ltr"><tr><td width="150" align="center" bgcolor="#CBE5FF" dir="rtl">لطفا کمی صبر کنید ...</td><td align="center" bgcolor="#CBE5FF">www.'+domain_name+''+d+'</td><td align="center" width="12" bgcolor="#CBE5FF"><img src="'+url+'img/delete.gif" width="10" height="10" style="cursor:pointer" onclick="empty_div()"></td></tr></table></div>');
			}
		}
      }
	}
};

function signup(){
	var n = get_fe_name("name");
	var ln = get_fe_name("lastname");
	var tell = get_fe_name("telephone");
	var mob = get_fe_name("mobile");
	var add = get_fe_name("address");
	var user = get_fe_name("username");
	var e = get_fe_name("email");
	var sc = get_fe_name("sec_code");
	
		if(n == "" | ln == "" | tell == "" | mob == "" | add == "" | e == "" | sc == "" | user == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__signup", "f__signup", 3);
			connect2(url+'main/send/signup', "ph_name="+n+"&ph_lastname="+ln+"&ph_telephone="+tell+"&ph_mobile="+mob+"&ph_address="+add+"&ph_username="+user+"&ph_email="+e+"&ph_sec_code="+sc, "f__signup", loading);
		}
};

function host(){
	var d = get_fe_name("domains");
	var dn = get_fe_name("domain_name");
	var ds = get_fe_name("domain_status");
	var hu = get_fe_name("host_username");
	var hp = get_fe_name("host_password");
	var hrp = get_fe_name("host_repassword");
	var y = get_fe_name("year");
	var hph = get_fe_name("host_price_h");
	var dph = get_fe_name("domain_price_h");
	var t = get_fe_name("total");
	var plan = get_fe_name("plan");
	
		if(d == "" | dn == "" | ds == "" | hu == "" | hp == "" | hrp == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else if(hp != hrp){
			msg_error(1, "کلمه عبورهای وارد شده یکسان نیستند !");
		}
		else {
			show_and_hide("__signup", "f__signup", 3);
			connect2(url+'main/send/host', "ph_domains="+d+"&ph_domain_name="+dn+"&ph_domain_status="+ds+"&ph_host_username="+hu+"&ph_host_password="+hp+"&ph_host_repassword="+hrp+"&ph_year="+y+"&ph_host_price_h="+hph+"&ph_domain_price_h="+dph+"&ph_total="+t+"&ph_plan="+plan, "f__signup", loading);
		}
};

function order_domain(){
	var d = get_fe_name("domains");
	var dn = get_fe_name("domain_name");
	var ns1 = get_fe_name("ns1");
	var ns2 = get_fe_name("ns2");
	var y = get_fe_name("year");
	var dph = get_fe_name("domain_price_h");
	
		if(d == "" | dn == "" | ns1 == "" | ns2 == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__domain", "f__domain", 3);
			connect2(url+'main/send/domain', "ph_domains="+d+"&ph_domain_name="+dn+"&ph_year="+y+"&ph_domain_price_h="+dph+"&ph_ns1="+ns1+"&ph_ns2="+ns2, "f__domain", loading);
		}
};

function support(){
	var t = get_fe_name("title");
	var s = get_fe_name("subject");
	var m = get_fe_name("msg");
	
		if(t == "" | s == "" | m == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			connect2(url+'main/send/support', "ph_title="+t+"&ph_subject="+s+"&ph_msg="+m, "content", loading);
		}
};

function topic(){
	var id = get_fe_name("id");
	var m = get_fe_name("msg");
	var u = get_fe_name("user");
	
		if(m == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			connect2(url+'main/send/topic', "ph_id="+id+"&ph_msg="+m+"&ph_user="+u, "content", loading);
		}
};

function admin_config_order(){
	var ud = get_fe_name("update_date");
	var os = get_fe_name("order_status");
	var ps = get_fe_name("payment_status");
	var id = get_fe_name("id");
	var y = get_fe_name("year");
	var yt = get_fe_name("year_temp");
	var ed = get_fe_name("expire_date");
	var desc = get_fe_name("desc");
	var user = get_fe_name("username");
	var user2 = get_fe_name("user_name");
	var od = get_fe_name("order_date");
	
		if(ud == "" | os == "" | ps == "" | y == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__admin_config_order", "f__admin_config_order", 3);
			connect2(url+'main/send/admin_config_order', "ph_update_date="+ud+"&ph_order_status="+os+"&ph_payment_status="+ps+"&ph_id="+id+"&ph_year="+y+"&ph_year_temp="+yt+"&ph_desc="+desc+"&ph_username="+user+"&ph_user_name="+user2+"&ph_order_date="+od, "f__admin_config_order", loading);
		}
};

function enter_receipt(){
	var r = get_fe_name("receipt");
	var ba = get_fe_name("bill_amount");
	var d = get_fe_name("ds_day");
	var m = get_fe_name("ds_month");
	var y = get_fe_name("ds_year");
	var on = get_fe_name("order_number");
	var bn = get_fe_name("bank_name");
	var bt = get_fe_name("buy_type");
	
		if(r == "" | ba == "" | d == "" | m == "" | y == "" | on == "" | bn == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__c_receipt", "f__c_receipt", 3);
			connect2(url+'main/send/add_receipt', "ph_receipt="+r+"&ph_bill_amount="+ba+"&ph_ds_day="+d+"&ph_ds_month="+m+"&ph_ds_year="+y+"&ph_order_number="+on+"&ph_bank_name="+bn+"&ph_buy_type="+bt, "f__c_receipt", loading);
		}
};

function profile(){
	var n = get_fe_name("name");
	var l = get_fe_name("lastname");
	var t = get_fe_name("telephone");
	var m = get_fe_name("mobile");
	var a = get_fe_name("address");
	var e = get_fe_name("email");
	
		if(n == "" | l == "" | t == "" | m == "" | a == "" | e == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__profile", "f__profile", 3);
			connect2(url+'main/send/profile', "ph_name="+n+"&ph_lastname="+l+"&ph_telephone="+t+"&ph_mobile="+m+"&ph_address="+a+"&ph_email="+e, "f__profile", loading);
		}
};

function support_unuser(){
	var n = get_fe_name("name");
	var l = get_fe_name("lastname");
	var e = get_fe_name("email");
	var t = get_fe_name("title");
	var s = get_fe_name("section");
	var m = get_fe_name("msg");
	var sc = get_fe_name("sec_code");
	
		if(n == "" | l == "" | t == "" | m == "" | s == "" | e == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__signup", "f__signup", 3);
			connect2(url+'main/send/support_unuser', "ph_name="+n+"&ph_lastname="+l+"&ph_email="+e+"&ph_title="+t+"&ph_section="+s+"&ph_msg="+m+"&ph_sec_code="+sc, "f__signup", loading);
		}
};

function admin_a_email(){
	var s = get_fe_name("subject");
	var m = get_fe_name("a_email");
	var e = get_fe_name("user_email");
	
		if(m == "" | s == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__a_email", "f__a_email", 3);
			connect2(url+'main/send/admin_a_email', "ph_subject="+s+"&ph_a_email="+m+"&ph_user_email="+e, "f__a_email", loading);
		}
};

function send_news_article(){
	var t = get_fe_name("news_article_title");
	var l = get_fe_name("news_article_link");
	var nt = get_fe_name("news_article_text");
	var ty = get_fe_name("type");
	
		if(t == "" | l == "" | nt == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__send_news_article", "f__send_news_article", 3);
			connect2(url+'main/send/admin_send_news_article', "ph_news_article_title="+t+"&ph_news_article_link="+l+"&ph_news_article_text="+nt+"&ph_type="+ty, "f__send_news_article", loading);
		}
};

function contact(){
	var n = get_fe_name("name");
	var l = get_fe_name("lastname");
	var e = get_fe_name("email");
	var s = get_fe_name("section");
	var m = get_fe_name("msg");
	var sc = get_fe_name("sec_code");
	
		if(n == "" | l == "" | m == "" | s == "" | e == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__signup", "f__signup", 3);
			connect2(url+'main/send/contact', "ph_name="+n+"&ph_lastname="+l+"&ph_email="+e+"&ph_section="+s+"&ph_msg="+m+"&ph_sec_code="+sc, "f__signup", loading);
		}
};

function forgot(){
	var u = get_fe_name("username");
	var e = get_fe_name("email");
	var sc = get_fe_name("sec_code");
	
		if(u == "" | e == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__signup", "f__signup", 3);
			connect2(url+'main/send/forgot', "ph_username="+u+"&ph_email="+e+"&ph_sec_code="+sc, "f__signup", loading);
		}
};

function charge_account(){
	var ca = get_fe_name("charge_amount");
	
		if(ca == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__charge_account", "f__charge_account", 3);
			connect2(url+'main/send/charge_account', "ph_charge_amount="+ca, "f__charge_account", loading);
		}
};

function payment_credit(){
	var op = get_fe_name("pc_order_price");
	var ci = get_fe_name("pc_current_inventory");
	var on = get_fe_name("pc_order_number");
	
		if(op == "" | ci == "" | on == ""){
			msg_error(1, "خطا در پرداخت ! لطفا دوباره درخواست خود را تکرار کنید");
		}
		else {
			show_and_hide("__payment_credit", "f__payment_credit", 3);
			connect2(url+'main/send/payment_credit', "ph_pc_order_price="+op+"&ph_pc_current_inventory="+ci+"&ph_pc_order_number="+on, "f__payment_credit", loading);
		}
};

function add_customer(){
	var cn = get_fe_name("customer_name");
	var u = get_fe_name("url");
	
		if(cn == "" | u == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__customers", "f__customers", 3);
			connect2(url+'main/send/admin_add_customer', "ph_customer_name="+cn+"&ph_url="+u, "f__customers", loading);
		}
};

function admin_em(){
	var m = get_fe_name("min");
	var t = get_fe_name("total");
	var u = get_fe_name("username");
	
		if(m == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__CM", "f__CM", 3);
			connect2(url+'main/send/admin_em', "ph_min="+m+"&ph_total="+t+"&ph_username="+u, "f__CM", loading);
		}
};

function admin_tra_and_rep(){
	var u = get_fe_name("tar_username");
	var t = get_fe_name("tar_type");
	
		if(t == ""){
			msg_error(1, "لطفا گزینه ای که می خواهید نمایش داده شود را انتخاب کنید");
		}
		else {
			connect2(url+'main/send/admin_tra_and_rep', "ph_tar_username="+u+"&ph_tar_type="+t, "f__TAR", loading);
		}
};

function change_dns(){
	var ns1 = get_fe_name("ns1");
	var ns2 = get_fe_name("ns2");
	var on = get_fe_name("order_number");
	
		if(ns1 == "" | ns2 == ""){
			msg_error(1, "لطفا تمام موارد را کامل کنید");
		}
		else {
			show_and_hide("__change_dns", "f__change_dns", 3);
			connect2(url+'main/send/change_dns', "ph_ns1="+ns1+"&ph_ns2="+ns2+"&ph_order_number="+on, "f__change_dns", loading);
		}
};
// ################################################################################################
//Bar
// ################################################################################################

var persistclose=0; //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var startX = 30; //set x offset of bar in pixels
var startY = 5; //set y offset of bar in pixels
var verticalpos="fromtop"; //enter "fromtop" or "frombottom"

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
};

function get_cookie(Name) {
var search = Name + "=";
var returnvalue = "";
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;
returnvalue=unescape(document.cookie.substring(offset, end));
}
}
}
return returnvalue;
};

function closebar(){
if (persistclose){
document.cookie="remainclosed=1";
document.getElementById("Loading").style.visibility="hidden";
}
};

function staticbar(){
barheight=document.getElementById("Loading").offsetHeight;
var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
var d = document;
function ml(id){
var el=d.getElementById(id);
if (!persistclose || persistclose && get_cookie("remainclosed")==""){
el.style.visibility="visible";
}
if(d.layers)el.style=el;{
el.sP=function(x,y){this.style.Right=x+"px";this.style.top=y+"px";};
el.x = startX;
}
if (verticalpos=="fromtop"){
el.y = startY;
}
else {
el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
el.y -= startY;
}
return el;
};
window.stayTopRight=function(){
if (verticalpos=="fromtop"){
var pY = ns ? pageYOffset : iecompattest().scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/8;
}
else {
var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
ftlObj.y += (pY - startY - ftlObj.y)/8;
}
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopRight()", 10);
};
ftlObj = ml("Loading");
stayTopRight();
}

if (window.addEventListener){
window.addEventListener("load", staticbar, false);
}
else if (window.attachEvent){
window.attachEvent("onload", staticbar);
}
else if (document.getElementById){
window.onload=staticbar;
}
// ################################################################################################
//Slider
// ################################################################################################

height = 15;
var slider, items;
function init()
{
	slider = document.getElementById("slider");
	slider.style.visibility = "visible";
	items = getItems (slider);
	setHeight(height ,slider);
	for(var i=0; i<items.length ; i++ )
	{
		init_item(items[i]);
	}
	
	startSliding();
};
n = 0;

function startSliding(){
t = setInterval("moveItem()",8);
};
function moveItem()
{

	if(n+1 < items.length)
	{
		if(getTop(items[n+1])< getTop(items[n])- height-10)
			moveY(1,items[n+1]);
	}
	
	if(n+1 == items.length)
	{
			if(getTop(items[0])< getTop(items[n])- height )
			moveY(1,items[0]);
	}

	if(getTop(items[n])< getHeight(slider))
	{
		moveY(1,items[n]);
	}
	else if(n+1 <items.length)
	{
		init_item(items[n]);
		n++;
	}
	else
	{
		init_item(items[n]);
		n = 0;
	}
	if(getTop(items[n]) == 0)
	{
		allowStart = false;
		wait(3000);
	}
};

function stopCount(){
	clearInterval(t);
};
function init_item(item){
	setHeight(height ,item);
	setPosition(1 ,-height ,item);
};

function getItems(obj) {
      var items = new Array();
      var iCnt=0;
      if (!obj) { return; }
      for (var ix=0; ix < obj.childNodes.length; ix++) {
            var cObj = obj.childNodes[ix];
            if (!cObj.tagName) { continue; }
            if (cObj.tagName.toLowerCase().match('a')) {
                  items [iCnt++] = cObj;
            }
      }
      return items ;
};
function setPosition(x,y,element) {
	element.style.left = x + "px";
	element.style.top = y + "px";
};
function setHeight(x,element) {	element.style.height = x + "px";};
function moveY(y,element) {
	var yfactor = Number(element.style.top.replace("px",""));
	element.style.top = (yfactor + y) + "px";
};
function getTop(element) {return Number(element.style.top.replace("px",""));};
function getHeight(element) {return Number(element.style.height.replace("px",""));};
function wait(sec){
	stopCount();
	setTimeout("startSliding()", sec );
};