﻿var marqueeheight;
function shoutbox(user, comment)
{
xmlhttpshout=GetXmlHttpObject();
if (xmlhttpshout==null)
{
  alert ("Browser does not support HTTP Request");
  return;
}
document.getElementById('scripdiv').innerHTML="<center><b><img src = 'images/loader.gif' border = '0' align='middle' width='25' height='25'><span style='vertical-align: middle'>در حال بارگزاری</span></b></center>";
document.getElementById('scripdiv').style.display="block";
if (user =="emoticonremove"){
	url= 'ajax.php?emoticonremove='+ comment +'&ShoutSubmit=emoticonremove';
}else{
if (comment == 'refresh' && user == 'refresh'){
	url= 'ajax.php?shoutuid=refresh&ShoutComment=refresh&ShoutSubmit=ShoutPost&button=فرستادن';
}else{
	ShoutComment1 = document.getElementById(comment).value;
	if ( document.getElementById(user) == null){
		url= 'ajax.php?ShoutComment=' + encodeURIComponent(ShoutComment1) +'&ShoutSubmit=ShoutPost&button=فرستادن';
	}else{
		boxtext1 = document.getElementById(user).value;
			url='ajax.php?shoutuid=' + encodeURIComponent(boxtext1) + '&ShoutComment=' + encodeURIComponent(ShoutComment1) +'&ShoutSubmit=ShoutPost&button=فرستادن';
	}
}}
	xmlhttpshout.onreadystatechange=stateChangedshout;
	xmlhttpshout.open("GET",url,true);
	xmlhttpshout.send(null);
}

function stateChangedshout()
{
if (xmlhttpshout.readyState==4){
  	document.getElementById('shout_boxdiv').innerHTML=  xmlhttpshout.responseText;
	document.getElementById('scripdiv').style.display="none";
	marqueeheight=document.getElementById("marqueecontainer").offsetHeight
	cross_marquee.style.top=marqueeheight;
  	}
}
function GetXmlHttpObject()
{
var objXMLHttp=null;
if (window.XMLHttpRequest)
  {
  objXMLHttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
return objXMLHttp;
}
function changeBoxSize(showhide) {
document.getElementById('smilies_hide').style.display='none';
document.getElementById('smilies_show').style.display='none';
document.getElementById('smilies_'+showhide).style.display='block';
}
function DoSmilie(addSmilie, messageDef){
	var addSmilie, messageDef, revisedMessage;
	var currentMessage = document.shoutform1.ShoutComment.value;
	if(currentMessage==messageDef){currentMessage='';}
	revisedMessage = currentMessage+addSmilie;
	document.shoutform1.ShoutComment.value=revisedMessage;
	document.shoutform1.ShoutComment.focus();
	return;
}
//////////////
var delayb4scroll
var marqueespeed=1 ;
var pauseit=1 
copyspeed=marqueespeed;
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''
var item
function scrollmarquee(item){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
{
cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed + item +"px"
}else{
cross_marquee.style.top=parseInt(marqueeheight)-8+"px";
shoutbox('refresh','refresh');
}
}

function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
marqueeheight=document.getElementById("marqueecontainer").offsetHeight
cross_marquee.style.top=marqueeheight;
actualheight=cross_marquee.offsetHeight;
setTimeout('lefttime=setInterval("scrollmarquee(0)",60)', delayb4scroll)

}
if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
window.onload=initializemarquee