﻿document.write('<link href="'+AdnetKeywordPath+'/img/stylesheet.css"  rel="stylesheet" type="text/css" />');
var AdLoadingPic= AdnetKeywordPath+"/img/loading.gif";
var HiddenTimer;

var hideID = 0;	

var AdBoxLeft = 0;
var AdBoxTop = 0;

var ContainerHeight = parseInt(AdBoxHeight.replace('px',''));

var maxAdCount = _maxAdCount;
var markedAdCount=0;

var ContainerId = '';
var ContainerIdTrans = 'AdShowBoxTrans';
var ContainerIdTransHeight="125px";
var ContainerIdTransWidth="175px";

var fo ;

var highlighted_keywordids=new Array();
var highlighted_adids=new Array();

var viewed_adids=new Array();

var str_highlighted_idpairs='';

var inconvenientKeywords=new Array('noadpop','gözaltına al','domuz gri[pb]i','olay günü','[^bBgGdD](ö|Ö)l[dm]?ü[\wğĞüÜşŞöÖçÇıİ]*[\s\W]*','silah','tabanca','kanlar içinde','meydana gelen patlama','ate(s|ş) ((aç)|(et))','satani(st|z(i)?m)','mezar','uyu(s|ş)turucu','eroin','kokain','(uyu(s|ş)turucu|koka(ı|i)n|ero(i|ı)n|silah|kad(i|ı)n) ticaret','cenaze','cese[dt]','tecavüz','ter(o|ö)r','pkk','deprem','yangın','soruşturma','jandarma','polis','mahkeme','zanlı','katil','cinnet','cinayet','(trafik|motor|moto[r]?(s(ı|i)klet)|kamyon(et)?|otob(u|ü)s|minib(u|ü)s|otomob(ı|i)l) kazas(i|ı)','kazada yaralan','cenaze','toprağa ver[eiı]','\W(ö|Ö)l[dm]?ü[\wğĞüÜşŞöÖçÇıİ]*[\s\W]*','hayat(lar)?(i|ı)n(i|ı) kaybe[td]{1,2}[iıe]','vefa[td]','ya(s|ş)ama veda etti','cinayet','traf(i|ı)k canavar(i|ı)','deh(s|ş)et sa[cç]','tecav(u|ü)z','sap(i|ı)[kğ]','(s|ş)ehit','tutuk(lu|suz)','mehmet(ç|c)ik','c(i|ı)nsel fant[ea]z(i|ı)','doland(i|ı)r(i|ı)c(i|ı)','ya(ş|s)am(lar)?(ı|i)n(ı|i) yitir','su(c|ç)lu bul','mahk[uû]m e((tti)|(di))','hapis cezas(ı|i)','(haf(i|ı)f|a[gğ](i|ı)r) yaral','yaralan(d(ı|i)|an)','travesti','orospu','fahişe','eşcinsel','genelev','int(i|a)har','boğul','felaket','can ver');

function getWindowSize()
{
    var w = 0;
    var h = 0;

    //IE
    if(!window.innerWidth)
    {
    //strict mode
    if(!(document.documentElement.clientWidth == 0))
    {
    w = document.documentElement.clientWidth;
    h = document.documentElement.clientHeight;
    }
    //quirks mode
    else
    {
    w = document.body.clientWidth;
    h = document.body.clientHeight;
    }
    }
    //w3c
    else
    {
    w = window.innerWidth;
    h = window.innerHeight;
    }
    return {width:w,height:h};
}


function getMousePos(ev)
{
     var scrOfX = 0, scrOfY = 0;
  
     if(ev.pageX || ev.pageY)//firefox Location
     {
        return {x:ev.layerX, y:ev.pageY};
     }
     
    if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    }else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }        
     
     return {//ie Location
          x:ev.x + scrOfX,
          y:ev.clientY + scrOfY  
     };
}

function getElements() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1)
      return element;
    elements.push(element);
  }
  return elements;
}

