// live nav.js (c) Efirst - 2011

var nclick_count=0;

function navClick(t, idx)
{
	top.document.title=t;
	nclick_count++;
	if (nclick_count<2) return;

	var new_url="http://"+document.location.hostname+"/page"+idx+".html";
	if (typeof(idx)=="undefined") 
	{
		idx=1;
	}
	
	refreshAds(new_url);
	if (document.getElementById)
	{

		urchinTracker("/page"+idx+".html");
		/*
		var el=document.getElementById("cabanova_page_views_tracking_frame");
		var i1 = el.getElementsByTagName("iframe")[0];
		var i2 = i1.cloneNode(true);
		i2.src=i2.src+"&cr=1";
		el.removeChild(i1);
		el.appendChild(i2);
		*/
	}
	
}

function index_DoFSCommand(command, args)
{
	if(command == 'eval')
		eval(args);
}

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub index_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call index_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

function showFlash(src, w, h, o, transparent)
{
	var a = [];
	for(var n in o)
	{
		a.push(encodeURIComponent(n)+'='+encodeURIComponent(o[n]));
	}
	var vars = a.join('&');

	str_wmode1 = '<param name="wmode" value="transparent">';
	str_wmode2 = 'wmode="transparent"';

	if(navigator.userAgent.indexOf("Firefox")!=-1)
	{
		var versionindex=navigator.userAgent.indexOf("Firefox")+8;
		if (parseInt(navigator.userAgent.charAt(versionindex))>=1)
		{
			//remove wmode parameter for mozilla firefox, problem with some keyboards with char @ (like british,german,french layout etc)
			//see http://www.headlondon.com/blog/index.php/archives/no-wmode-please-were-british/
			str_wmode1 = '';
			str_wmode2 = '';
		}
	}

	//str_wmode1 = '<param name="wmode" value="opaque">';
	//str_wmode2 = 'wmode="opaque"';

	document.write('<object id="index" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+w+'" height="'+h+'">');
	document.write('<param name="movie" value="'+src+'" />');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="FlashVars" value="'+vars+'" />');
	document.write('<param name="quality" value="high" />');
	document.write(str_wmode1);
	document.write('<param name="menu" value="false" />');
	document.write('<embed name="index" src="'+src+'" menu="false" quality=high pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="'+vars+'" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" allowScriptAccess="always"'+str_wmode2+'></embed>');
	document.write('</object>');
/*
	document.write('<object id="index" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+w+'" height="'+h+'">');
	document.write('<param name="movie" value="'+src+'" />');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="FlashVars" value="'+vars+'" />');
	document.write('<param name="quality" value="high" />');
	if(transparent) document.write('<param name="wmode" value="transparent">');
	document.write('<param name="menu" value="false" />');
	document.write('<embed name="index" src="'+src+'" menu="false" quality=high pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="'+vars+'" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" allowScriptAccess="always"'+(transparent?'wmode="transparent"':'')+'></embed>');
	document.write('</object>');
*/
}

refreshAds = function(url)
{
	function replaceParam(src, name, value){			
		
		value = typeof(encodeURIComponent)=="function" ? encodeURIComponent(value) : escape(value);
		var myregexp = new RegExp("([&;]"+name+"=)[^&]*", "i");			
		src = src.replace(myregexp, "$1" + value);			
		return src;
	}
	
	function refreshDiv(div)
	{
		if (!div) return;
		var i1 = div.getElementsByTagName("iframe")[0];
		var i2 = i1.cloneNode(true);
		var src = i2.src;
		
		src = replaceParam(src, "url", url);

		i2.src = src;
		div.removeChild(i1);
		div.appendChild(i2);
	}

	if(document.getElementById && document.getElementsByTagName)
	{
		refreshDiv(document.getElementById("cabanova_google_ad_right"));
		refreshDiv(document.getElementById("cabanova_google_ad_top"));
	}

};

