/*====================================================================*/
/* Banners Refresh Constants                                          */
/*====================================================================*/
var numOfBanner = 0; 
var bannerRefreshTime = 240000;   /* number of msec(240000);  no refresh = 0 */
var bannerRefreshList = ",x03,x22,x30,x40,x41,x42,x59,x93,x94,Top,Top2,Top3,Left2,Rigth1,Left3,"; 

var bannerRefreshTime2 = 420000;   /* number of msec(420000);  no refresh = 0 */
var bannerRefreshList2 = ",x63,"; 
/*====================================================================*/
//var arMitparStatic = new Array( "level1and2div", "divMenuTopLinks", "divSearchTopLinkDiv",
//                                "divSearchBottom", "divLogo" );
//var arMitparHidden = new Array( "crrossSiteBanDiv", "crrossSiteBanRightDiv", "BannerRightDiv" );

var arMitparStatic = new Array( "nr_main", "nr_gamepic", "nr_textbox", 
                                "nr_title", "nr_text", "nr_pages" );

var arMitparSrcPos = new Array( "", "", "", "", "", "" );   // Same size that in array arMitparStatic

var arMitparHidden = new Array( "crrossSiteBanDiv", "BannerRightDiv", "TopBannerCont", 
                                "nr_main", "newSearchContainer", "divUserMenuContainer",
					  "closeMonsterRight", "closeMonsterLeft" );

var arOzenHidden = new Array(   "headerContainer", "crrossSiteBanRightDiv", "BannerRightDiv", "loginBox", "popDiv" );    

/*
var arOzenHidden = new Array(   "crrossSiteBanRightDiv", "BannerRightDiv", 
                                "newSearchContainer", 
					  //"divMenuTopLinks", "divLogo", "divSearchMain",
					  //"divAruz", 
					  //"divUSBar", 
					  //"divTopMenu", 
					  "loginBox",
					  "TopBannerDiv",
                                "TopBannerCont", "nr_main", "divUserMenuContainer" );    
*/

var monsterSynchron = false
//============================================================================
function changeStyle_ShowMitpar(pp)
{
    var ob;
    if (pp != 1)    
     for(var i=0; i < arMitparStatic.length; i++ )
     {
      ob = document.getElementById(arMitparStatic[i]);
      if (ob) 
	{
	  arMitparSrcPos[i] = ob.style.position;
	  ob.style.position = "static";
	 } 
     }

    var ar = arMitparHidden;
    if (pp == 1) ar = arOzenHidden;
    
    for(var i=0; i < ar.length; i++ )
    {
      ob = document.getElementById(ar[i]);
      if (ob) ob.style.visibility = "hidden";
    }
}
//============================================================================
function changeStyle_HideMitpar(pp)
{
    var ob;
    if (pp != 1)    
     for(var i=0; i < arMitparStatic.length; i++ )
     {
      ob = document.getElementById(arMitparStatic[i]);
      if (ob) ob.style.position = arMitparSrcPos[i];
     }

    var ar = arMitparHidden;
    if (pp == 1) ar = arOzenHidden;
    
    for(var i=0; i < ar.length; i++ )
    {
      ob = document.getElementById(ar[i]);
      if (ob) ob.style.visibility = "visible";
    }
}
//============================================================================
function KingExt_Show()
{
    changeStyle_ShowMitpar(0);
}
//============================================================================
function KingExt_Hide()
{
    changeStyle_HideMitpar(0);
    closeMonster();
}
//============================================================================
function Monster_Show()
{
    changeStyle_ShowMitpar(0);
}
//============================================================================
function Monster_Hide()
{
    changeStyle_HideMitpar(0);
    closeMonster();
}
//============================================================================
function OzenMonster_Show()
{
    changeStyle_ShowMitpar(1);
    
 if (document.getElementById("LOzenMPDiv2"))
     document.getElementById("LOzenMPDiv2").style.display = ""; 
     
  // if (document.getElementById("LOzenMPDiv1"))       
  //     document.getElementById("LOzenMPDiv1").style.display = "";
      
  // if (document.getElementById("LOzenMPDiv3"))        
  //     document.getElementById("LOzenMPDiv3").style.display = "none";  
}
//============================================================================
function OzenMonster_Hide()
{
 if (document.getElementById("LOzenMPDiv3"))        
     document.getElementById("LOzenMPDiv3").style.display = "";  

 if (document.getElementById("LOzenMPDiv1"))   
     document.getElementById("LOzenMPDiv1").style.display = "none";
     
 if (document.getElementById("LOzenMPDiv2"))        
     document.getElementById("LOzenMPDiv2").style.display = "none"; 
     
    changeStyle_HideMitpar(1);
}
//============================================================================
function MonsterSynchron_Show()
{
    monsterSynchron = true;
    
    if (document.getElementById("crrossSiteBanRightDiv"))
        document.getElementById("crrossSiteBanRightDiv").style.visibility = "hidden";
}
//============================================================================
function DisplayAds (sitepage, position, width, height, isDotomi) {
	DisplayAdsMain (sitepage, position, width, height, isDotomi);
}