function matchAds(e)
{
    var divAdnetId=''
    var arrAdContainerIds = AdContainerIds.split(',');
    
    
    ContainerId = 'AdShowBox';
    var AdShowBox=document.createElement("div");//Ads show form 
    AdShowBox.id = ContainerId;
    AdShowBox.setAttribute("id",ContainerId);
    AdShowBox.setAttribute("width",AdBoxWidth); 
    AdShowBox.style.position="absolute";   
    AdShowBox.style.zIndex = "2147483640";

    document.body.appendChild(AdShowBox); 
    
    var contentArray = new Array();  
    var objArray = new Array();
    
    for (var i=0 ;i<arrAdContainerIds.length;i++)
    {    
        divAdnetId=arrAdContainerIds[i];

        if(divAdnetId=='')
        {
            continue;
        }        
        
        if(Ads.length==0)
        {
            return;
        }
        
        var obj=getElements(e);
        
        
        var tmp = '';    
        
        try{
            obj = document.getElementById(divAdnetId);
            objArray[i] = obj;
            if(document.all)
            {
                tmp = obj.innerHTML;
            }
            else
            {
                if(!obj) obj = obj.childNodes[0];
                if(obj.innerHTML=="")obj = obj.childNodes[1];
                tmp=obj.innerHTML;        
            }            
        }
        catch(e)
        {
            return;
        }
        
        if(!checkInconvenientWords(tmp))
        {
            tmp = markText(tmp);
        }       
        tmp = tmp.replace('<PARAM NAME="Play" VALUE="0">','<PARAM NAME="Play" VALUE="1">');
        contentArray[i] = tmp;
    }        
    
    for (var i=0 ;i<objArray.length;i++)
    {
        objArray[i].innerHTML = contentArray[i];   
        if(i==objArray.length-1)
        {
            objArray[i].innerHTML += countHighlightedKeywords();
        } 
    } 
}

function checkInconvenientWords(_inputHtml) 
{
    var inconvenientWordFound = false;
    var arrAdContainerIds = AdContainerIds.split(',');

    var inputHtml=iso8859Escape(_inputHtml);
    
    for (var i=0 ;i<arrAdContainerIds.length;i++)
    {    
        divAdnetId=arrAdContainerIds[i];

        if(divAdnetId=='')
        {
            continue;
        }               
        
        for(var j=0 ;j<inconvenientKeywords.length;j++)
        {
            var pattern_InconvenientWords = new RegExp(iso8859Escape(inconvenientKeywords[j]),'gi');
            if(inputHtml.search(pattern_InconvenientWords)!=-1)
            {
                inconvenientWordFound = true;
                break;
            }        
        }
        if(inconvenientWordFound)
        {
            break;
        }
    }
    
    return inconvenientWordFound;
}


