
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function calcHeight()
{
  //find the height of the internal page
  var the_height=
    document.getElementById('the_iframe').contentWindow.
      document.body.scrollHeight;

  //change the height of the iframe
  document.getElementById('the_iframe').height=
      the_height;
}


function popUp2(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=530,height=620,left=380,top=202');");
}


function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=510,height=520,left=385,top=252');");
}


if (window.XMLHttpRequest) { 
    xmlHttp = new XMLHttpRequest();
} else if (window.ActiveXObject) { 
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
function callServer(url) {
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updatePage;
  xmlHttp.send(null);
}
function updatePage() {
  try {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
    document.getElementById("rtoc").innerHTML = response;
    setTimeout("callServer('/rtoc.php')",5000);
  }
  } catch (e) {}
}




/* Login xHttpRequest */
function xload(e, url) {
	if (window.XMLHttpRequest)
		xmlHttp = new XMLHttpRequest();
	else if (window.ActiveXObject)
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);
	function updatePage() {
		try {
		if (xmlHttp.readyState == 4) {
			var response = xmlHttp.responseText;
			document.getElementById(e).innerHTML = response;
		}
		} catch (e) {}
	}
}

/* 
Google AdSense Trax
*/

var analyticsTag = '/asclick';

// init adsense click tracking after docuement load...
attachOnloadEvent(adsenseTrackerInit);

// helper global variables
var adsenseTrackerActive = false;
var adsenseTrackerUnit = '';

// prefixes and suffixes language filter array
var lngFilter = Array('go to','View ads about','gehe zu','Afficher la page','Afficher des annonces sur','Anzeigen über',
'gaan na','|ma Ja','war-du','vs a','Jdi na','Zobrazit reklamy na téma','ewch i','g til','Se annoncer om','iru al','ir a',
'Ver anuncios sobre','liigu edasi aadressile','bisitatu','mene osoitteeseen','Tarkastele mainoksia aiheesta','far til',
'gean nei','tigh chuig','rach gu','Jeho ko\'pe:','idemo na','Ugrs:','vade a','fara','visita','Visualizza annunci su',
'Ayo menyang','ire ad','kumbama na','eiti','Dodieties uz','|- ilekku povuka','pergi ke','mur sa','ga naar',
'Bekijk advertenties over','g til','Se annonser om','anar a','|ku jAntu','przejd do','Pokarz reklamy o','ir para',
'Ver anúncios sobre','riy|man','va a','du-te la','posjeti','|yanna','prejdi na','Zobraziť reklamy s témou','pojdi na',
'endai ku','Aad','shko n','e ya ho','lebet ka','g till','Se annonser om','nenda','|a git','pumunta sa','\'alu ki he',
'|adresine git','Şu konuyla ilgili reklamları görüntüle:','ko','|ga boring','yiya kwi','lo si','iya ku','A(z)|témával kapcsolatos hirdetések megtekintése',
'|&#2965;&#3021;&#2965;&#3009;&#2970;&#3021; &#2970;&#3014;&#2994;&#3021;&#2994;&#2997;&#3009;&#2990;&#3021;',
'|&#3093;&#3135; &#3125;&#3142;&#3123;&#3149;&#3123;&#3074;&#3105;&#3135;','&#6033;&#6085;&#6016;&#6070;&#6035;&#6091;',
'|&#1576;&#1585;&#1734; &#1576;&#1734;','v&#224;o trang','|ünvanına keç','küçü:','Andate versu à','ба|рафтан','Просмотреть рекламу по теме',
'|адресіне бару','Εμφάνιση διαφημίσεων σχετικά με','|에 대한 광고 보기','गच्छ|प्रति','მოინახულე','դեպի','ໄປຫາ','|の広告検索','|मा जानुहोस्','|ला जा');