function BrowserCheck() 
{
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b.toLowerCase().indexOf("explorer")!=-1) this.b = "ie"
  	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ns6 = (this.b=="ns" && this.v==6)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.ie6 = (this.version.indexOf('MSIE 6')>0)
	this.min = (this.ns||this.ie)
}

tapuz_browser_is = new BrowserCheck();

var oas = "http://rm.tapuz.co.il/RealMedia/ads/";
if (document.location.protocol == "https:")
	oas = "https://rm.tapuz.co.il/RealMedia/ads/";
var RN = new String (Math.random());
var RNS = RN.substring(2,11);
var AsyncElementsIds = new String("");
var MaxAsyncElementsIds = 1;

/*
function DisplayAdsMain (sitepage, position, width, height, isDotomi) {
	
	var oaspage
	var sitepageStr = new String(sitepage)
	var positionStr = new String(position)
	oaspage = sitepage + '/1' + RNS + '@' + position;
	
	document.write ('\<IFRAME WIDTH=' + width + ' HEIGHT=' + height + ' NORESIZE ID=mainBanner SCROLLING=No FRAMEBORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0 SRC="' + oas + 'adstream_sx.ads/' + oaspage + '"\>');
	if (tapuz_browser_is.ns ) 
	{
		document.write ('\<SCRIPT LANGUAGE="JavaScript1.1" SRC="' + oas + 'adstream_jx.ads/' + '@Top2,Left2!' + oaspage + '">');
		document.write ('\<\!-- --\>');
		document.write ('\<\/SCRIPT\>');
	}
	document.write ('\<\/IFRAME\>');
	
	showBannerDeatils(sitepage, position)
}
*/

function DisplayAdsMain( sitepage, position, width, height, isDotomi ) {

	numOfBanner ++;
	var spanId = position + '_' + numOfBanner;

	document.write ('\<SPAN ID="' + spanId + '"\>\</SPAN\>');
	
	var refrtime = 0;
	if ( bannerRefreshList.indexOf("," + position + ",") >= 0 )
	     refrtime = bannerRefreshTime;
	else if ( bannerRefreshList2.indexOf("," + position + ",") >= 0 )
	     refrtime = bannerRefreshTime2;
	     
	RefreshAdsMain(sitepage, position, width, height, isDotomi, spanId, refrtime);
	
	showBannerDeatils(sitepage, position);
}