function markText(inputHtml) 
{
    var re;
    var varMatches;
    var outHtml;
    var replaceText;
    var gelen;
    var aramayap=0;
    var reptextarray = new Array();
    var keykontrol = new Array();       
    
    for (var k=0 ; k < Ads.length; k++)
    {
        reptextarray[k]="<a oncontextmenu=\"return false;\" onmouseover=\"showAd('"+ Ads[k].adid + "','" + Ads[k].id + "' ,event);clearAdInterval();\" onmouseout=\"hideAd();\" name=\"aspx1\" target=\"_blank\"><font class=\"ADPopLink\"><b>" + Ads[k].word + "</b></font></a>";    
      
        keykontrol[k]=0;
    }
    	   
    re=new RegExp("(\<[^>][^<]*\>)([^<]*)","g");
    outHtml=new String('');
    outHtmlTextPart=new String('');

    //var markedAdCount=0;
    var str ='';
    var tagstr='';
          
    var strSearch = '';  
    var strOut1 = '';
    var strOut2 = '';
    
    var adText = '';
    
    var escape_tags=new Array('<A','<B>','<U','<H1','<H2','<H3','<H4','<H5','<H6','<EM','<STRONG','<TT','<IFRAME','<LAYER','<CODE','<OBJECT','<SELECT','<OPTION','<INPUT','<TEXTAREA','<SCRIPT','<NOSCRIPT','<SMALL');
    var escape_tag_found = false; 
    
   inputHtml = '<font></font>' + inputHtml ; 
   
   var reAnchorStart = new RegExp("<a","gi");
   var reAnchorEnd  = new RegExp("</a>","gi"); 
   var anchor_tag_found = false;   
    
   while ((varMatches = re.exec(inputHtml)) != null)
   {   
        outHtml+=varMatches[1]; 	/*html tag part*/
        str= varMatches[2];
        tagstr=varMatches[1]; 
        
         if(varMatches[1].search(reAnchorStart)!=-1)
         {
            anchor_tag_found=true;            
         }          
                
         if(anchor_tag_found)
         {
            if(varMatches[1].search(reAnchorEnd)!=-1)
            {
                anchor_tag_found=false;
            }    
         }        
          
         escape_tag_found = false; 
         
         for(i=0;i<escape_tags.length;i++)
         { 
            var pattern_escape_tags = new RegExp(escape_tags[i],'i');
            if(tagstr.search(pattern_escape_tags)!=-1)
            {
                escape_tag_found = true;
                break;
            }
         }         
          
        strSearch = iso8859Escape(str);  
        outHtmlTextPart =  str;
       
        
            for (k=0; k < Ads.length; k++) 
            {
                var chg=reptextarray[k];
                
                //adText = iso8859Escape(Ads[k].word);
                
                adText = Ads[k].word;
                
                var pattern = new RegExp('\\b'+ adText +'\\b','gi');            
                var testPattern=pattern.exec(strSearch);
 
                var pattern2 = new RegExp(adText +'\\W','gi');            
                var testPattern2=pattern2.exec(strSearch);
               
                
                if(testPattern!=null && testPattern2!=null)
                {
                    if(escape_tag_found || anchor_tag_found)
                    {
                        break;
                    }           
                
	                if (!detectItem(highlighted_keywordids,Ads[k].id) && !detectItem(highlighted_adids,Ads[k].adid) && markedAdCount<maxAdCount)
	                {
		                highlighted_keywordids.push(Ads[k].id);
		                highlighted_adids.push(Ads[k].adid);
		                
		                if(str_highlighted_idpairs=='')
		                {
		                    str_highlighted_idpairs = '(' + PartnerId + ',' + Ads[k].adid + ',' + Ads[k].id + ')' ;
		                }
		                else
		                {
		                    str_highlighted_idpairs = str_highlighted_idpairs + ',(' + PartnerId + ',' + Ads[k].adid + ',' + Ads[k].id + ')' ;
		                }
		                
		                var matchedText = testPattern[0];
		                matchedText = matchedText.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
		                
		                strOut1 = strSearch.substr(0,testPattern.index);
		                strOut2 = strSearch.substr(testPattern.index);             
	                
		                matchedText = iso8859EscapeFix(matchedText);
		                
		                strOut1 = iso8859EscapeFix(strOut1);
		                strOut2 = iso8859EscapeFix(strOut2);
   		                
   		                outHtmlTextPart=decodeURI(strOut1) + decodeURI(strOut2.replace(matchedText , chg.replace(Ads[k].word+'</b>',matchedText+'</b>')));
   		                
		                markedAdCount++;
		                break;
	                }
		        }
            }
        outHtml+=outHtmlTextPart;  
   }  

   return outHtml;
}

function countHighlightedKeywords()
{
    var img = '';
    if(str_highlighted_idpairs.length>0)
    {
        img = '<img src="' + AdnetKeywordPath + '/counthighlight.ashx?t='+ new Date().getTime() +  '&ids=' + str_highlighted_idpairs + '" border=0 width=0 height=0 style="position:absolute;"></img>';
    }
    return img;
}

function iso8859Escape(strText)
{   
    strText=strText.replace(/i/g,"c4b0");
    strText=strText.replace(/İ/g,"C4B0");    
    strText=strText.replace(/ı/g,"c4b1");
    strText=strText.replace(/I/g,"C4B1");
    strText=strText.replace(/ü/g,"c3bc");
    strText=strText.replace(/Ü/g,"C3BC");
    strText=strText.replace(/ğ/g,"c49f");
    strText=strText.replace(/Ğ/g,"C49F");
    strText=strText.replace(/ş/g,"c59f");
    strText=strText.replace(/Ş/g,"C59F");
    strText=strText.replace(/ç/g,"c3a7");
    strText=strText.replace(/Ç/g,"C3A7");
    strText=strText.replace(/ö/g,"c3b6");
    strText=strText.replace(/Ö/g,"C3B6");

    return strText;
}

