﻿function loadMTopFuncIndex()
{
    if(document.getElementById)
    {
        var tPara="";
        var myTitleText=document.getElementById('frameTitleHomePage');
        
        var myTableCell = document.getElementById('menuTopBlueStar').getElementsByTagName("td");;

	    for(var i=0;i<myTableCell.length;i++)
	    {            
            if(myTableCell[i].className!="tempBar" && myTableCell[i].className!="separator")
		    {

                //onmouseover="if(this.className=='menuTopCell'){this.className='menuTopOver';}"
                //onmouseout="if(this.className=='menuTopOver'){this.className='menuTopCell';}"
                //onclick="hideMenuSelect();this.className='select_Col';showMenu('link_manager');"
			    
			    myTableCell[i].onmouseover=function(){ if(this.className=='cellRegular'){this.className="cellMouseOver";} };
			    myTableCell[i].onmouseout=function(){ if(this.className=='cellMouseOver'){this.className="cellRegular";} };
			    
			    
			    if(i==1)
			    {
			        myTableCell[i].onclick=function()
			        {
			            hideMenuSelect();
			            this.className="cellSelect";
		                myTitleText.innerText="آخرین اخبار و اطلاعیه ها";
		                tPara='IndexGetData.aspx?tabID=news';
				        makeRequest(tPara,'frameBodyHomePage','frameBodyHomePage');
				        //alert("Cell 1");
			        };
			    }
			    else if(i==3)
			    {
			        myTableCell[i].onclick=function()
			        {
			            hideMenuSelect();
			            this.className="cellSelect";
		                myTitleText.innerText="تقویم آموزشی موسسه";
		                tPara='IndexGetData.aspx?tabID=calendar';
				        makeRequest(tPara,'frameBodyHomePage','frameBodyHomePage');
				        //alert("Cell 5");
			        };
			    }
			    else if(i==5)
			    {
			        myTableCell[i].onclick=function()
			        {
			            hideMenuSelect();
			            this.className="cellSelect";
		                myTitleText.innerText="رویدادهای آینده موسسه";
		                tPara='IndexGetData.aspx?tabID=event';
				        makeRequest(tPara,'frameBodyHomePage','frameBodyHomePage');
				        //alert("Cell 3");
			        };
			    }
			    else if(i==7)
			    {
			        myTableCell[i].onclick=function()
			        {
			            window.location="http://amoz.mit.ac.ir/";
			            /*
			            hideMenuSelect();
			            this.className="cellSelect";
		                myTitleText.innerText="ارتباط با موسسه";
		                tPara='IndexGetData.aspx?tabID=contact';
		                tPara='contactUs.aspx';
				        makeRequest(tPara,'frameBodyHomePage','frameBodyHomePage');
				        //alert("Cell 7");
				        */
			        };
			    }
			    else if(i==9)
			    {
			        myTableCell[i].onclick=function()
			        {
			            hideMenuSelect();
			            this.className="cellSelect";
		                myTitleText.innerText="ارتباط با موسسه";
		                tPara='IndexGetData.aspx?tabID=contact';
		                tPara='contactUs.aspx';
				        makeRequest(tPara,'frameBodyHomePage','frameBodyHomePage');
				        //alert("Cell 7");
			        };
			    }
		    }
        }
    }
}

function loadMTopFunc()
{
    if(document.getElementById)
    {
        var myTableCell = document.getElementById('menuTopBlueStar').getElementsByTagName("td");

	    for(var i=0; i<myTableCell.length; i++)
	    {            
            if(myTableCell[i].className!="tempBar" && myTableCell[i].className!="separator")
		    {
			    myTableCell[i].onmouseover=function(){ if(this.className=='cellRegular'){this.className="cellMouseOver";} };
			    myTableCell[i].onmouseout=function(){ if(this.className=='cellMouseOver'){this.className="cellRegular";} };
		    }
        }
    }
}

function selectMTopFunc(para)
{
    if(document.getElementById)
    {
        //******* Reset  Select *******
        var myTableCell = document.getElementById('menuTopBlueStar').getElementsByTagName("td");
	    for(var i=0; i<myTableCell.length; i++)
	    {            
            if(myTableCell[i].className!="tempBar" && myTableCell[i].className!="separator")
		    {			        
			    myTableCell[i].className = 'cellRegular';
		    }
        }
        
        //******* Start  Select *******
        var myCell = document.getElementById(para);
        myCell.className = "cellSelect";
    }
}    

function hideMenuSelect()
{
    if(document.getElementById)
    {
        var myTableCell = document.getElementById('menuTopBlueStar').getElementsByTagName("td");;

	    for(var i=0;i<myTableCell.length;i++)
	    {            
            if(myTableCell[i].className!="tempBar" && myTableCell[i].className!="separator")
		    {
		        myTableCell[i].className="cellRegular";
		    }	    
		}
	} 
}


//********************
function href(paraLink)
{
	window.location.href=paraLink;
}

function winjadid(linkref,wh,ht)
{
    var myVal=Math.floor(100000*Math.random());
    newwin=window.open(linkref,'newWin'+myVal,'menubar=no,toolbar=no,status=no,width='+wh+',height='+ht);
}

function winjadid2(linkref,wh,ht)
{
    var myVal=Math.floor(100000*Math.random());
    newwin2=window.open(linkref,'newWin'+myVal,'menubar=no,toolbar=no,scrollbars=yes,status=no,resizable=yes,width='+wh+',height='+ht);
}

function winDialog(urlText,ww,hh)
{
    var browser = navigator.appName;
	var neww;
	if(browser == "Microsoft Internet Explorer")
	{
		neww=window.showModalDialog(urlText,"","dialogWidth:" + ww + "px; dialogHeight:" + hh + "px; Center:yes; resizable:no; scroll:no; status:no; help:no;");
	}else
	{
	    neww=window.open(urlText,'newWin','menubar=no,scrollbars=no,toolbar=no,sizable=no,status=no,width='+ww+',height='+hh);
	}
}
//**********************

