﻿var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}



$(document).ready(function() {
	$("#replay_form").submit(function() { 
	 //  $(this).children('input[type=submit]').attr('disabled', 'disabled');

		var tidval    = $("#tid").val();
        var useridval = $("#userid").val();
        var typeval   = $("#type").val();
        var msgval    = $("#msg").val();
		$.post("add_replay.php", {tid:tidval, userid:useridval, type:typeval, msg:msgval }, function(data) {
			$("#status_rep p").html(data);         
		});
		return false;
	});
});



$(document).ready(function() {
	$("#login_form").submit(function() { 
		var unameval = $("#username").val();
		var pwordval = $("#userpass").val();
		var thepageval = $("#re_page").val();
		$.post("login.php", { username: unameval,
		userpass: pwordval, re_page: thepageval }, function(data) {
			$("#status p").html(data);
		});
		return false;
	});
});

$(document).ready(function() {
	$("#reg_form").submit(function() { 
		var unameval = $("#yourname").val();
		var emailval = $("#youremail").val();
        var passval = $("#yourpass").val();
        var countryval = $("#country").val();
        var codeval = $("#code").val();
		$.post("do_register.php", { yourname: unameval,
		youremail: emailval , yourpass: passval , country: countryval , code: codeval }, function(data) {
			$("#status_reg p").html(data);
		});
		return false;
	});
}); 


$(document).ready(function(){
    //  When user clicks on tab, this code will be executed
    $("#tabs li").click(function() {
        //  First remove class "active" from currently active tab
        $("#tabs li").removeClass('active');
 
        //  Now add class "active" to the selected/clicked tab
        $(this).addClass("active");
 
        //  Hide all tab content
        $(".tab_content").hide();
 
        //  Here we get the href value of the selected tab
        var selected_tab = $(this).find("a").attr("href");
 
        //  Show the selected tab content
        $(selected_tab).fadeIn();
 
        //  At the end, we add return false so that the click on the link is not executed
        return false;
    });
});


function toggle() {
	var ele = document.getElementById("toggleText");
	var text = document.getElementById("displayText");
	if(ele.style.display == "block") {
    		ele.style.display = "none";
		text.innerHTML = "إظهار صندوق الرد";
  	}
	else {
		ele.style.display = "block";
		text.innerHTML = "إخفاء صندوق الرد";
	}
} 

function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}
//  End -->