function iso8859EscapeFix(strText)
{ 
    strText=strText.replace(/c4b0/g,"i");       //i
    strText=strText.replace(/C4B0/g,"%C4%B0");  //İ
    strText=strText.replace(/c4b1/g,"%C4%B1");  //ı
    strText=strText.replace(/C4B1/g,"I");       //İ
    strText=strText.replace(/c3bc/g,"%C3%BC");  //ü
    strText=strText.replace(/C3BC/g,"%C3%9C");  //Ü
    strText=strText.replace(/c49f/g,"%C4%9F");  //ğ
    strText=strText.replace(/C49F/g,"%C4%9E");  //Ğ
    strText=strText.replace(/c59f/g,"%C5%9F");  //ş
    strText=strText.replace(/C59F/g,"%C5%9E");  //Ş
    strText=strText.replace(/c3a7/g,"%C3%A7");  //ç
    strText=strText.replace(/C3A7/g,"%C3%87");  //Ç
    strText=strText.replace(/c3b6/g,"%C3%B6");  //ö
    strText=strText.replace(/C3B6/g,"%C3%96");  //Ö
    return strText;
}

function replaceTurkishChars(strText)
{ 
    strText=strText.replace(/İ/g,"&#304;");    
    strText=strText.replace(/ı/g,"&#305;");
    strText=strText.replace(/ü/g,"&#252;");
    strText=strText.replace(/Ü/g,"&#220;");
    strText=strText.replace(/ğ/g,"&#287;");
    strText=strText.replace(/Ğ/g,"&#286;");
    strText=strText.replace(/ş/g,"&#351;");
    strText=strText.replace(/Ş/g,"&#350;");
    strText=strText.replace(/ç/g,"&#231;");
    strText=strText.replace(/Ç/g,"&#199;");
    strText=strText.replace(/ö/g,"&#246");
    strText=strText.replace(/Ö/g,"&#214;");
    return strText;
}
function detectItem(originalArray, itemToDetect)
{
    var j=0;
 	while (j < originalArray.length)
 	 {
 	 		if (originalArray[j] == itemToDetect)
 	 		 {
 	 		    return true;
 	 		 } 
 	 		 j++;
 	}
 	return false;
}

function showAd(AdId,KeywordId,e)
{
    try{clearTimeout(HiddenTimer);}//Closed from time to time the disappearance of the incident
     catch(e){}    
    
    AdBoxLeft=getMousePos(e).x;
    AdBoxTop=getMousePos(e).y;    
       
    getElements(ContainerId).style.display="block";    

    var adJson = '';
    
    for(i=0 ; i<AdContents.length ; i++)
    {
        if(AdContents[i].adid == AdId)
        {
            adJson = AdContents[i];
            break;
        }
    }    
    
    displayAd(KeywordId,adJson);
}

function moveAdBox()
{     
    ContainerHeight = getElements('tblAdContent').offsetHeight;
    
    
    var vscroll = (document.all ? document.documentElement.scrollTop : window.pageYOffset); 
    
    if(document.all && document.documentElement.scrollTop==0)
    {
        vscroll = document.body.scrollTop;
    }
       
    var browserHeight = 0 ;
    var browserWidth
    browserHeight = getWindowSize().height; 
    browserWidth = getWindowSize().width;  
    
    if(parseInt(browserWidth)-AdBoxLeft<parseInt(getElements(ContainerId).offsetWidth))
        {
        AdBoxLeft=(AdBoxLeft-parseInt(getElements(ContainerId).offsetWidth))+"px";
        }
    else
        {
        AdBoxLeft=AdBoxLeft+"px";
        }
    getElements(ContainerId).style.left=AdBoxLeft;//Set abscissa
   
    if(browserHeight+vscroll-AdBoxTop>ContainerHeight+75)
    {
        AdBoxTop=(AdBoxTop)+"px"; //Aşağı doğru açıl
    }
    else
    {
        AdBoxTop=(AdBoxTop-ContainerHeight-75)+"px"; //Yukarı doğru açıl               
    } 
    
    getElements(ContainerId).style.top=AdBoxTop; 
}

function displayStatus(string){
	window.status = string;
	return true;
}

function hiddenAdShowBox()
{
     try{
        clearTimeout(HiddenTimer);
        getElements(ContainerId).style.display="none";
     } catch(e){}
}
function getResult(req,data)
{
  if(req)
  {
     var adJson = req.responseText;
     
     displayAd(adJson);
  }
  else
  {
	 getElements(ContainerId).innerHTML="System Error!";
  }
}

