// JScript File
var flagspan=new Array()
for(i=0;i<=3000;i++){
	flagspan[i]=0;
}

var viewed=new Array()

var msgID=new Array()
var viewedcntr=0
var loaded = false


function waitPic(ID,first)
{
	for (i=0;i<document.images.length;i++)
		if (document.images[i].complete==false)
		{
		    if (document.images[i].src.indexOf("http://rm.tapuz.co.il/RealMedia/") == -1 && document.images[i].src.indexOf("/Creatives/default/empty.gif") == -1)
		    {
			    setTimeout("waitPic(" + ID + ")",500)
			    return;
			}
		}
	
	if (first==true)
	{
	    if (navigator.appVersion.indexOf('MSIE 6')>0)
		{
    		for(t=1;t<=viewedcntr;t++)
	    		document.getElementById('link'+viewed[t]).click();
	    }
		viewedcntr=0
	}

	if (navigator.appVersion.indexOf('MSIE 6')>0)
	{	
    	document.getElementById('link' + ID).click();	
    }
}

function show_msg_attch(ID,attch,msgID)
{
	show_msg(ID)
	if (flagspan[ID]!=0)
	{
		show_attch(attch,msgID)
	}
}

function show_msg(ID)
{
	if (flagspan[ID]==0)
	{
	    var isNew
	    
		if( document.getElementById("subj" + ID).className == "vColor" )
		    isNew = 0;
		else
		    isNew = 1;
		
		document.getElementById("span"+ID).innerHTML=msgID[ID]
		flagspan[ID]=1
		document.getElementById("subj" + ID).className = "vColor"
		
		if (document.getElementById("opened"+ID))
		    document.getElementById("opened"+ID).innerHTML=""

		if (loaded==true)
			if (viewedcntr>0)
				setTimeout("waitPic(" + ID + ",true)",100)
			else
				setTimeout("waitPic(" + ID + ",false)",100)
		else
			viewed[++viewedcntr]=ID
			
        if (!(navigator.appVersion.indexOf('MSIE 6')>0))		
    		setMark(document.getElementById("RealMsgId" + ID).value);
    		
        var theMsgId = document.getElementById("RealMsgId" + ID).value
		
		if( parseInt(cookieUserId) != -1 && isNew == 1 && !(navigator.appVersion.indexOf('MSIE 6')>0))
            makePOSTRequest( "redirectForumClicks.asp", "userId="+cookieUserId+"&msgId="+theMsgId );    		
			
		try 
		{
			document.getElementById("HitCont"+ID).innerHTML = document.getElementById("HitCont"+ID).innerHTML.replace('{HitSubject}',document.getElementById("HitSubject"+ID).value);
			window.setTimeout("startHit();" ,1000); 
		} 
		catch (ex) { }
	}
	else
	{
		document.getElementById("span"+ID).innerHTML=""
		flagspan[ID]=0
	}
	try { glp_glp.scanLinks() } catch (ex) { }
}

function show_attch(attch,msgID)
{
	if (attch.indexOf("flv") == -1)
	{
		var dest="../main/ShowImage.asp?path=" + attch + "&msgid=" + msgID;
		window.open(dest, "Image", "toolbar=no,status=no,scrollbars=yes,height=400,width=400,resizable=1")
	}
	else
	{
		document.getElementById("flix" + msgID).innerHTML = "";
		document.getElementById("flix" + msgID).innerHTML = "<object id='playerObj' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='190' height='157' align='middle'>" +
			"<param name='allowScriptAccess' value='sameDomain' />" +
			"<param id='flashVideoMovie'  name='movie' value='/tapuzforum/images/FLV_Player5.swf?autoStart=true&file="+attch+"&LinkCounter=http://www.tapuz.co.il/flix/ivideo.asp?f="+attch+"' />" +
			"<param name='quality' value='high' />" +
			"<param name='bgcolor' value='#ffffff' />" +
			"<embed id='flashVideoMovieEMBD' src='/tapuzforum/images/FLV_Player5.swf?autoStart=true&file="+attch+"&LinkCounter=http://www.tapuz.co.il/flix/ivideo.asp?f="+attch+"' quality='high' bgcolor='#ffffff' width='190' height='157'  align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
			"</object>";
	}
}

function show_attch_doc(attch)
{
	 var dest="http://www.tapuz.co.il/tapuzforum/tapuzforumsUploads/" + attch;
	 window.open(dest, "Image", "toolbar=no,status=no,scrollbars=yes,height=400,width=400,resizable=1")
}

function SendMsgByMail(msgid,forumId)
{
  dest="http://www.tapuz.co.il/tapuzforum/main/emailAdresses.asp?msgid=" + msgid + "&id="+ forumId;
     window.open(dest,null,"height=250; width=400, status=yes, toolbar=no, menubar=no,location=no, top=200, left=200");
}

function printWin(msgid)
{
	dest="http://www.tapuz.co.il/tapuzforum/main/printWin.asp?msgid=" + msgid;
	window.open(dest,null,"height=500; width=550, status=no, toolbar=yes, menubar=no,toolbar=no,location=no, top=50, left=150,scrollbars=yes");
}

function ShowEditorMsg(id)
{
	  var dest="../main/EditorMsg.asp?id=" + id
	  window.open(dest,"EditorMessage", "toolbar=no,scrollbars=yes,status=no,width=600,height=300") 
}

// we switch the function because Serge add new img server (img2) ...
function sendMMS(iType,fName,ServerID,ForumID)
{
	w = Math.round((screen.width - 430) / 2);
	h = Math.round((screen.height - 330) / 2);

 wnd = window.open("http://www.tapuz.co.il/orange/communa/albums/mms_check.asp" +
                                                                           "?infoType=" + iType + 
                                                                           "&fileName=" + escape(fName) + 
                                                                           "&ServerID=" + ServerID + 
                                                                           "&CommunaID=" + ForumID,
          "sndMMS","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=430,height=330,top=" + h + ",left=" + w );
 wnd.focus();   
} 