// filter phrase with lngFilter
function filterPhrase(phrase) {
    var suprefixes, filterhit;
    
    phrase = phrase.replace(/^\s+|\s+$/g, '');
    if (phrase != '') {
        for(var i=0; i<lngFilter.length; i++) {
            suprefixes = lngFilter[i].split('|');
            // check prefix
            if (suprefixes[0].length > 0 && phrase.substring(0, suprefixes[0].length) == suprefixes[0]) {
                phrase = phrase.substring(suprefixes[0].length);
                filterhit = true;
            }
            // check suffix
            if (suprefixes.length > 1 && suprefixes[1].length > 0 && phrase.substring(phrase.length - suprefixes[1].length) == suprefixes[1]) {
                phrase = phrase.substring(0, phrase.length - suprefixes[1].length);
                filterhit = true;
            }    
            if (filterhit) {
                phrase = phrase.replace(/^\s+|\s+$/g, '');
                break;
            }        
        }
    }
    return phrase;
}

// init tracker
function adsenseTrackerInit() {
	var pageHasAdsense = false;
	var el = document.getElementsByTagName("iframe");
	
	for (var i=0; i<el.length; i++) {
		if (el[i].src.indexOf('googlesyndication.com') > -1) {
			pageHasAdsense = true;

			el[i].onmouseover = adsenseTrackerActivate;
			el[i].onmouseout = adsenseTrackerDeActivate;
		}
	}

	if (pageHasAdsense) {
		if (typeof window.attachEvent != 'undefined') {
			// this works for IE
			window.attachEvent('onbeforeunload', adsenseTrackerCheckClick);
		} else if (typeof window.addEventListener != 'undefined') {
			// this works for firefox
			window.addEventListener('beforeunload', adsenseTrackerCheckClick, false);
		}
	}
}

// check if it's our click
function adsenseTrackerCheckClick() {
	if (adsenseTrackerActive) {
		var reportedUrl = analyticsTag;

		if (adsenseTrackerUnit != '') {
			reportedUrl += '/'+ escape(adsenseTrackerUnit);
		}

		// check for ad Url/AdLinks text (is disabled in Firefox by default)
		if (window.status) {
		    var adsenseClickedAd = filterPhrase(window.status);
			if (adsenseClickedAd != '') {
			    reportedUrl += '/'+ escape(adsenseClickedAd);
			}
		}

		// this could be replaced with other tracking sw...
		reportToGoogleAnalytics(reportedUrl);
	}
}

// when moving mouse to adsense frame, activate click tracking for current ad unit...
function adsenseTrackerActivate() {
	adsenseTrackerUnit = '';

	if (this.parentNode) {
		// check for custom asc_ adsense element id
		if (this.parentNode.id.substring(0, 4) == 'asc_') {
			adsenseTrackerUnit = this.parentNode.id.substring(4);
		}
	}
	if (adsenseTrackerUnit == '') {
		// decode format parameter from adsense ads url
		var url = this.src;
		var startIndex = url.indexOf('format=');
		if (startIndex >= 0) {
			var lastIndex = url.indexOf('&', startIndex);
			adsenseTrackerUnit = lastIndex >= 0 ? url.substring(startIndex + 7, lastIndex) : url.substring(startIndex + 7);
		}
	}
	adsenseTrackerActive = true;
}

// when moving mouse out of adsense frame, deactivate click tracking...
function adsenseTrackerDeActivate() {
	adsenseTrackerUnit = '';
	adsenseTrackerActive = false;
}

// report click to google Analytics
function reportToGoogleAnalytics(reportedUrl) {
	if (typeof urchinTracker == 'function') {
		urchinTracker(reportedUrl);
	}
}

// attach func function to window onload event (crossbrowser compatible)
function attachOnloadEvent(func) {
	if(typeof window.addEventListener != 'undefined') {
		// moz, saf1.2, ow5b6.1
		window.addEventListener('load', func, false);
	} else if (typeof document.addEventListener != 'undefined') {
		// MSN/OSX, op7.50, saf1.2, ow5b6.1
		document.addEventListener('load', func, false);
	} else if (typeof window.attachEvent != 'undefined') {
		// ie5.0w, ie5.5w, ie6w
		window.attachEvent('onload', func);
	} else {
		// all other browsers
		if (typeof window.onload == 'function') {
			var oldonload = onload;
			window.onload = function() {
				oldonload();
				func();
			};
		} else {
				window.onload = func;
		}
	}
}

/* END AdSense Tracking */