function RefreshAdsMain( sitepage, position, width, height, isDotomi, spanId, refrtime ) {

	if (document.getElementById(spanId))
	{
	 	var oaspage;
	 	var sitepageStr = new String(sitepage);
	 	var positionStr = new String(position);
	 	//oaspage = sitepage + '/1' + RNS + '@' + position;
	 	oaspage = sitepage + '/1' + RNS + '@' + position + "?" + sitepage.replace("/","&");
		oaspage  = oaspage.replace("%20","");
	 
	 var rr = '\<IFRAME WIDTH=' + width + ' HEIGHT=' + height + ' NORESIZE ID=mainBanner SCROLLING=No FRAMEBORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0 SRC="' + oas + 'adstream_sx.ads/' + oaspage + '"\>'; 
	 if (tapuz_browser_is.ns ) 
	 {
	   rr += '\<SCRIPT LANGUAGE="JavaScript1.1" SRC="' + oas + 'adstream_jx.ads/' + '@Top2,Left2!' + oaspage + '">';
	   rr += '\<\!-- --\>';
	   rr += '\<\/SCRIPT\>';
	 }
	 rr += '\<\/IFRAME\>';
	
	 document.getElementById(spanId).innerHTML = "";	
	 document.getElementById(spanId).innerHTML = rr;
	} 
      if (refrtime > 0)
	   setTimeout("RefreshAdsMain('" + sitepage + "','" + position + "'," + width + "," + height + "," + isDotomi + ",'" + spanId + "'," + refrtime + ")",refrtime);

}

function replaceAll(text, strA, strB) 
{
    while ( text.indexOf(strA) != -1)
    {
        text = text.replace(strA,strB);
    }
    return text;
}

function DisplayAdsAsync (sitepage, position, width, height) {
	
      var refrtime = 0;
      if ( bannerRefreshList.indexOf("," + position + ",") >= 0 )
	     refrtime = bannerRefreshTime;

	var oaspage
	var sitepageStr = new String(sitepage)
	var positionStr = new String(position)
	//oaspage = sitepage + '/1' + RNS + '@' + position;
	oaspage = sitepage + '/1' + RNS + '@' + position + "?" + replaceAll(sitepage,"/","&");
	oaspage = replaceAll(oaspage,"%20","");
	
	document.write ('\<DIV WIDTH=' + width + ' HEIGHT=' + height + ' ID="AsyncMainBanner_' + MaxAsyncElementsIds + '" AsyncWidth="' + width + '" AsyncHeight="' + height + '" AsyncSRC="' + oas + 'adstream_sx.ads/' + oaspage + '" AsyncRefreshTime="' + refrtime + '"\>');
	document.write ('\<\/DIV\>');
	
	AsyncElementsIds += "AsyncMainBanner_" + MaxAsyncElementsIds + ",";
	MaxAsyncElementsIds += 1;
	
	showBannerDeatils(sitepage, position)
}

function LoadAllBannersAsync()
{
    if (AsyncElementsIds != "")
    {
        var refrFlag = 0;
        var AsyncElementsIdsArr = AsyncElementsIds.split(",");
        for(var i=0;i < AsyncElementsIdsArr.length; i++)
        {
            if (AsyncElementsIdsArr[i] != "")
            {
                var obj = document.getElementById(AsyncElementsIdsArr[i]);
                if (obj)
                {
			var AsyncWidth    =          obj.attributes["AsyncWidth"].value;
			var AsyncHeight   =          obj.attributes["AsyncHeight"].value;
			var AsyncSRC      =          obj.attributes["AsyncSRC"].value;
			var AsyncRefrTime = parseInt(obj.attributes["AsyncRefreshTime"].value);					
			
			if (obj.innerHTML == "" || AsyncRefrTime > 0)
			    obj.innerHTML = "<IFRAME WIDTH=\"" + AsyncWidth + "\" HEIGHT=\"" + AsyncHeight + "\" NORESIZE SCROLLING=No FRAMEBORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0 SRC=\"" + AsyncSRC + "\"></IFRAME>";

			if (AsyncRefrTime > 0) refrFlag = 1;                 
                }
            }
        }
        if (refrFlag > 0)
           setTimeout("LoadAllBannersAsync()", bannerRefreshTime);
        else
	  {
         AsyncElementsIds = "";
         MaxAsyncElementsIds = 1;
	  } 
    }
}

