
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }

function OpenWindow(Url)
{
        window.open (Url, "MyNewWindow", "toolbar=No, location=No, directories=no,status=no, menubar=no, scrollbars=yes, resizable=No,width=400,height=300,left=150,top=100");
}

/****************************************/

function set_smile(X)
{
         topic.S1.focus();
         var rng = SelectedText();

         if (win_ie_ver >= 5.5){
             var sel = document.selection;
             if (rng != null && (sel.type == "Text" || sel.type == "None"))
             {
                 text = rng.text;
             }
         }

         if (rng != null && topic.S1.createTextRange)
         {
             topic.S1.caretPos = rng.duplicate();
         }

         if (typeof(topic.S1.createTextRange) != "undefined" && topic.S1.caretPos)
         {
             var caretPos = topic.S1.caretPos;
             caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? " " + X + " " + ' ' : " " + X + " ";
             caretPos.select();
         }
         else if (topic.S1.selectionStart || topic.S1.selectionStart == '0')
         {
              var start_selection = topic.S1.selectionStart;
              var end_selection = topic.S1.selectionEnd;

              var start = (topic.S1.value).substring(0, start_selection);
              var middle = " " + X + " ";
              var end = (topic.S1.value).substring(end_selection, topic.S1.textLength);

              topic.S1.value = start + middle + end;
              topic.S1.focus();
              topic.S1.selectionStart = end_selection + middle.length;
              topic.S1.selectionEnd = start_selection + middle.length;
         }
         else
         {
              topic.S1.value += " " + X + " ";
         }
}

/****************************************/

function avatar_check()
{
        avatar.T1.value = "";

         if (avatar.R1.checked == true)
    {
                  avatar.T1.value = "";
         }
}

/****************************************/

function getsubjecturl(rurl)
{
        url = prompt("يمكنك نسخ وصلة الرد من هنا",rurl);

         return false;
}

/****************************************/

function GoToForum()
{
        window.location.href=ForumsList.Site.value
}

/****************************************/

function ContactusEnable ()
{
        var x = document.getElementById('contactus_email')
        x.disabled = false
}

/****************************************/

function ContactusState ()
{
        var x = document.getElementById('contactus_email')
        var c = document.getElementById('editemail')

        if (c.checked == false) x.disabled = true
}

/****************************************/

function makeCheck(thisForm)
{
        for (i = 0; i < thisForm.elements.length; i++)
    {
        thisForm.elements[i].checked=true
    }
}

/****************************************/

function makeUncheck(thisForm)
{
        for (i = 0; i < thisForm.elements.length; i++)
    {
        thisForm.elements[i].checked=false
    }
}

/****************************************/

function DevTimeDate()
{
var d = new Date();
var currYear = d.getFullYear();
var currMonth = d.getMonth() + 1;
var currDate = d.getDate();
var currHour = d.getHours();
var currMin = d.getMinutes();
var theInput;
time = "التاريخ: " + currYear + "/" +
(currMonth < 10 ? "0" : "") + currMonth + "/" +
(currDate < 10 ? "0" : "") + currDate + " " +
"الوقت: " + (currHour < 10 ? "0" : "") + currHour + ":" +
(currMin < 10 ? "0" : "") + currMin;
theInput = document.getElementById("note");
theInput.value = theInput.value + time + " ";
theInput.focus();
}

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)
if(win.window.focus){win.window.focus();}
}

/*****************************************/

function UpdateSize(c,t){
var SS,RR;
    if (c.checked==true){
      RR = document.getElementById("total").innerHTML;
      if(c.name=="SelectAllSa"){
        RR = 0;
      }
      document.getElementById("total").innerHTML = eval(RR) + eval(t);
  }else{
      RR = document.getElementById("total").innerHTML;
      document.getElementById("total").innerHTML = RR-t;
      if(document.getElementById("total").innerHTML < 0){
      document.getElementById("total").innerHTML = 0;
      }
  }
}

/*********************************************/
function ChangeMulti(X){
if(X=="1"){
  document.SaTable.filesno.disabled = true;
  document.SaTable.filesno.value    = "1";
  document.SaTable.type[0].disabled = false;
  document.SaTable.type[2].disabled = false;
  document.SaTable.type[0].checked = "checked";
}else{
 if(X=="2"){
  document.SaTable.filesno.disabled  = false;
  document.SaTable.filesno.value     = "2";
 }else{
  document.SaTable.filesno.disabled  = true;
  document.SaTable.filesno.value     = "1";
 }
  document.SaTable.type[1].checked = "checked";
  document.SaTable.type[0].disabled = true;
  document.SaTable.type[2].disabled = true;
}
}

/****************************************/

// show and hide function in cpanel menu

	function DisplayDiv(div_name, col_exp)
	{
		var div_name = document.getElementById(div_name);
		if(div_name.style.display == 'inline')
		{
			div_name.style.display='none';
			document.getElementById(col_exp).src = "image/plus.gif";
		}
		else if(div_name.style.display == 'none')
		{
			div_name.style.display='inline';
			document.getElementById(col_exp).src = "image/minus.gif";
		}
	}
/****************************************/