/* Flash Fix for IE */
function display_flash_header() {
	var flash_header_html =
	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="335" height="320" id="header2" align="middle">' +
	'<param name="allowScriptAccess" value="always" />' +
	'<param name="wmode" value="transparent" />' +
	'<param name="movie" value="/kh.swf" />' +
	'<param name="quality" value="high" />' +
	'<param name="bgcolor" value="#322b21" />' +
	'<embed src="/kh.swf"  wmode="transparent" quality="high" bgcolor="#322b21" width="335" height="320" name="kh" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
	'</object>';
	document.write(flash_header_html);
}







/**
 * reflection.js v1.6
 *
 * Contributors: Cow http://cow.neondragon.net
 *               Gfx http://www.jroller.com/page/gfx/
 *               Sitharus http://www.sitharus.com
 *               Andreas Linde http://www.andreaslinde.de
 *               Tralala, coder @ http://www.vbulletin.org
 *
 * Freely distributable under MIT-style license.
 */
 
/* From prototype.js */
document.getElementsByClassName = function(className) {
	var children = document.getElementsByTagName('*') || document.all;
	var elements = new Array();
  
	for (var i = 0; i < children.length; i++) {
		var child = children[i];
		var classNames = child.className.split(' ');
		for (var j = 0; j < classNames.length; j++) {
			if (classNames[j] == className) {
				elements.push(child);
				break;
			}
		}
	}
	return elements;
}

var Reflection = {
	defaultHeight : 0.5,
	defaultOpacity: 0.5,
	
	add: function(image, options) {
		Reflection.remove(image);
		
		doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }
		if (options) {
			for (var i in doptions) {
				if (!options[i]) {
					options[i] = doptions[i];
				}
			}
		} else {
			options = doptions;
		}
	
		try {
			var d = document.createElement('div');
			var p = image;
			
			var classes = p.className.split(' ');
			var newClasses = '';
			for (j=0;j<classes.length;j++) {
				if (classes[j] != "reflect") {
					if (newClasses) {
						newClasses += ' '
					}
					
					newClasses += classes[j];
				}
			}

			var reflectionHeight = Math.floor(p.height*options['height']);
			var divHeight = Math.floor(p.height*(1+options['height']));
			
			var reflectionWidth = p.width;
			
			if (document.all && !window.opera) {
				/* Copy original image's classes & styles to div */
				d.className = newClasses;
				p.className = 'reflected';
				
				d.style.cssText = p.style.cssText;
				p.style.cssText = 'vertical-align: bottom';
			
				var reflection = document.createElement('img');
				reflection.src = p.src;
				reflection.style.width = reflectionWidth+'px';
				
				reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';
				reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';
				
				d.style.width = reflectionWidth+'px';
				d.style.height = divHeight+'px';
				p.parentNode.replaceChild(d, p);
				
				d.appendChild(p);
				d.appendChild(reflection);
			} else {
				var canvas = document.createElement('canvas');
				if (canvas.getContext) {
					/* Copy original image's classes & styles to div */
					d.className = newClasses;
					p.className = 'reflected';
					
					d.style.cssText = p.style.cssText;
					p.style.cssText = 'vertical-align: bottom';
			
					var context = canvas.getContext("2d");
				
					canvas.style.height = reflectionHeight+'px';
					canvas.style.width = reflectionWidth+'px';
					canvas.height = reflectionHeight;
					canvas.width = reflectionWidth;
					
					d.style.width = reflectionWidth+'px';
					d.style.height = divHeight+'px';
					p.parentNode.replaceChild(d, p);
					
					d.appendChild(p);
					d.appendChild(canvas);
					
					context.save();
					
					context.translate(0,image.height-1);
					context.scale(1,-1);
					
					context.drawImage(image, 0, 0, reflectionWidth, image.height);
	
					context.restore();
					
					context.globalCompositeOperation = "destination-out";
					var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);
					
					gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
					gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")");
		
					context.fillStyle = gradient;
					if (navigator.appVersion.indexOf('WebKit') != -1) {
						context.fill();
					} else {
						context.fillRect(0, 0, reflectionWidth, reflectionHeight*2);
					}
				}
			}
		} catch (e) {
	    }
	},
	
	remove : function(image) {
		if (image.className == "reflected") {
			image.className = image.parentNode.className;
			image.parentNode.parentNode.replaceChild(image, image.parentNode);
		}
	}
}