function DisplayAdsWithValidate(sitepage, position, width, height,objIdStr)
{
    var oaspage = sitepage + '/1' + RNS + '@' + position;
    document.write ('\<SPAN ID=' + objIdStr + ' STYLE="width:' + width + 'px;height:' + height + 'px;">');
    document.write ('\<SCRIPT LANGUAGE="JavaScript1.1" SRC="' + oas + 'adstream_jx.ads/' + oaspage + '">');
	document.write ('\<\!-- --\>');
	document.write ('\<\/SCRIPT\>');
    document.write ('\<\/SPAN\>');
}

function DisplayAdsSpecial (sitepage, position, width, height) {
	DisplayAdsMainSpecial (sitepage, position, width, height);
}

function DisplayAdsMainSpecial (sitepage, position, width, height) {
	var RN = new String (Math.random());
	var RNS = RN.substring(2,11);
	var oaspage = sitepage + '/1' + RNS + '@' + position;
	
	//document.write ('\<div id=aaa style="BORDER-RIGHT: blue 1px solid; BORDER-TOP: blue 0px solid; ; LEFT: 100px;  BORDER-LEFT: blue 1px solid; WIDTH: 50; BORDER-BOTTOM: blue 1px solid; POSITION: absolute; TOP: 20px; HEIGHT: 50;z-index:2">');
	document.write ('\<SCRIPT LANGUAGE="JavaScript1.1" SRC="' + oas + 'adstream_jx.ads/' + oaspage + '">');
	document.write ('\<\!-- --\>');
	document.write ('\<\/SCRIPT\>');
	//document.write ('\<\/div\>');
		
	showBannerDeatils(sitepage, position)
}

function DisplayFloatingAds(sitepage, position)
{
	var RN = new String (Math.random());
	var RNS = RN.substring(2,11);

	var oaspage = sitepage + '/1' + RNS + '@' + position;
	var JSSource = oas + 'adstream_jx.ads/' + oaspage

	if (tapuz_browser_is.ie5 || tapuz_browser_is.ie6) {		
		document.write('<SCRIPT LANGUAGE="JavaScript1.1" SRC="' + JSSource + '">');
		document.write('</SCRIPT>');
		
		showBannerDeatils(sitepage, position)
	}
}

function DisplayAdsMainSXCGI (sitepage, position) {
	var RN = new String (Math.random());
	var RNS = RN.substring(2,11);
	var oaspage = sitepage + '/1' + RNS + '@' + position;
	
	document.write ('\<SCRIPT LANGUAGE="JavaScript1.1" SRC="' + oas + 'adstream_sx.ads/' + oaspage + '" charset="windows-1255">');
	document.write ('\<\!-- --\>');
	document.write ('\<\/SCRIPT\>');

	showBannerDeatils(sitepage, position)
}

function showBannerDeatils(sitepage, position)
{
	//For show Position and Page
	//try
	//{
	//	if (showPosAndPage)
	//	{
	//		document.write('<br>Pos:' + position + '<br>Page:' + sitepage);
	//	}
	//}
	//catch (ex) { }
}
//============================================================================
function DisplayAdsOzenNoFrame( sitepage, position ) {
       var RN = new String (Math.random());
       var RNS = RN.substring(2,11);
	 var oaspage = sitepage + '/1' + RNS + '@' + position + "?" + sitepage.replace("/","&");
	 
	 var rr = '\<SC' + 'RIPT LANGUAGE="JavaScript1.1" SRC="' + oas + 'adstream_sx.ads/' + oaspage + '" charset="windows-1255">' +
	          '\<\!-- --\>' +
	          '\<\/SC' + 'RIPT\>';

       document.write(rr);
}

function showBanner(divId) {
    var obj = document.getElementById(divId);
    if (obj) {
        obj.style.display = "";
    }
}