﻿ function NewsWindowOpen(urlText,ww,hh){
 	var neww;
 		neww=window.showModalDialog(urlText,"","dialogWidth:"+ww+"px;dialogHeight:"+hh+"px;Center:yes;resizable:yes;scroll:yes;status:no;help:no;");
 }

function showMenu(obj)
{
    if(document.getElementById)
    {
	    var el = document.getElementById(obj);
	    var ar = document.getElementById("menutop").getElementsByTagName("DIV");
	    if(el.style.display == "none")
	    {
		for (var i=0; i<ar.length; i++)
		{
		    ar[i].style.display = "none";
		}
		el.style.display = "block";
	    }
	    else
	    {
		el.style.display = "none";
	    }
    }

}
			
function SwitchMenu(obj)
{
    if(document.getElementById)
    {
	    var el = document.getElementById(obj);
	    var ar = document.getElementById("cont").getElementsByTagName("DIV");
	    if(el.style.display == "none")
	    {
		for (var i=0; i<ar.length; i++)
		{
		    ar[i].style.display = "none";
		}
		el.style.display = "block";
	    }
	    else
	    {
		el.style.display = "none";
	    }
    }
}


function hideMenuSelect()
{
	var id1 = document.getElementById("menuTop1");
	id1.className='menuTopCell';
	var id2 = document.getElementById("menuTop2");
	id2.className='menuTopCell';
	var id3 = document.getElementById("menuTop3");
	id3.className='menuTopCell';
	var id4 = document.getElementById("menuTop4");
	id4.className='menuTopCell';
	var id5 = document.getElementById("menuTop5");
	id5.className='menuTopCell';
	var id6 = document.getElementById("menuTop6");
	id6.className='menuTopCell';
	var id7 = document.getElementById("menuTop7");
	id7.className='menuTopCell';
	var id8 = document.getElementById("menuTop8");
	id8.className='menuTopCell';	
}

function hideMenuSelect2()
{
	var id1 = document.getElementById("menuTop1");
	id1.className='menuTopCell';
	var id2 = document.getElementById("menuTop2");
	id2.className='menuTopCell';
	var id3 = document.getElementById("menuTop3");
	id3.className='menuTopCell';
	var id4 = document.getElementById("menuTop4");
	id4.className='menuTopCell';
	var id5 = document.getElementById("menuTop5");
	id5.className='menuTopCell';
	var id6 = document.getElementById("menuTop6");
	id6.className='menuTopCell';	
}


function winjadid(linkref,wh,ht){
  newwin=window.open(linkref,'newWin','menubar=no,scrollbars=yes,toolbar=no,status=no,width='+wh+',height='+ht);
}

function winjadidStDt(linkref,wh,ht){
  newwin=window.open(linkref,'newWin','menubar=no,scrollbars=yes,toolbar=no,status=no,resizable=yes,width='+wh+',height='+ht);
}



function winjadid2(linkref){
  newwin2=window.open(linkref,'newWin','menubar=no,toolbar=no,scrollbars=yes,status=no,resizable=yes,width=420,height=300');
}

//******************* Right Menu

function msgShow(){
 var obj=document.getElementById('rightClick');
 var curX=window.event.clientX;  
 var curY=window.event.clientY;

 if((curX+160)>(screen.width-20)){
  curX=curX - 180;
 }  
 obj.style.left=curX;
 obj.style.top=curY;
 obj.style.display="block";
 //window.status = 'X=' + window.event.clientX + ' Y=' + window.event.clientY + '   کليک راست دانشكده مهندسي برق و كامپيوتر' ; 
}

function msgHide(){
 var obj=document.getElementById('rightClick');
 obj.style.display="none"; 
}

function DisableContextMenu(e){
 msgShow();
 return false;
}

 function winOpen(urlText,ww,hh){
 	var neww;
 		neww=window.showModalDialog(urlText,"","dialogWidth:"+ww+"px;dialogHeight:"+hh+"px;Center:yes;resizable:no;scroll:no;status:no;help:no;");
 }


 function regGradeStud(strUrl,para2)
 {
    try
    {
        var Obj=document.getElementById('txt'+para2);
        //alert(Obj.value);
        if( Obj.value=="" )
        {
            alert("لطفاً نمره را وارد كنيد.");
            Obj.focus();
            return false;
        }
        if( (parseFloat(Obj.value)>20) || (parseFloat(Obj.value)<0) )
        {
            alert("نمره بايد در محدوده صفر تا 20 باشد.");
            Obj.focus();
            Obj.select();
            return false;
        }
        //res= confirm("آيا مطمئن به ثبت نمره هستيد؟");
        res=true;
        if(res)
        {
            //alert("masterCPanel_studentsAndGroupsInsert.aspx?"+strUrl+"&gradeStud="+Obj.value);
            sendRequest("http://amoozesh.ustmb.ac.ir/masterCPanel_studentsAndGroupsInsert.aspx?"+strUrl+"&gradeStud="+Obj.value , "col2"+para2 , "col2"+para2 , "col1"+para2 , Obj.value );
        	
        }
    }
    catch(e)
    {
        alert("خطا صورت گرفته است.");
    }
 }
 
 function regGradeStud_Sabt(e,para1,para2)
 {
    var keynum;
	if(window.event) // IE
	  {
	  	keynum = e.keyCode;
	  }
	else if(e.which) // Netscape/Firefox/Opera
	  {
	  	keynum = e.which;
	  }
	  
		if(keynum==13)
		{
		    
			regGradeStud(para1,para2);
		}
 }
 
 //===============================
 function NextControl(e)
 {
    var keynum;
	if(window.event) // IE
	  {
	  	keynum = e.keyCode;
	  }
	else if(e.which) // Netscape/Firefox/Opera
	  {
	  	keynum = e.which;
	  }
	  
		if(keynum==13)
		{
		    
			 var Obj=document.getElementById('EnterToAccount');
            Obj.focus();
         }		
 }

//****************************
//var http = createRequestObject();
//**************************** 

function createRequestObject()
{
    try
    {    
	    var ro;
	    var browser = navigator.appName;
	    if(browser == "Microsoft Internet Explorer"){
		    ro = new ActiveXObject("Microsoft.XMLHTTP");
	    }else{
		    ro = new XMLHttpRequest();
	    }
	    return ro;
	}
	catch(e)
	{
	    alert("خطا صورت گرفته است.")
	}
}


function sendRequest(action,targetDiv1,targetDiv2,targetDiv3, paraGrade) {
    try
	{
        var http = createRequestObject();
	    //http.open('POST',action); // 'getStudent.aspx?studID='+escape(action)
	    http.open('POST',action);//GET
	    http.onreadystatechange = function(){    
	        if(http.readyState == 1){
	            var strHTML="<div style='text-align:center;'>";
	            strHTML +="<img style='border:0px;' src='require_files/miniAnim.gif' alt='كمي صبر كنيد' /></div>";
	            document.getElementById(targetDiv1).innerHTML=strHTML;
	        }else if(http.readyState == 4){

		            var response = http.responseText;
		            //alert(response);
		            document.getElementById(targetDiv2).innerHTML = response;
		            document.getElementById(targetDiv3).innerHTML = "<span style='color:red; font-weight:600;'>"+paraGrade+"</span>";
   
	        }
        };
        http.send(null);
    }
    catch(e)
    {
	    alert("خطا صورت گرفته است.");
	}
}
 