function displayAd(keywordId,_adJson){ 
    var adnetKeyword = keywordId ;  
    var adJson = _adJson ;
	var adTypeId = adJson.adtypeid; // Metin = 1, Logo=2, Gorsel = 3 , Video=4
	var targetUrl = encodeURI(AdnetKeywordPath+ '/Redirect.ashx?pid=' + PartnerId + '&aid='+ adJson.adid + '&kid=' + adnetKeyword + '&url=' + adJson.urlprefix + escape(adJson.targeturl) ) ;

	var displayString = '';
	
	var containerId = ContainerId;
	
	//if(containerId=='AdShowBox')
	//{
	//    displayString +='<table  name="aspx1" onmouseover="clearAdInterval();" onmouseout=\"hideAd_('+adTypeId+');\"  cellpadding="0" cellspacing="0"  border="0"><tr><td><table border="0" cellspacing="0" cellpadding="0"><tr><td><img src="'+AdnetKeywordPath+'/img/adnettextlink_03.png" width="32" height="46" alt=""></td><td><a href="http://www.adnet.com.tr" target="_blank"><img src="'+AdnetKeywordPath+'/img/adnettextlink_04.png" alt="" width="65" height="46" border="0"></a></td><td><img src="'+AdnetKeywordPath+'/img/adnettextlink_05.png" width="189" height="46" alt=""></td><td><img src="'+AdnetKeywordPath+'/img/adnettextlink_06.png" width="41" height="46" alt="" onClick="closeAdWindow();"></td></tr></table></td></tr><tr><td style="padding-left:13px;" background="'+AdnetKeywordPath+'/img/adnettextlink_08.png"/>'
	//}
	//else
	//{
	//    displayString +='<table name="aspx1" id="AdContent" cellpadding="0" cellspacing="0"  border="0"><tr><td><table border="0" cellspacing="0" cellpadding="0"><tr><td><img src="'+AdnetKeywordPath+'/img/adnettextlink_03.png" width="32" height="46" alt=""></td><td><a href="http://www.adnet.com.tr" target="_blank"><img src="'+AdnetKeywordPath+'/img/adnettextlink_04.png" alt="" width="65" height="46" border="0"></a></td><td><img src="'+AdnetKeywordPath+'/img/adnettextlink_05.png" width="189" height="46" alt=""></td><td><img src="'+AdnetKeywordPath+'/img/adnettextlink_06.png" width="41" height="46" alt=""></td></tr></table></td></tr><tr><td style="padding-left:13px;" background="'+AdnetKeywordPath+'/img/adnettextlink_08.png">'
	//}
	
	var videopath = AdVideopath + "/" + adJson.videopath ;
	var imagepath = AdImagePath + "/" + adJson.imagepath ;
    var flashpath = AdFlashPath + "/" + adJson.videopath ;


    displayString +='<table  name="aspx1" onmouseover="clearAdInterval();" onmouseout=\"hideAd_('+adTypeId+');\"  cellpadding="0" cellspacing="0"  border="0" style="z-index:2147483646;"><tr><td><table border="0" cellspacing="0" cellpadding="0"><tr><td><img src="'+AdnetKeywordPath+'/img/adnettextlink_03.png" width="32" height="46" alt=""></td><td><a href="http://www.adnet.com.tr" target="_blank" style="font-size:1px;"><img src="'+AdnetKeywordPath+'/img/adnettextlink_04.png" alt="" width="65" height="46" border="0"></a></td><td><img src="'+AdnetKeywordPath+'/img/adnettextlink_05.png" width="189" height="46" alt=""></td><td><img src="'+AdnetKeywordPath+'/img/adnettextlink_06.png" width="41" height="46" alt="" onClick="closeAdWindow();"></td></tr></table></td></tr><tr><td style="padding-left:13px;vertical-align:top" background="'+AdnetKeywordPath+'/img/adnettextlink_08.png"/>'

 
	switch(adTypeId){	
	    case 3:
				displayString += 				'<table id="tblAdContent" height=\"' +AdBoxHeightInner + '\" cellpadding="0" cellspacing="0" border="0" style="z-index:2147483646;position:relative;width:' + AdBoxWidth +';">'
				displayString += 					'<tr>'
				displayString += 						'<td width="121" class="" style="padding-left:4px;padding-right:1px;padding-top:1px;padding-bottom:1px;vertical-align:top;text-align:left;">'
				displayString += 							'<a target="_blank" href="'+ targetUrl +'" style="font-size:11px;display:block;font-family:' + tooltipFont + ';color:' + tooltipTitleColorOff + ';text-decoration:' + tooltipTitleDecorationOff + ';font-weight:bold;">' 			
				displayString += 							'<img border="0" width="120" height="105" align="left" src="'+imagepath+'" style="color:#000000;display:block;padding-top:3px;padding-bottom:3px;padding-right:5px;padding-left:5px;"></a>'
				displayString += 						'</td>'				
				displayString += 						'<td class="" style="padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;vertical-align:top;text-align:left;">'
				displayString += 							'<a target="_blank" href="'+ targetUrl +'" style="font-size:11px;display:block;font-family:' + tooltipFont + ';color:' + tooltipTitleColorOff + ';text-decoration:' + tooltipTitleDecorationOff + ';font-weight:bold;">'  + replaceTurkishChars(adJson.header)			
				displayString +=                                '<span style="color:#000000;display:block;font-size:11px;display:block;font-weight:normal;font-family:' + tooltipFont + ';">' + replaceTurkishChars(adJson.content1) + '</span>' + '<span style="color:#000000;display:block;font-size:11px;display:block;font-weight:normal;font-family:' + tooltipFont + ';">' + replaceTurkishChars(adJson.content2) + '</span></a>'
				displayString += 						'</td>'				
				displayString += 					'</tr>'
				displayString += 				'</table>'
		break
		case 4:	        
				displayString += 				'<table id="tblAdContent" cellpadding="0" cellspacing="0" border="0" style="position:relative;z-index:2147483646;width:' + AdBoxWidth +';">'
				displayString += 					'<tr>'
				displayString += 						'<td style="cursor:pointer;cursor:hand;padding-left:1px;padding-right:1px;padding-bottom:1px;vertical-align:text-top;text-align:left;width:' + VideoWidth +';height:' + VideoHeight +';">'
	            displayString +=                            '<div id="creativeContent' + containerId + '" style="position:absolute;z-index:2147483646;">'
		        displayString += 	                            '<div style="background-color:#FFFF00;font-family:' + tooltipFont + ';font-size:10px;">[Flash was not detected]</div>'
		        displayString +=                            '</div>'
	            displayString +=                            '<a target="_blank" href="'+ targetUrl +'">'
	            displayString +=                                '<img border="0" src="'+AdnetKeywordPath+'/img/trans.gif" id="' + ContainerIdTrans + '" style="cursor:hand;position:absolute;z-index:2147483647;width:' + ContainerIdTransWidth +';height:' + ContainerIdTransHeight +';"></img>'
	            displayString +=                            '</a>'
				
	            displayString +=                            '<img id="imgLoading" border="0" src="'+AdnetKeywordPath+'/img/loading.gif" style="position:absolute;padding-top:60px;padding-left:60px;width:30px;z-index:2147483630"></img>'
				
				displayString += 						'</td>'			
				displayString += 						'<td class="" style="padding-left:1px;padding-right:1px;padding-bottom:1px;vertical-align:top;text-align:left;">'
				displayString += 							'<a target="_blank" href="'+ targetUrl +'" style="font-size:11px;display:block;font-family:' + tooltipFont + ';color:' + tooltipTitleColorOff + ';text-decoration:' + tooltipTitleDecorationOff + ';font-weight:bold;">' + replaceTurkishChars(adJson.header) 
				displayString += 							'<span style="color:#000000;display:block;font-size:11px;display:block;font-weight:normal;font-family:' + tooltipFont + ';">' + replaceTurkishChars(adJson.content1) + '</span>' + '<span style="color:#000000;display:block;font-size:11px;display:block;font-weight:normal;font-family:' + tooltipFont + ';">' + replaceTurkishChars(adJson.content2) + '</span></a>'
				displayString += 						'</td>'				
				displayString += 					'</tr>'
				displayString += 				'</table>'
		break
		case 5:	        
				displayString += 				'<table id="tblAdContent" cellpadding="0" cellspacing="0" align="left" border="0" style="position:relative;z-index:2147483646;width:' + FlashWidth +';height:' + FlashHeight +';">'
				displayString += 					'<tr>'
				displayString += 						'<td style="cursor:pointer;cursor:hand;padding-left:1px;vertical-align:text-top;text-align:left;width:' + FlashWidth +';height:' + FlashHeight +';">'
	            displayString +=                            '<div id="creativeContent' + containerId + '" style="position:absolute;z-index:2147483646;">'
		        displayString += 	                            '<span style="background-color:#FFFF00;font-family:' + tooltipFont + ';font-size:10px;">[Flash was not detected]</span>'
		        displayString +=                            '</div>'
	            displayString +=                            '<a target="_blank" href="'+ targetUrl +'">'
	            displayString +=                                '<img border="0" src="'+AdnetKeywordPath+'/img/trans.gif" id="' + ContainerIdTrans + '" style="cursor:hand;position:absolute;z-index:2147483647;width:' + FlashWidth +';height:' + FlashHeight +';"></img>'
	            displayString +=                            '</a>'
				displayString += 						'</td>'			
				displayString += 					'</tr>'
				displayString += 				'</table>'
		break		
		default:
				displayString += 				'<table id="tblAdContent" cellpadding="0" cellspacing="0" border="0" style="position:relative;z-index:2147483646;width:' + AdBoxWidth +';">'
				displayString += 					'<tr>'
				displayString += 						'<td class="" style="padding-left:4px;padding-right:1px;padding-top:1px;padding-bottom:1px;padding-left:5px;vertical-align:top;text-align:left;">'
				displayString += 							'<a target="_blank" href="'+ targetUrl +'" style="font-size:11px;display:block;font-family:' + tooltipFont + ';color:' + tooltipTitleColorOff + ';text-decoration:' + tooltipTitleDecorationOff + ';font-weight:bold;">' + replaceTurkishChars(adJson.header) 
				displayString += 							'<span style="color:#000000;display:block;font-size:11px;display:block;font-weight:normal;font-family:' + tooltipFont + ';">' + replaceTurkishChars(adJson.content1) + '</span>' + '<span style="color:#000000;display:block;font-size:11px;display:block;font-weight:normal;font-family:' + tooltipFont + ';">' + replaceTurkishChars(adJson.content2) + '</span></a>'
				displayString += 						'</td>'
				displayString += 					'</tr>'
				displayString += 				'</table>'
		break;
	}
	
    if(adTypeId==5)
	{
	    adJson.visibleurl="";
	}

    displayString +='</td></tr><tr><td><table width="327" border="0" cellspacing="0" cellpadding="0"><tr><td><img src="'+AdnetKeywordPath+'/img/adnettextlink_09.png" width="32" height="37" alt=""></td><td width="255" align="right" style="text-align:right;vertical-align:top" valign="top" background="'+AdnetKeywordPath+'/img/adnettextlink_11.png">'
    if (!detectItem(viewed_adids,adJson.adid))
    {		                
        viewed_adids.push(adJson.adid);
   	    displayString +=    '<img src="' + AdnetKeywordPath + '/Ad.ashx?t='+ new Date().getTime() + '&pid=' + PartnerId +  '&adid='+adJson.adid + '&kid=' + adnetKeyword + '" border=0 width=0 height=0 style="position:absolute;"></img>'
    }
    
    displayString +='<a target="_blank" href="http://www.adnet.com.tr" style="text-decoration:none;">   <span style="font-size: 11px; font-weight: normal;font-family: Arial, Verdana, Helvetica, sans-serif; color: #EE6603;">AD</span><span style="font-size: 11px; font-weight: normal;font-family: Arial, Verdana, Helvetica, sans-serif; color: #FFFFFF;">net Reklam&#305;</span></a>'
    displayString +='</td><td><img src="'+AdnetKeywordPath+'/img/adnettextlink_12.png" width="41" height="37" alt=""></td></tr></table></td></tr></table>';

   	changeProperty(containerId, 'innerHTML', displayString);
       
	var creative = AdnetKeywordPath+"/js/player_flv_maxi.swf?flv=" + videopath ;	
	creative = creative + "&t=" +   new Date().getTime() ;	
	creative = creative + "&title=ADnet&startimage=" + imagepath ;	
	creative = creative + "&loop=0&autoload=0";
	creative = creative + "&videobgcolor=EEEEEE&bgcolor=EEEEEE&bgcolor1=7c7c77&bgcolor2=333334";
	creative = creative + "&showstop=1&showvolume=1";
	creative = creative + "&playeralpha=50&buffershowbg=0";
    	
	if(adTypeId==4)
	{		
		fo = new FlashObject(creative, "objFlash"+containerId,VideoWidth, VideoHeight, "6", "#EEEEEE");
		if ( !((navigator.userAgent.indexOf('Firefox') > -1) && (navigator.platform.indexOf('Mac') > -1)) ){
		    fo.addParam("wmode", "transparent");
		}
		fo.addParam("scale", "exactfit");
		fo.addParam("swLiveConnect","true");
		fo.addVariable("pageRef",window.location.hostname);
    
   		//fo.addParam("onclick", "none");

    
		fo.write("creativeContent" + containerId);
		//changeStyle('imgLoading', 'visibility', 'hidden');			
	}
	
	if(adTypeId==5)
	{	
		fo = new FlashObject(flashpath, "objFlash"+containerId,FlashWidth, FlashHeight, "6", "#EEEEEE");
		if ( !((navigator.userAgent.indexOf('Firefox') > -1) && (navigator.platform.indexOf('Mac') > -1)) ){
		    fo.addParam("wmode", "transparent");
		}
        fo.addParam("allowScriptAccess", "sameDomain"); 
        fo.addParam("quality", "high"); 
        fo.addParam("loop", "true"); 
		fo.write("creativeContent" + containerId);
	}	

        //if (fo.addEventListener){
        //  fo.addEventListener('click', clickSay, false); 
        //} else if (fo.attachEvent){
        //  fo.attachEvent('onclick', clickSay);
        //}


	changeStyle(containerId, 'visibility', 'visible');	

	moveAdBox();
}


