﻿// JScript File By Adel Bamohriz - 15/07/2007


	


function makevisible(cur,which){
strength=(which==0)? 0.7 : 1

if (cur.style.MozOpacity)
    cur.style.MozOpacity=strength
else if (cur.filters)
    cur.filters.alpha.opacity=strength*100
}

////////////////////////////////////////////////////////////////

/********* Numbers only ***********************/////////////////
  function isNumberKey(evt)
  {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "This field accepts numbers only."
        return false
    }
    status = ""
    return true
  
/*     var charCode = (evt.which) ? evt.which : event.keyCode
     if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

     return true;*/
  }
////////////////////////////////////////////////////////////////

// Open Popup window
function popitup(url,iwidth,iheight,itop,ileft,iscrollbars,itoolbar,iresize) {

    //popitup('index.aspx',440,300,0,10,1,1,1);
    var mystr;
    
    if (iwidth=='full')
    mywidth= screen.availWidth;
    else
    mywidth=iwidth;

    if (iheight=='full')
    myheight= screen.availHeight;
    else
    myheight=iheight;
        
    if (iscrollbars==1)
    mystr='scrollbars,';
    
    if (itoolbar==1)
    mystr=mystr + 'toolbar,';
    
    if (iresize==1)
    mystr=mystr + 'resizable,';
    
	newwindow=window.open(url,'popupwindow','width=' + mywidth + ',height=' + myheight + ',top='+ itop + ',left=' + ileft + ',' + mystr + 'return false;');
	if (window.focus) {newwindow.focus()}
	return false;
}
// *************** Text Counter ************************ //
function textCounter(field, countfield, maxlimit) {

if (field.value.length > maxlimit) // if too long...trim it!

field.value = field.value.substring(0, maxlimit);

// otherwise, update 'characters left' counter

else 

countfield.value = maxlimit - field.value.length;

}

/////////////////////// Poll popup /////////////////////////
function doit(rooturl,ctrl,pid,cid){
var obj = document.getElementsByName(ctrl);
var radioLength = obj.length;
var pt;
var iflag=false;
	if(radioLength == undefined)
		if(obj.checked)
		{
			pt= obj.value;
			iflag= true;
		}
		else
			iflag=false;
	for(var i = 0; i < radioLength; i++) {
		if(obj[i].checked) {
			pt= obj[i].value;
			iflag= true;
		}
	}
	if(iflag == false)
	{
	    alert('يجب تحديد خيار');
	    //return false;
	}
	else
	    popitup(rooturl+'poll/poll_result.aspx?pid='+pid+'&pt='+pt+'&cid='+cid ,'417','440',50,110,1,0,0);
}

///////////////// Question Tree View Expand/Collaps ///////////
function ExpandCollapseNode(ctrl,mod)
    {
            var tree = ctrl;

        //var node = tree.SelectedNode;
        var node = tree.Nodes;
        
        for (var i = 0; i < tree.AllNodes.length; i++) //if (node != null && node.Nodes.length!=0)
        {
            if (mod == 1) //if (node && !node.Expanded)
            {
                tree.AllNodes[i].Expand();  //node.Expand();
            }
            else
            {
                tree.AllNodes[i].Collapse();  //node.Collapse();              
            }
        }       
    }
////////// End ///////////////////////////////////////

///////////////////// RadTree
function ExpandCollapseNode(ctrl,mod)
    {
            var tree = ctrl;

        //var node = tree.SelectedNode;
        var node = tree.Nodes;
        
        for (var i = 0; i < tree.AllNodes.length; i++) //if (node != null && node.Nodes.length!=0)
        {
            if (mod == 1) //if (node && !node.Expanded)
            {
                tree.AllNodes[i].Expand();  //node.Expand();
            }
            else
            {
                tree.AllNodes[i].Collapse();  //node.Collapse();              
            }
        }       
    }