function addReflections() {
	var rimages = document.getElementsByClassName('reflect');
	for (i=0;i<rimages.length;i++) {
		var rheight = null;
		var ropacity = null;
		
		var classes = rimages[i].className.split(' ');
		for (j=0;j<classes.length;j++) {
			if (classes[j].indexOf("rheight") == 0) {
				var rheight = classes[j].substring(7)/100;
			} else if (classes[j].indexOf("ropacity") == 0) {
				var ropacity = classes[j].substring(8)/100;
			}
		}
		
		Reflection.add(rimages[i], { height: rheight, opacity : ropacity});
	}
}



function slider(url) {
	xload('slider', url);
	Slide('slider').toggle();
}




/* KH Slider */
var slideInUse = new Array();

function Slide(objId, options) {
	this.obj = document.getElementById(objId);
	this.duration = .4;
	this.height = parseInt(this.obj.style.height);

	if(typeof options != 'undefined') { this.options = options; } else { this.options = {}; }
	if(this.options.duration) { this.duration = this.options.duration; }
	if(this.options.height) { this.height = this.options.height; }
	
	if (!this.height) { this.height = 200; }

	this.up = function() {
		this.curHeight = this.height;
		this.newHeight = '1';
		this.curOpacity = '99'; //why do we make this 99 and not .99? I don't know!
		if(slideInUse[objId] != true) {
			var finishTime = this.slide();
			window.setTimeout("Slide('"+objId+"').finishup("+this.height+");",finishTime);
		}
	}
	
	this.down = function() {
		this.newHeight = this.height;
		this.curHeight = '1';
		this.curOpacity = '0.4';
		if(slideInUse[objId] != true) {
			this.obj.style.opacity = '0.4';
			this.obj.style.height = '1px';
			this.obj.style.display = 'block';
			this.slide();
		}
		this.slideStatus = 'down';
	}



	this.toggle = function() {
		if (typeof this.slideStatus != 'undefined') {
			if (this.slideStatus == 'down') {
				this.up();
			} else {
				this.down();
			}
		} else { this.down(); }
	}

	
	this.slide = function() {
		slideInUse[objId] = true;
		var frames = 30 * duration; // Running at 30 fps

		var tIncrement = (duration*1000) / frames;
		tIncrement = Math.round(tIncrement);
		var sIncrement = (this.curHeight-this.newHeight) / frames;

		var frameSizes = new Array();
		for(var i=0; i < frames; i++) {
			if(i < frames/2) {
				frameSizes[i] = (sIncrement * (i/frames))*4;
			} else {
				frameSizes[i] = (sIncrement * (1-(i/frames)))*4;
			}
		}

		var j;
		for(var i=0; i < frames; i++) {
			this.curHeight = this.curHeight - frameSizes[i];
			window.setTimeout("document.getElementById('"+objId+"').style.height='"+Math.round(this.curHeight)+"px';",tIncrement * i);
			j = tIncrement * i;
		}
		
		for(var i=0; i < frames; i++) {
			this.curOpacity = this.curOpacity - frameSizes[i];
//			window.setTimeout("document.getElementById('debug').innerHTML='"+Math.round(this.curOpacity)/100+"';",(tIncrement * i)/1);
			window.setTimeout("document.getElementById('"+objId+"').style.opacity='"+Math.round(this.curOpacity)/100+"';",(tIncrement * i)/1);
		}

		window.setTimeout("delete(slideInUse['"+objId+"']);",tIncrement * i);
		
		if(this.options.onComplete) {
			window.setTimeout(this.options.onComplete, tIncrement * (i-2));
		}
		
		return tIncrement * i;
	}
	
	this.finishup = function(height) {
		this.obj.style.display = 'none';
		this.obj.style.height = height + 'px';
		this.slideStatus = 'up';
	}
	
	return this;
}






/* Executes on load */
attachOnloadEvent(addReflections);