function changeStyle(objectID, propertyName, propertyValue){
	document.getElementById(objectID).style[propertyName] = propertyValue;
}
function changeProperty(objectID, propertyName, propertyValue){
	document.getElementById(objectID)[propertyName] = propertyValue;
}
function getStyleValue(objectID, propertyName){
	return document.getElementById(objectID).style[propertyName];
}
function getPropertyValue(objectID, propertyName){
	return document.getElementById(objectID)[propertyName];
}

function adDelay(){
	ttIsVis = false;
	//close box
	changeStyle(ContainerId, 'visibility', 'hidden');
	//clear ID
	clearInterval(hideID);
	//clear status message
	displayStatus(' ');
	//clear ad content to turn off possible flash audio
	changeProperty(ContainerId, 'innerHTML', "");	
}

function clearAdInterval(){
	clearInterval(hideID);	
	turnSoundOn();	
	playFlash();
}

function hideAd(){	
	clearInterval(hideID);
	hideID = setInterval(adDelay, 1500);
	//TURN OFF AUDIO
	turnSoundOff();
	pauseFlash();
}
function hideAd_(adTypeId){	
    if(adTypeId!=4)
    {
	    clearInterval(hideID);
	    hideID = setInterval(adDelay, 1500);
	    //TURN OFF AUDIO
	    turnSoundOff();
	    pauseFlash();
	}
}

