

window.onload=function(){
    //alert(window.screenX);
    var news_height=$('news').clientHeight;
    //alert($("ctl00_ContentPlaceHolder1_GridView3").clientHeight);
    if($("news_box"))
    {
        $('news_box').style.height=news_height+"px";
        $('td_doc').style.height=news_height+"px";
        move_news(news_height);
    }
    var browserVersion=BrowserDetect.browser+" "+BrowserDetect.version;
    GetBrowserAttribute(browserVersion);
}
function $($id,$parent) {
	//alert("find_obj :"+id)
	if( typeof($parent) == 'object'){
		var e = $parent.document.getElementById($id);
	}else{
		var e = document.getElementById($id);
	}//end if
	if(e){
		return(e);
	}else{
		return(false);
	}//end if
}//end func

function GetBrowserAttribute(browserVersion)
{
    var e=$("content_td");
    var eh=e.style.height;
    //alert()
    if(browserVersion=="Explorer 6")
    {
        e.style.height="432px";
        
    }
    else if(browserVersion=="Explorer 7")
    {
        e.style.height="auto";
    }//end if
}

var n=0;

function move_news(h){   
    document.getElementById('news_box').onmouseover=function(){n=1;}
    document.getElementById('news_box').onmouseout=function(){n=0;}
    var  e=document.getElementById('news');
    var e2=document.getElementById('news2');
    //alert(h)
    k=-1*h;
    if(parseInt(e.style.top)==k)e.style.top=h;
    if(parseInt(e.style.top)==0)e2.style.top=h;
    var top_news=parseInt(e.style.top);
    var top_news2=parseInt(e2.style.top);
    if(top_news>k&&n==0)
    {
        top_news--;
        e.style.top=top_news;
        top_news2--;
        e2.style.top=top_news2;      
    }
    var timer = setTimeout("move_news("+h+")",65);
}
function stop_news()
{
  n=1;
}

function show_news(pe)
{
	var e=pe.parentNode;
	
	//alert(e.childNodes.length);
	for(var counter in e.childNodes)
	{  
	    if(e.childNodes[counter].tagName=='TABLE')
	    {
	        var p = e.childNodes[counter]
	        if(p.style.display=='none') p.style.display='block';
	        else if(p.style.display=='block') p.style.display='none';
	    }
	}
}

var test_state=0;
var t;

function show_hide_panel()
{
    //alert($('ctl00_ContentPlaceHolder1_GridView8').clientHeight);
    var c=clearTimeout(t);
    //alert($("ctl00_ContentPlaceHolder1_GridView8").clientHeight)
    if(test_state==0){
        show_linklist();
        $('action').src='Image/action_down.gif';
        }//////action
        else{
        hide_linklist();
	    $('action').src='Image/action_left.gif';
        }
}
function show_linklist(){
	var pe=document.getElementById('list');
	var pe_h=parseInt(pe.style.height);
	var end =parseInt(pe.clientHeight);
	if(pe_h<250){
		pe_h+=50;
		pe.style.height=pe_h;
	}
	else{
	pe.style.height="325px";
	test_state=1;
	}
	t=setTimeout('show_linklist()',1);
}

function hide_linklist(){

	var pe=$('list');
	var pe_h=parseInt(pe.style.height);
	if(pe_h>50){
		pe_h-=50;
		pe.style.height=pe_h;
	}
	else{
	pe.style.height="18px";
	test_state=0;
	}
	t=setTimeout('hide_linklist()',1);
}

var test_more_state=0;
var min_h=0;
function show_hide_search()
{
    if(test_more_state==0)
    {
        $("div_cmd_search").style.display='none';
        $("div_more").style.color='#008b8b';
        $("div_more").style.background='url(Image/action_up.gif) no-repeat';
        show_more_search();
    }
    else
    {
        $("div_more").style.color='#b22222';
        $("div_more").style.background='url(Image/action_down.gif) no-repeat';
        hide_more_search();
    }//end if
}//end func show_hide_search

