﻿function DisplayBnrOpenX(ZoneID, Width, Height, BannerKeyForSearch) 
{
    var strKey = KeyWordMaker(ZoneID, BannerKeyForSearch);
    document.write('<iframe id="a4ea035f" name="a4ea035f" src="http://openx.alljobs.co.il/www/delivery/afr.php?what=' + strKey + '" frameborder="0" scrolling="no" width="' + Width + '" height="' + Height + '"><a href="http://openx.alljobs.co.il/www/delivery/ck.php?n=a0143b56" target="_blank"><img src="http://openx.alljobs.co.il/www/delivery/avw.php?what=' + strKey + '&amp;n=a0143b56" border="0" alt="" /></a></iframe>');
}

function DisplayBnrOpenXIfrm(ZoneID, Width, Height) 
{
    document.write('<iframe id="a3379ef0" name="a3379ef0" src="http://openx.alljobs.co.il/www/delivery/afr.php?zoneid=' + ZoneID + '&amp;target=_blank" frameborder="0" scrolling="no" width="' + Width + '" height="' + Height + '" allowtransparency="true"><a href="http://openx.alljobs.co.il/www/delivery/ck.php?n=a818326e" target="_blank"><img src="http://openx.alljobs.co.il/www/delivery/avw.php?zoneid=' + ZoneID + '&amp;n=a818326e" border="0" alt="" /></a></iframe>');
}

function DisplayBnrOpenXScript(ZoneID)
{
    document.write('<span id="BannerScript' + ZoneID + '"><sc' + 'ript type="text/javascript" src="http://openx.alljobs.co.il/www/delivery/ajs.php?zoneid=' + ZoneID + '&amp;target=_blank&amp;cb=91273363515&amp;charset=windows-1255&amp;loc=' + location.href + '"></scr' + 'ipt><noscript><a href="http://openx.alljobs.co.il/www/delivery/ck.php?n=ac6b38df&amp;cb=122222" target="_blank"><img src="http://openx.alljobs.co.il/www/delivery/avw.php?zoneid=' + ZoneID + '&amp;cb=123665447&amp;n=ac6b38df" border="0" alt="" /></a></noscript></noscript></span>');
}

function DisplayBnrOpenXScriptWithKeyword(ZoneID, BannerKeyForSearch)
{
    var strKey = KeyWordMaker(ZoneID, BannerKeyForSearch);
    document.write('<script type="text/javascript" src="http://openx.alljobs.co.il/www/delivery/ajs.php?what=' + strKey + '&amp;cb=84394680009&amp;charset=windows-1255&amp;loc=' + location.href + '"></script><noscript><a href="http://openx.alljobs.co.il/www/delivery/ck.php?n=a8ee1b5c&amp;amp;cb=3323135" target="_blank"><img src="http://openx.alljobs.co.il/www/delivery/avw.php?what=' + strKey + '&amp;amp;cb=326659787&amp;amp;n=a8ee1b5c" border="0" alt=""/></a></noscript>');
}


function KeyWordMaker(ZoneID, BannerKeyForSearch) 
{
    
    var Position = '';
    if (typeof(BannerKeyForSearch) == 'undefined')
    {
        Position = RequestQueryStringForOpenx('position');
        
        //In Upload Pages  Take The Categoris From AgentD Variable
        if(Position == 'undefined' || Position == '')
            Position = RequestQueryString('AgentD').split(';')[0];
    }
    else
        Position = BannerKeyForSearch;

    if (Position == '' || typeof(Position) == 'undefined')
        return ZoneID + '_-1';
            
    var arrPosition = Position.split(',');
    var strKey = '';

    for(i=0;i<arrPosition.length;i++)
        if(!isNaN(arrPosition[i]))
            strKey += ZoneID + '_' + arrPosition[i] + ',';
            
    if(strKey != '')
        strKey = strKey.substring(0, strKey.length - 1);
    else
        strKey = ZoneID + '_-1';

    return strKey
}  

function RequestQueryStringForOpenx(sParamName,isParentRequest)
{
    sParamName = sParamName.toLowerCase();
	var sHref="";
	var arrHref;
	var nParamStartPos=0, nParamEndPos=0;
	var sParamValue='';
	 
	sHref = typeof isParentRequest != 'undefined' ? sHref = parent.document.location.href  : sHref = document.location.href;	
		 
	arrHref = sHref.split("?");
	// return empty string if the query string not exsits
	if (arrHref.length <= 1) 
		return(sParamValue);
	sParamName += '=';
	nParamStartPos = arrHref[1].toLowerCase().indexOf(sParamName);
	// return empty string if the requested parameter is not exsits
	if(nParamStartPos == -1)	
		return(sParamValue);
	nParamStartPos += sParamName.toString().length;
	nParamEndPos = arrHref[1].indexOf("&", nParamStartPos);
	if(nParamStartPos == nParamEndPos)
		return '';
		
	if(nParamEndPos > -1 && nParamEndPos > nParamStartPos)
		sParamValue=arrHref[1].slice(nParamStartPos,nParamEndPos);
	else
		sParamValue=arrHref[1].slice(nParamStartPos);

	return(sParamValue);
}