function closeAdWindow(){	
	clearInterval(hideID);
	hideID = setInterval(adDelay, 0);
	//TURN OFF AUDIO
	//turnSoundOff();
	//pauseFlash();
}
function turnSoundOff(){
	try {
		//window.document.objFlash.SetVariable("jsAudioAdjust", "AUDIO_OFF");
	} catch(err) {
	}
}
function turnSoundOn(){
	try {
		//window.document.objFlash.SetVariable("jsAudioAdjust", "AUDIO_ON");
	} catch(err) {
	}
}
function playFlash(){
	try {
		//document.getElementById("objFlash" + ContainerId).SetVariable("player:jsPlay", "");
	} catch(err) {
	}
}
function pauseFlash(){
	try {
    	//document.getElementById("objFlash" + ContainerId).SetVariable("player:jsPause", "");
	} catch(err) {
	}
}


var libJS = {
    addEvent: function(obj,type,fn)
    {
        if (obj.addEventListener)
        {
            obj.addEventListener(type,fn,false);
            return true;
        }
        else if (obj.attachEvent) 
        {
            obj['e'+type+fn] = fn;
            obj[type+fn] = function() { obj['e'+type+fn](window.event);}
            var r = obj.attachEvent('on'+type, obj[type+fn]);
            return r;
        }
        else
        {
            obj['on'+type] = fn;
            return true;
        }
    }
}

libJS.addEvent(window,'load', matchAds);