function show_more_search()
{
    var e=$("period_search");
    var $h=parseInt(e.style.height);
    var txtbx=$("div_txt");
    var $h_txt=parseInt(txtbx.style.width);
    if($h<=85)
    {
        $h+=20;
        $h_txt+=7;
        e.style.height=$h;
        txtbx.style.width=$h_txt;
        setTimeout('show_more_search()',1);
    }
    else
    {
        e.style.height="170px";
        txtbx.style.width="130px";
        test_more_state=1;
    }//end if
}//end func show_more_search

function hide_more_search()
{
    var e=$("period_search");
    var $h=parseInt(e.style.height);
    var txtbx=$("div_txt");
    var $h_txt=parseInt(txtbx.style.width);
    if($h>=50)
    {
        $h-=20;
        $h_txt-=7;
        e.style.height=$h;
        txtbx.style.width=$h_txt;        
        setTimeout('hide_more_search()',1);
    }
    else
    {
        $("div_cmd_search").style.display='block';
        e.style.height="40px";
        txtbx.style.width="88px";
        test_more_state=0;
    }//end if
}//end func hide_more_search

var date_state=0;
function show_hide_date()
{
    if(date_state==0)
    {
        $("div1").style.background="url(Image/minus.gif) no-repeat right 0%";
        show_date();       
    }
    else
    {
        $("div1").style.background="url(Image/plus.gif) no-repeat right 0%";
        hide_date();       
    }//end if   
}
function show_date()
{
    var e=$("date_period");
    var pe=$("period_search");
    var hpe=parseInt(pe.style.height);
    var h=parseInt(e.style.height);
    if(h<=40)
    {
        h+=10;
        hpe+=10;
        pe.style.height=hpe;
        e.style.height=h;
        setTimeout('show_date()',1);
    }
    else
    {
        e.style.height="60px";
        date_state=1;
        
    }//end if
}//end func show_date

function hide_date()
{
    var e=$("date_period");
    var pe=$("period_search");
    var hpe=parseInt(pe.style.height);
    var h=parseInt(e.style.height);
    if(h>16)
    {
        h-=5;
        hpe-=5;
        pe.style.height=hpe;
        e.style.height=h;
        setTimeout('hide_date()',1);
    }
    else
    {
       e.style.height="16px";
       date_state=0; 
    }//end if
}//end func show_date

var loc_state=0;
function show_hide_loc()
{
    if(loc_state==0)
    {
        $("div2").style.background="url(Image/minus.gif) no-repeat right 0%";
        show_loc();       
    }
    else
    {
        $("div2").style.background="url(Image/plus.gif) no-repeat right 0%";
        hide_loc();       
    }//end if   
}
function show_loc()
{
    var e=$("loc_period");
    var pe=$("period_search");
    var hpe=parseInt(pe.style.height);
    var h=parseInt(e.style.height);
    if(h<=40)
    {
        h+=10;
        e.style.height=h;
        hpe+=10;
        pe.style.height=hpe;
        setTimeout('show_loc()',1);
    }
    else
    {
        e.style.height="40px";
        loc_state=1;
        $("ctl00_ContentPlaceHolder1_TextBox2").focus();
        
    }//end if
}//end func show_date

function hide_loc()
{
    var e=$("loc_period");
    var pe=$("period_search");
    var hpe=parseInt(pe.style.height);
    var h=parseInt(e.style.height);
    if(h>16)
    {
        h-=5;
        hpe-=5;
        pe.style.height=hpe;
        e.style.height=h;
        setTimeout('hide_loc()',1);
    }
    else
    {
       e.style.height="16px";
       loc_state=0; 
    }//end if
}//end func show_date

function valid_value()
{
    var e=$("div_txt");
    if(e.childNodes[0].value=="")
    {
        alert("عنوان دوره را وارد نمایید!");
        return false;
    }
    else return true;
}


//detect features of all Browsers
var BrowserDetect = {
	init: function(){
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	}//end func
	,
	searchString: function (data) {
		for( var i=0;i<data.length;i++ ){
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if( dataString ){
				if( dataString.indexOf(data[i].subString) != -1 )return(data[i].identity);
			}else if( dataProp ){
				return(data[i].identity);
			}//end if
		}//end for
	}//end func
	,
	searchVersion: function( dataString ){
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	}//end func
	,
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"

		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]
}//end class
BrowserDetect.init();//for example BrowserDetect.browser or BrowserDetect.OS or BrowserDetect.version
//alert(BrowserDetect.browser)
