﻿/* DEPENDENCY ON JohnnicWebProfile.js */
/* TODO: Obviscate */

// set show_afs_search.js parameters
var googleSearchIframeName		= 'googleSearchUnitIframe';
var googleSearchFrameWidth		= 980;
var googleSearchFrameborder		= 0;
var googleSearchDomain			= 'www.google.co.za';
var googleSearchNumAds			= '0';
var googleSearchResizeIframe	= 'true';

// set show_afs_ads.js parameters
google_afs_query		= getQueryVariable('q');
google_afs_ad			= 'w7n0';
google_afs_client		= 'pub-1624384907986172';
google_afs_channel		= '0816278019';
google_afs_hl			= 'en';
google_afs_gl			= 'za';


function google_afs_request_done(google_ads)
{
	var google_num_ads = google_ads.length;
	if (google_num_ads <= 0)
	{
		return;
	}

	var topAds = "";
	var bottomAds = "";

	for(i = 0; i < google_num_ads; i++)
	{
		if (google_ads[i].type=="text/wide")
		{
			// first 3 ads go on top
			if (i < 3)
			{
				topAds+='<div class=\'gad\'><a class="title" onmouseover="javascript:window.status=\'' +
					google_ads[i].url + '\';return true;" ' +
					'onmouseout="javascript:window.status=\'\';return true;" ' +
					'href="' + google_ads[i].url + '">' +
					'<span class="ad_line1">' + google_ads[i].line1 + '</span></a><br>' +
					'<span class="ad_text">' + google_ads[i].line2 + '</span><br>' +
					'<a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
					google_ads[i].url + '\';return true;" ' +
					'onmouseout="javascript:window.status=\'\';return true;" ' +
					'href="' + google_ads[i].url + '">' +
					'<span class="ad_url">' + google_ads[i].visible_url + '</span></a></div>';
			}
			else
			{
				bottomAds+='<div class=\'gad\'><a class="title" onmouseover="javascript:window.status=\'' +
					google_ads[i].url + '\';return true;" ' +
					'onmouseout="javascript:window.status=\'\';return true;" ' +
					'href="' + google_ads[i].url + '">' +
					'<span class="ad_line1">' + google_ads[i].line1 + '</span></a><br>' +
					'<span class="ad_text">' + google_ads[i].line2 + '</span><br>' +
					'<a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
					google_ads[i].url + '\';return true;" ' +
					'onmouseout="javascript:window.status=\'\';return true;" ' +
					'href="' + google_ads[i].url + '">' +
					'<span class="ad_url">' + google_ads[i].visible_url + '</span></a></div>';
			
			};
		}
		else
		{
			// not gatering for narrow ads
		}
	}
	
	if (topAds != "")
		topAds = '<div class=\'ads\'><span style=\'width:980px;\'><a href=\'https://www.google.com/adsense/support/bin/request.py?contact=afs_violation\'>Ads by Google</a></span></div>'+ topAds;
		
	if (bottomAds != "")
		bottomAds = '<div class=\'ads\'><span style=\'width:980px;\'><a href=\'https://www.google.com/adsense/support/bin/request.py?contact=afs_violation\'>Ads by Google</a></span></div>'+ bottomAds;
	
	document.getElementById("googleTopAds").innerHTML = topAds;
	document.getElementById("googleBottomAds").innerHTML = bottomAds;
}

function SearchClearBox(id)
{
	document.getElementById(id).value = '';
}

function SubmitSearch(id, select)
{
	var domains		= "sowetan.co.za";
	var	sax			= 0;
	var say			= 0;
	var sa			= "Google+Search";
	var sitesearch	= "sowetan.co.za";
	var client		= "pub-1624384907986172";
	var forid		= "1";
	var channel		= "0816278019";
	var ie			= "ISO-8859-1";
	var oe			= "ISO-8859-1";
	var safe		= "active";
	var cof			= "GALT:#666666;GL:1;DIV:#E6E6E6;VLC:008131;AH:center;BGC:FFFFFF;LBGC:FF3333;ALC:9f0e0e;LC:008131;T:000000;GFNT:7E3939;GIMP:7E3939;FORID:11";
	var hl			= "en";		
	var q			= document.getElementById(id).value;
	var searchtype	= document.getElementById(select).options[document.getElementById(select).selectedIndex].value;
	
	if (searchtype == 'web')
		sitesearch = '';
	else
		sitesearch = searchtype;
		
	
	window.location = '/search/default.aspx?domains=' + escape(domains) +
		'&q=' + escape(q) +
		'&sa.x=0&sa.y=0&sa=Google+Search' +
		'&sitesearch=' + escape(sitesearch) +
		'&client=' + escape(client) +
		'&forid=' + forid +
		'&channel=' + channel +
		'&ie=' + ie +
		'&oe=' + oe +
		'&safe=' + safe + 
		'&cof=' + escape(cof) +
		'&hl=' + hl;
		
		
}

function EnterPressed(e) 
{
	var characterCode
	if(e && e.which)
	{
		// NN4 specific code
		e = e
		characterCode = e.which
	}
	else 
	{
		e = event
		characterCode = e.keyCode // IE specific code
	}
	if (characterCode == 13) return true;   // Enter key is 13
	
	else return false
}

// Hulle hou my dop