function increasefontsize(s) {
   var p = document.getElementById('shownewstext');
      p.style.fontSize = s+"px"
}
function insertEmoticon(tag){
	if(document.getElementById('message').value != 'متن پيام ...'){
		document.getElementById('message').value += tag;
	}else{
		document.getElementById('message').value = tag;
	}
}
function search(link,search_value){
	document.location.href = link+'search/'+search_value+'/';
}
function changestatusslide()
{
	var clsname = document.getElementById('hostslidebutton').classname;
	if(clsname == 'slidearrowup')
	{
		document.getElementById('hostslidebutton').classname = 'slidearrowdwon';
		document.getElementById('hostslidebutton').href = "javascript:slide('hostingpanels',{oncomplete:function(){changestatusslide();}}).down();";
		slider = 0;
		setcookie('hostslide','0',1);
	}
	else
	{
		document.getElementById('hostslidebutton').classname = 'slidearrowup';
		document.getElementById('hostslidebutton').href = "javascript:slide('hostingpanels',{oncomplete:function(){changestatusslide();}}).up();";
		slider = 1;
		setcookie('hostslide','1',1);
	}
}
function avatar_choose(avatar_name){
document.getElementById('choose_avatar').style.display='none';
document.getElementById('avatar_image_user_value').value =avatar_name;
document.images['avatar_image_user'].src= web_link+'module_images/chatroom/big/'+avatar_name;
document.getElementById('avatar').style.display='block';
}
function back_to_avatar_choose(){
document.getElementById('choose_avatar').style.display='block';
document.getElementById('avatar').style.display='none';
}
function changethemecolor(name,id_theme) {
	if(id_theme == 1){
		config. BgColor			= '#D3E9F8';
		config. FontColor		= '#525974'
		config. BorderColor		= '#92C9ED';
	}else 	if(id_theme == 2){
		config. BgColor			= '#D9E6C8';
		config. FontColor		= '#525974'
		config. BorderColor		= '#A9C583';
	}else 	if(id_theme == 3){
		config. BgColor			= '#E7E7EB';
		config. FontColor		= '#525974'
		config. BorderColor		= '#ACADB9';
	}else{
		config. BgColor			= '#FDDFE3';
		config. FontColor		= '#525974'
		config. BorderColor		= '#FAADB9';
	}
	document.getElementById('cssfile').href = name;
	deletecookie('themecolor');
	deletecookie('id_themecolor');
	setcookie('themecolor',name,7);
	setcookie('id_themecolor',id_theme,7);
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function setcookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ';path="/";expires='+exdate.toGMTString());
}

function deletecookie(c_name)
{
document.cookie=c_name+'="";path="/";expires="Thu, 01-Jan-1970 00:00:01 GMT";';
}

function blockstatchange(eventer,o)
{
	var object = document.getElementById(o);
	if(!object.style.display)
	{
		object.style.display = 'none';
		eventer.classname = 'cbsb cbsbplus';
	}else
	{
		object.style.display = '';
		eventer.classname = 'cbsb cbsbmin';
	}
}

function evalscript(_source) {
		var source = _source;
		var scripts = new Array();
		
		// Strip out tags
		while(source.indexOf("<script") > -1 || source.indexOf("</script") > -1) {
	var s = source.indexOf("<script");
	var s_e = source.indexOf(">", s);
	var e = source.indexOf("</script", s);
	var e_e = source.indexOf(">", e);
	
	// Add to scripts array
	scripts.push(source.substring(s_e+1, e));
	// Strip from source
	source = source.substring(0, s) + source.substring(e_e+1);
		}
		
		// Loop through every script collected and eval it
		for(var i=0; i<scripts.length; i++) {
	try {
		eval(scripts[i]);
	}
	catch(ex) {
		// do what you want here when a script fails
	}
		}
		return source;
}

function GetXmlHttpObject()
{
        var xmlhttp;
        /** Special IE only code ... */
        /*@cc_on
          @if (@_jscript_version >= 5)
              try
              {
                  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
              }
              catch (e)
              {
                  try
                  {
                      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                  }
                  catch (E)
                  {
                      xmlhttp = false;
                  }
             }
          @else
             xmlhttp = false;
        @end @*/
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
        {
            try
            {
                xmlhttp = new XMLHttpRequest();
            }
            catch (e)
            {
                xmlhttp = false;
            }
        }

        return xmlhttp;
}

function pageload(page,usediv) {
	var xmlhttp = false;
	xmlhttp = GetXmlHttpObject();
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState == 4 && (xmlhttp.status==200 || window.location.href.indexOf("http")==-1)){
			document.getElementById(usediv).innerHTML = evalscript(xmlhttp.responseText);
		}
	}
    xmlhttp.open("GET", page,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send(null);
   return false;
}
function pagesend(page,usediv,sendpost) {
	var xmlhttp = false;
	xmlhttp = GetXmlHttpObject();
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState == 4 && (xmlhttp.status==200 || window.location.href.indexOf("http")==-1)){
			document.getElementById(usediv).innerHTML = evalscript(xmlhttp.responseText);
		}
	}
    xmlhttp.open("POST", page,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send(sendpost);
   return false;  
}