function showHideItem(obj)
{
    if(document.getElementById)
    {
	    var el = document.getElementById(obj);
	    
	    if(el.style.display == "none")
	    {
            var browser = navigator.appName;
            if(browser == "Microsoft Internet Explorer"){
	            el.style.display = "block";   
            }else{
	            el.style.display = 'table-row';
            }
	    }
	    else
	    {
	        el.style.display = "none";
	    }
    }
}

function changeStyle(objStyle,objSH)
{
    if(document.getElementById)
    {
	    var el = document.getElementById(objSH);//objStyle
	    var myRow = document.getElementById(objStyle);
	    //alert(el.style.backgroundColor);
	    if(el.style.display == "none")
	    {
	        //el.style.backgroundColor = '#CCFFCC';
	        //alert(el.style.backgroundColor);
	        myRow.style.backgroundColor = '#CCFFCC';
	    }
	    else
	    {
	        myRow.style.backgroundColor = '';
	        //el.style.backgroundColor = '';
	        //alert(el.style.backgroundColor);
	    }
	    
	    showHideItem(objSH);
    }
}

//***********************
//******** AJAX *********
//***********************

function makeRequest(urlID,targetID1,targetID2)
{
    var httpRequest;
    if (window.XMLHttpRequest)
    { // Mozilla, Safari, ...
        httpRequest = new XMLHttpRequest();
        if (httpRequest.overrideMimeType) {
            httpRequest.overrideMimeType('text/xml');
            // See note below about this line
        }
    } 
    else if (window.ActiveXObject)
    { // IE
        try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) {
            try {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e) {}
        }
    }

    if (!httpRequest) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    httpRequest.onreadystatechange = function() { alertContents(httpRequest,targetID1,targetID2); };
    httpRequest.open('GET', urlID, true);
    httpRequest.send('');
}

function alertContents(httpRequest,targetID1,targetID2)
{
    if(httpRequest.readyState == 1)
    {
        var strHTML="<p dir='rtl' align='center' style='font-size:9pt; font-family:tahoma; color:#0c0c0c;'>&#1604;&#1591;&#1601;&#1575;&#1611; &#1670;&#1606;&#1583; &#1604;&#1581;&#1592;&#1607; &#1605;&#1606;&#1578;&#1592;&#1585; &#1576;&#1605;&#1575;&#1606;&#1610;&#1583;...<br />";
        strHTML +="<img style='border:0px;' src='require_files/loading.gif' /></p>";	    
        document.getElementById(targetID1).innerHTML=strHTML;
    }
    else if (httpRequest.readyState == 4)
    {
        if (httpRequest.status == 200)
        {
            //alert(httpRequest.responseText);
            document.getElementById(targetID2).innerHTML=httpRequest.responseText;
        } else {
            alert('There was a problem with the request.');
        }
    }
}

//******************* Right Menu
function menuRightShow(para)
{
    if(document.getElementById)
    {
	    var obj = document.getElementById(para);	    
	    if(obj.style.display != "block")
	    {
		    obj.style.display = "block";
		}
		else
		{
		    obj.style.display = "none";
		}
    }
}

//**********************

function galleryImageShow(imageID)
{
    if(document.getElementById)
    {
	    var myFrame = document.getElementById('framePicShow');
	    myFrame.src='imageViewGallery.aspx?galleryID='+imageID;    
    }
}

function showPicBig(pathImg,titleImg)
{
    if(document.getElementById)
    {
	    var myBigImg = document.getElementById('bigImageHome');
	    myBigImg.src=pathImg;
	    myBigImg.title=titleImg;
	    	    //*******************
	    var myDivTitle = document.getElementById('bigImageHomeTitle');
	    myDivTitle.innerText=titleImg;
	    myDivTitle.innerHTML=titleImg;
    }
}

function showMenuTopManager(para)
{
    try
    {
        var Obj=document.getElementById("sMenu_"+para);
        Obj.style.display='block';
    }
    catch(e)
    {
        alert("Error event");
    }
}

//**********************

function galleryImageShow(imageID)
{
    if(document.getElementById)
    {
	    var myFrame = document.getElementById('framePicShow');
	    myFrame.src='imageViewGallery.aspx?galleryID='+imageID;    
    }
}

function showPicBig(pathImg,titleImg)
{
    if(document.getElementById)
    {
	    var myBigImg = document.getElementById('bigImageHome');
	    myBigImg.src=pathImg;
	    myBigImg.title=titleImg;
	    	    //*******************
	    var myDivTitle = document.getElementById('bigImageHomeTitle');
	    myDivTitle.innerText=titleImg;
	    myDivTitle.innerHTML=titleImg;
    }
}

//****************
function myShowHideMenu()
{
    if(document.getElementById)
    {
	    var myTD1 = document.getElementById('myTDMenu1');
	    var myTD2 = document.getElementById('myTDMenu2');
	    
	    myTD1.style.display="none";
	    myTD2.style.display="none";
    }
}


//Show Image Gallery
//*************
function showImageGallery(sourceID, place) {
    if (document.getElementById) {
        var frameID = document.getElementById('framePicShow');

        var myPlc = '';
        switch (place) {
            case 'gallery':
                myPlc = "file_part/gallery_part"; break;
            case 'first':
                myPlc = "imageFirst_part"; break;
        }

        if (frameID)
            frameID.src = myPlc + "/" + sourceID;
        else
            frameID.src = "require_files/noPic.gif";
        /*alert(sourceID);*/
    }
}
//*************

