var flg;

var searchControl;
var mysearchForm;
function OnLoad() {
  searchControl = new google.search.SearchControl();
  var options = new GsearcherOptions();
  options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
  var siteSearch = new GwebSearch();
  siteSearch.setUserDefinedLabel("ShahroodUT.ac.ir");
  siteSearch.setSiteRestriction("ShahroodUT.ac.ir");
  searchControl.addSearcher(siteSearch,options);
  searchControl.addSearcher(new GwebSearch());
  searchControl.addSearcher(new GnewsSearch());
  searchControl.addSearcher(new GbookSearch());
  searchControl.setResultSetSize(GSearch.LARGE_RESULTSET); 

  var drawOptions = new GdrawOptions();
  drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
  //drawOptions.setSearchFormRoot(document.getElementById("searchForm"));
  
  
  mysearchForm = new GSearchForm(false, document.getElementById("searchForm"));
  mysearchForm.setOnSubmitCallback(null, OnSearchStarting); 
  drawOptions.setInput(mysearchForm);
     
  searchControl.draw(document.getElementById("searchresults"),drawOptions);
}
try
{
google.load("search", "1");

google.setOnLoadCallback(OnLoad);
}
catch(e)
{
	
}

window.onload = function()
{
	po(6); 
	showbox(1)
}

function OnSearchStarting(mysearchForm)
{
    searchControl.execute(mysearchForm.input.value);
    document.getElementById('btn6').style.display='block';
    po(6);
    return false;
}        

function po(n)
{
    flg=n;
    clearTimeout;
    setTimeout("tempfunc("+n+")",300);
}    
function tempfunc(n)
{
    if (flg==0 || flg!=n) return;
    temp="btn"+ n;
    document.getElementById(temp).style.background="url(images/button.jpg) no-repeat right";
    document.getElementById(temp).style.fontWeight="bold";
    //document.getElementById(temp).style.color="#366C90";
    document.getElementById(temp).style.color="#D76000";
    var object=document.getElementById('div'+n);
    /*object.style.opacity = 0;
    object.style.MozOpacity = 0;
    object.style.KhtmlOpacity = 0;
    object.style.filter="alpha(opacity=0)";
    object.style.display="block";
    FadeIn('div'+n);*/
    object.style.display="block"
    for(i=1;i<=7;i++)
    {
        if (i==n) continue;
        temp="btn"+ i;
        document.getElementById(temp).style.background="";
        document.getElementById(temp).style.fontWeight="";
        document.getElementById(temp).style.color="black";
        document.getElementById('div'+i).style.display='none';
    }
}
function FadeIn(item)
{
    for (i=0;i<=100;i++)
    {
        clearTimeout();
        setTimeout("ChangeOpac('"+item+"',"+i+")",i*2);
    }
}
function  ChangeOpac(item,opac)
{
    var obj=document.getElementById(item)
    obj.style.MozOpacity = (opac/100);
    obj.style.opacity = (opac/100);
    obj.style.KhtmlOpacity = (opac/100); 
    obj.style.filter="alpha(opacity="+opac+")";
} 
function hideResults()
{
    document.getElementById('btn6').style.display='none';
    po(5);
}
function showbox(item)
{
    for (i=1;i<=4;i++)
        if (i==item)
        {
            document.getElementById('box'+i).style.display='block';
            document.getElementById('wsl'+i).style.border='1px solid #A2AAAD';
            document.getElementById('wsl'+i).style.borderBottom='';
            document.getElementById('wsl'+i).style.fontWeight='bold';
            document.getElementById('wsl'+i).style.backgroundColor='#EBF8FE';            
        }
        else
        {
            document.getElementById('box'+i).style.display='none';
            document.getElementById('wsl'+i).style.border='1px solid #EFFBFF';
            document.getElementById('wsl'+i).style.borderBottom='';
            document.getElementById('wsl'+i).style.fontWeight='';
            document.getElementById('wsl'+i).style.backgroundColor='';
        }
}
function doLogin()
{
    if (document.getElementById('uname').value=="")
    {
        cheshmak=true;
        mhmdam('uname',0);
        return false;
    }
        if (document.getElementById('upass').value=="")
    {
        cheshmak=true;
        mhmdam('upass',0); 
        return false;
    }
    document.getElementById('loginform').submit();
}
function mhmdam(objname,flg)
{
    obj=document.getElementById(objname);
    if (flg==0)
        obj.style.backgroundColor="#fff";
    else
        obj.style.backgroundColor="#fff0f7";    
    flg=!flg;
    if (cheshmak) 
        setTimeout("mhmdam('"+objname+"',"+flg+")",500);
    else
        obj.style.backgroundColor="#fff";    
}
function clearpass1()
{
	document.getElementById('normal_username2').value=document.getElementById('musername').value;
	document.getElementById('normal_password2').value=document.getElementById('mpassword').value;
	document.getElementById('formmail').submit();
	document.getElementById('musername').value='';
	document.getElementById('mpassword').value='';
	return false;
}
function clearpass2()
{
	document.getElementById('normal_username').value=document.getElementById('normal_username1').value;
	document.getElementById('normal_password').value=document.getElementById('normal_password1').value;
	document.getElementById('forminternet').submit();
	document.getElementById('normal_password1').value='';
	document.getElementById('normal_username1').value='';
	return false;
}