function submitrate(id,score)
{
	xmlhttp=getxmlhttpobject();
	if (xmlhttp==null)
	{
	  alert ("your browser does not support ajax!");
	  return;
	}
	var theul = document.getElementById('unit_ul'+id);
	theul.innerhtml = '<div class="loading"></div>';
	var url="ajax.php?req=submitnewsrate&score="+score+"&id="+id;
	xmlhttp.onreadystatechange=loadrate;
	xmlhttp.open('get', url, true);
	xmlhttp.send(null);
}
function loadrate()
{
	if(xmlhttp.readystate==4)
      {
		var response = xmlhttp.responsetext;
        var upDate = new array();

        if(response.indexof('|') != -1) {
            upDate = response.split('|');
			document.getElementById(upDate[0]).innerhtml = upDate[1];
        }
	  }
}

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

function shoutbox(web_folder){
	pageload(web_folder+'shout_box/','chatbox');
	wait_shout_box = setTimeout(function(){shoutbox(web_folder)}, 2000);
}
function addBookmark(title, url) {
        if (window.sidebar) { // firefox
              window.sidebar.addPanel(title, url,"");
        } else if( document.all ) { //MSIE
                window.external.AddFavorite( url, title);
        } else {
               alert("Sorry, your browser doesn't support this");
        }
}

var tablink_idname = new Array("tablink","anotherlink")
var tabcontent_idname = new Array("tabcontent","anothercontent") 
var tabcount = new Array("9","9")
var loadtabs = new Array("0","9")  
var autochangemenu = 1;
var changespeed = 12;
var stoponhover = 0;
function easytabs(menunr, active) {
	if (menunr == autochangemenu){currenttab=active;}
	if ((menunr == autochangemenu)&&(stoponhover==1)) {stop_autochange()}
	else if ((menunr == autochangemenu)&&(stoponhover==0))  {counter=0;}
	menunr = menunr-1;
	for (i=0; i <= tabcount[menunr]; i++){
		if(document.getElementById(tablink_idname[menunr]+i)){
			document.getElementById(tablink_idname[menunr]+i).className='tab'+i;
		}
		if(document.getElementById(tabcontent_idname[menunr]+i)){
			document.getElementById(tabcontent_idname[menunr]+i).style.display = 'none';
		}
	}
	if(document.getElementById(tablink_idname[menunr]+active)){
		document.getElementById(tablink_idname[menunr]+active).className='tab'+active+' tabactive';
	}
	if(document.getElementById(tabcontent_idname[menunr]+active)){
		document.getElementById(tabcontent_idname[menunr]+active).style.display = 'block';
	}
}
var timer;
counter=0;
var totaltabs=tabcount[autochangemenu-1];
var currenttab=loadtabs[autochangemenu-1];
function start_autochange(){
	 counter=counter+1;
	 timer=setTimeout("start_autochange()",1000);
	 if (counter == changespeed+1) {
		 currenttab++;
		 if (currenttab>totaltabs) {currenttab=1}
			easytabs(autochangemenu,currenttab);
		restart_autochange();
	}
}
function nextnews(){
	 currenttab++;
	 if (currenttab>totaltabs) {currenttab=1}
	 easytabs(autochangemenu,currenttab);
}
function backnews(){
	 currenttab--;
	 if (currenttab<0) {currenttab=totaltabs;}
	 easytabs(autochangemenu,currenttab);
}
function restart_autochange(){
	clearTimeout(timer);
	counter=0;
	if(document.getElementById('play'))document.getElementById('play').innerHTML= '<a href="#"  onclick="stop_autochange();return false;"> <img src="'+temp_link+'images/button-p.png" width="15" /></a>';
	start_autochange();
}
function stop_autochange(){
	clearTimeout(timer);
	counter=0;
	document.getElementById('play').innerHTML = '<a href="#"  onclick="restart_autochange();return false;"> <img src="'+temp_link+'images/disable-pause.bmp" width="15" /></a>';
	
}

window.onload=function(){
	var menucount=loadtabs.length;
	var a = 0;
	var b = 1;
	do {easytabs(b, loadtabs[a]);  a++; b++;}
	while (b<=menucount);
	if (autochangemenu!=0){start_autochange();}
}

function TabActive(idActive1,idActive2,idActive3,idActive4,idActive5){
document.getElementById(idActive1).className = 'Active';
document.getElementById(idActive2+'div').style.display = 'none';
document.getElementById(idActive2).className = '';
document.getElementById(idActive1+'div').style.display = '';
if(idActive3 != ''){
	document.getElementById(idActive3).className = '';
	document.getElementById(idActive3+'div').style.display = 'none';
}
if(idActive4 != ''){
	document.getElementById(idActive4).className = '';
	document.getElementById(idActive4+'div').style.display = 'none';
}
if(idActive5 != ''){
	document.getElementById(idActive5).className = '';
	document.getElementById(idActive5+'div').style.display = 'none';
}
}
