function popUp(URL, w, h) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + w + ",height=" + h + ",left=200,top=200');");
}

function popUpOut(URL) {
	w = (screen.width *0.75); //screen.width-75;
	h = (screen.height *0.75);//screen.height-250;
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=" + w + ",height=" + h + ",left=0,top=0');");
}

function buttonHoverIn()
{

}

function buttonHoverOut()
{

}
function httpRequest(word, bool) {
 
	// Mozilla-based browsers
	if (window.XMLHttpRequest) {
		request = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		request = new ActiveXObject("Msxml2.XMLHTTP");
		if (!request) {
			request = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
 
	// Request could still be null if neither ActiveXObject
	//   initialization succeeded
	if (request) {
		// If the reqType param is POST, then the fifth arg is the POSTed data
		if (reqType.toLowerCase() != "post") {
			request.open('GET', 'http://www.rubrikk.no/words.aspx?word='+word,bool);
		} 
		
	} else {
		
	}
 
}

function showBanner(id)
        {
        var m3_u = (location.protocol=='https:'?'https://tfs.inmed.no/~adil/openx/www/delivery/ajs.php':'http://tfs.inmed.no/~adil/openx/www/delivery/ajs.php');
        var m3_r = Math.floor(Math.random()*99999999999);
        if (!document.MAX_used) document.MAX_used = ',';
        document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
        document.write ("?zoneid=" + id);
        document.write ('&amp;cb=' + m3_r);
        if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
        document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
        document.write ("&amp;loc=" + escape(window.location));
        if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
        if (document.context) document.write ("&context=" + escape(document.context));
        if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
        document.write ("'><\/scr"+"ipt>");
           
        }
        
        
   
function GetParam(name) { 
    var match = new RegExp(name + "=(.+?)[&]","i").exec(location.search);
 if (match==null)
 { match = new RegExp(name + "=([^\n]+)","i").exec(location.search);
 } if (match==null) { return null; } match = match + ""; 
 match = match.replace(/%e5/gi, "å"); 
 match = match.replace(/%f8/gi, "ø"); 
 match = match.replace(/%e6/gi, "æ"); 
 result = match.split(","); 
 return decodeURIComponent(result[1]); 
 }
 function GetParam2() { 
    var match = new RegExp("=(.+?)[&]","i").exec(location.search);
 if (match==null)
 { match = new RegExp("til_salgs(.+?).aspx").exec(location.href);
 } if (match==null) { return null; } match = match + ""; 
 match = match.replace(/%e5/gi, "å"); 
 match = match.replace(/%f8/gi, "ø"); 
 match = match.replace(/%e6/gi, "æ"); 
 result = match.split(","); 
 return decodeURIComponent(result[1]); 
 }
 function GetParam3() { 
    var match = new RegExp("=(.+?)[&]","i").exec(location.search);
 if (match==null)
 { match = new RegExp("brukt(.+?).aspx","i").exec(location.href);
 } if (match==null) { return null; } match = match + ""; 
 match = match.replace(/%e5/gi, "å"); 
 match = match.replace(/%f8/gi, "ø"); 
 match = match.replace(/%e6/gi, "æ");
 match = match.replace(/_/gi, " "); 
 result = match.split(","); 
 
 return decodeURIComponent(result[1]); 
 }
 function GetKilde(kilde) { 
    var match = new RegExp("(.+?)/","i").exec(kilde);
 if (match==null)
 { match = new RegExp("(.+)","i").exec(kilde);
 } 
 if (match==null) { return null; } match = match + ""; 
 
 result = match.split(",");
 return result[1]; 
 }
  
 if (window.location.href.indexOf("klikk.") <=0){

 if (window.location.href.indexOf("ft") >=0 || window.location.href.indexOf("www.rubrikk.no/til_salgs") >=0 || window.location.href.indexOf("www.rubrikk.no/brukt/") >=0) { 
 function google_afs_request_done(google_ads) { 
 var google_num_ads = google_ads.length;

 if (google_num_ads <= 0) {
 return;      
 } 
 var wideAds = "";
 var narrowAds = "";
 var midAds = "";
 var rep = "";
 var to = 0;
 if(window.location.href.indexOf("www.rubrikk.no/til_salgs") >=0 || window.location.href.indexOf("www.rubrikk.no/brukt/") >=0) to = 2;

 for(i = 0; i < google_num_ads; i++) { 
 rep = google_ads[i].visible_url.replace('www.','');
 if (i < 3){
 wideAds +='<table id="" border="0" cellpadding="0" cellspacing="0" style="height:130px;width:100%;" width="100%">'+
 '<tr onmouseover="this.style.backgroundColor=\'#E6F2FA\';" onmouseout="this.style.backgroundColor=\'#FFFFFF\';">'+
 //'<td id="imagecell" style="width: 200px; height: 100%; padding-right: 20px;" align="left">'+
 //'</td>'+
 '<td>' +
 '<table style="width: 100%; height: 100%; border: 0;" cellpadding="0" cellspacing="0"><tr><td><table id="HeadlineTable" style="width:100%;height:125px;" border="0" cellpadding="0" cellspacing="0">'+
 '<tr><td style="height: 100%; width: 65%;" align="left"><div><span class="ad_line1"><a id="Headline" class="font2 underline colorb" href="'+google_ads[i].url+'">'+google_ads[i].line1+'</a></span></div>' +
 '<div><span class="ad_url">'+google_ads[i].line2+'</span><br><a id="Ingress" class="font4" href="'+google_ads[i].url+'"><span class="ad_url">'+google_ads[i].visible_url+'</span></a></div></td><td style="height:100%; width:25%;" align="right" class="font3 colora"> &nbsp;</td> </td></tr></table></td></tr></table></td></tr></table>';
 if(i != 2) wideAds+= '<div style="height:2px;"></div><div style="height:2px;" class="dottedline"></div>';
 //document.write("<img rel=\"nofollow\" src=\"http://www.rubrikk.no/words.aspx?word="+google_ads[i].line1+"&kat="+window.location.href+"\" />");
 }
 if (i > 2 && i < 4+to){
 midAds +='<table id="" border="0" cellpadding="0" cellspacing="0" style="height:130px;width:100%;" width="100%">'+
 '<tr onmouseover="this.style.backgroundColor=\'#E6F2FA\';" onmouseout="this.style.backgroundColor=\'#FFFFFF\';">'+
 //'<td id="imagecell" style="width: 200px; height: 100%; padding-right: 20px;" align="left">'+
 //'</td>' +
 '<td>' +
 '<table style="width: 100%; height: 100%; border: 0;" cellpadding="0" cellspacing="0"><tr><td><table id="HeadlineTable" style="width:100%;height:125px;" border="0" cellpadding="0" cellspacing="0">'+
 '<tr><td style="height: 100%; width: 65%;" align="left"><div><span class="ad_line1"><a id="Headline" class="font2 underline colorb" href="'+google_ads[i].url+'">'+google_ads[i].line1+'</a></span></div>' +
 '<div><span class="ad_url">'+google_ads[i].line2+'</span><br><a id="Ingress" class="font4" href="'+google_ads[i].url+'"><span class="ad_url">'+google_ads[i].visible_url+'</span></div></td><td style="height:100%; width:25%;" align="right" class="font3 colora"> &nbsp;</td> </td></tr></table></td></tr></table></td></tr></table>';
 if(i != 3+to) midAds+= '<div style="height:2px;"></div><div style="height:2px;" class="dottedline"></div>';
 }
 if (i > 3+to && i < 9+to){
  narrowAds +='<table id="" border="0" cellpadding="0" cellspacing="0" style="height:130px;width:100%;" width="100%">'+
 '<tr onmouseover="this.style.backgroundColor=\'#E6F2FA\';" onmouseout="this.style.backgroundColor=\'#FFFFFF\';">'+
 //'<td id="imagecell" style="width: 200px; height: 100%; padding-right: 20px;" align="left">'+
 //'</td>' +
 '<td>' +
 '<table style="width: 100%; height: 100%; border: 0;" cellpadding="0" cellspacing="0"><tr><td><table id="HeadlineTable" style="width:100%;height:125px;" border="0" cellpadding="0" cellspacing="0">'+
 '<tr><td style="height: 100%; width: 65%;" align="left"><div><span class="ad_line1"><a id="Headline" class="font2 underline colorb" href="'+google_ads[i].url+'">'+google_ads[i].line1+'</a></span></div>' +
 '<div><span class="ad_url">'+google_ads[i].line2+'</span><br><a id="Ingress" class="font4" href="'+google_ads[i].url+'"><span class="ad_url">'+google_ads[i].visible_url+'</span></div></td><td style="height:100%; width:25%;" align="right" class="font3 colora"> &nbsp;</td> </td></tr></table></td></tr></table></td></tr></table>';
  narrowAds+= '<div style="height:2px;"></div><div style="height:2px;" class="dottedline"></div>';

 }

 }
 if (narrowAds != "") {
 document.write("<div id=\"narrow_ad_unit\" class=\"narrow_ads\"></div>");
 narrowAds = '<a style="text-decoration:none" ' + 'href="http://services.google.com/feedback/online_hws_feedback">' +
 '<span class="ad_header" style="text-align:left">Annonser fra Google</span><br><br></a>' + narrowAds;
 }
 if (wideAds != "")
 {
 wideAds = '<a style="text-decoration:none" ' + 'href="http://services.google.com/feedback/online_hws_feedback">' +
 '<span class="ad_header" style="text-align:left">Annonser fra Google</span><br><br></a>' + wideAds;
 }
 if (midAds != "")
 {
 midAds = '<a style="text-decoration:none" ' + 'href="http://services.google.com/feedback/online_hws_feedback">' +
 '<span class="ad_header" style="text-align:left">Annonser fra Google</span><br><br></a>' + midAds;
 }
 
 document.getElementById("wide_ad_unit").innerHTML = wideAds;

 document.getElementById("narrow_ad_unit").innerHTML = narrowAds;
 document.getElementById("mid_ad_unit").innerHTML = midAds;
 
 }
 if (window.location.href.indexOf("www.rubrikk.no/til_salgs") >=0){
 google_afs_ad = 'w11';
 google_afs_query = GetParam2();
 google_afs_channel = '1411053791';
 }else if (window.location.href.indexOf("www.rubrikk.no/brukt/") >=0){
 google_afs_ad = 'w11';
 google_afs_query = GetParam3();
 google_afs_channel = '5229696907';
 }else{
 google_afs_ad = 'w7';
 google_afs_query = GetParam('ft');
 google_afs_channel = '5661944469';
 }
 
 google_afs_client = 'pub-0412891939856117';
 
 google_afs_hl = 'no';
 }
else
{
var numAdBlockCount = 1;
 function google_ad_request_done(google_ads)
 {
 
 var i; 
 var s = '';
 var google_num_ads = google_ads.length;
 if (google_num_ads <= 0) {
 if (document.getElementById("narrow_ad_unit"))  document.getElementById("narrow_ad_unit").style.display = 'none';
 if (document.getElementById("wide_ad_unit"))  document.getElementById("wide_ad_unit").style.display = 'none';
 return;
 }
 var topAds = "";
 var middleAds = "";
 var bottomAds ="";
 
 var adsByGoogle = '<a href=\"' + google_info.feedback_url + '\"><span class="font4 colora">Annonser fra Google</span></a><br>';
 for(i = 0; i < google_num_ads; i++)
 {
 var rep = google_ads[i].visible_url.replace('www.','');
  if (google_ads[0].type == "flash") {

   s += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + 
google_ad.image_width +	'" HEIGHT="' + 
google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' + 
google_ad.image_url + '">' + 
'<PARAM NAME="quality" VALUE="high">' + 
'<PARAM NAME="AllowScriptAccess" VALUE="never">' + 
'<EMBED src="' + 
google_ad.image_url + '" WIDTH="' + 
google_ad.image_width + '" HEIGHT="' + 
google_ad.image_height + 
'" TYPE="application/x-shockwave-flash"' + 
' AllowScriptAccess="never" ' + 
' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';

} else if (google_ads[0].type == "image") {

   s += ' <a href="' + 
google_ads[0].url + '" target="_top" title="go to ' + 
google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
google_ads[0].visible_url + '\';return true"><img border="0" src="' + 
google_ads[0].image_url + '"width="' + 
google_ads[0].image_width + '"height="' + 
google_ads[0].image_height + '"></a>';

} else if (google_ads[0].type == "html") {

        s += google_ads[0].snippet;
       
}else{
 
 var s = '<table id="" border="0" cellpadding="0" cellspacing="0" style="height:130px;width:100%;" width="100%">'+
 '<tr onmouseover="this.style.backgroundColor=\'#E6F2FA\';" onmouseout="this.style.backgroundColor=\'#FFFFFF\';">'+
 //'<td id="imagecell" style="width: 200px; height: 100%; padding-right: 20px;" align="left">'+
 //'</td>' +
 '<td>' +
 '<table style="width: 100%; height: 100%; border: 0;" cellpadding="0" cellspacing="0"><tr><td><table id="HeadlineTable" style="width:100%;height:125px;" border="0" cellpadding="0" cellspacing="0">'+
 '<tr><td style="height: 100%; width: 65%;" align="left"><div><span class="ad_line1"><a id="Headline" class="font2 underline colorb" href="'+google_ads[i].url+'">'+google_ads[i].line1+'</a></span></div>' +
 '<div><span class="ad_url">'+google_ads[i].line2+' '+google_ads[i].line3+'</span><br><a id="Ingress" class="font4" href="'+google_ads[i].url+'"><span class="ad_url">'+google_ads[i].visible_url+'</span></a></div></td><td style="height:100%; width:25%;" align="right" class="font3 colora"> &nbsp;</td> </td></tr></table></td></tr></table></td></tr></table>';
    
    //document.write("<img rel=\"nofollow\" src=\"http://www.rubrikk.no/words.aspx?word="+google_ads[i].line1+"&kat="+window.location.href+"\" />");
    
 }
 
 if(i+1 < google_num_ads) s+= '<div style="height:2px;"></div><div style="height:2px;" class="dottedline"></div>';
 

 if (numAdBlockCount == 1)
 {
 topAds+=s;
  
 }
 else if (numAdBlockCount == 2)
 {
 middleAds+=s;
 }
 else if (numAdBlockCount == 3)
 {
 bottomAds+=s;
 }
 if (i == (google_num_ads-1))
 {
  numAdBlockCount++;
 }
 }
 if (topAds != "")
 {
 topAds = adsByGoogle + topAds;
 document.getElementById("wide_ad_unit").innerHTML = topAds;
 }
 if (middleAds != "")
 {
 
 middleAds = adsByGoogle + middleAds;
 document.getElementById("mid_ad_unit").innerHTML = middleAds;
 }
 if (bottomAds != "")
 {
 bottomAds = adsByGoogle + bottomAds;
 document.write("<div id=\"narrow_ad_unit\" class=\"narrow_ads\"></div>");
 document.getElementById("narrow_ad_unit").innerHTML = bottomAds;
 }
 }
 }
 }
