if (top.location != location) top.location.href = document.location.href ;

function sbmform()
{
	frm = $("mainform");
	frm.submit();
}

function blurLinks(){ 
	for(var i=0;i<document.links.length;i++) document.links[i].blur() 
}

function modalDialog(URL) {
 var sFeatures = 'dialogLeft: 100; dialogTop: 100; dialogHeight: 600px;  dialogWidth: 800px; ';
 sFeatures += 'status: no; scroll: no; resizable: no; help: no; center: no; dialogHide: no;';
 //sFeatures = '';
 var sUrl = URL;
 a = window.open(sUrl, null, sFeatures);
 a.focus();
}

function switchTab(obj, nr)
{
		// reset
		var zzindex = 100;
		var o =null;
		var ti = 0;
		var tbar = $("tabbar" + nr);
		var tpg = $("tabpages" + nr);
		var tpid = obj.id.replace("tab", "tabcontent");				

		for(var i=0;i<tbar.childNodes.length;i++)
		{
				o = tbar.childNodes[i];
				if(o.id == obj.id) ti = i;

				if((o.tagName == "DIV") && (o.className == "carsubnav tabbutton"))
				{
						o.className = "carsubnav-inactive tabbutton";
						o.style.zIndex = zzindex;
						zzindex++;
				}
		}

		for(i=0;i<tpg.childNodes.length;i++)
		{
				o = tpg.childNodes[i];
				if((o.tagName == "DIV") && (o.className = "tabcontent")) o.style.display = "none";
		}

		obj.className = "carsubnav tabbutton";
		$(tpid).style.display = "block";
}


function MyBrowser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}
var thebrowser = new MyBrowser();

function addToFavorites(urlAddress, pageName) 
{
	if (window.sidebar) window.sidebar.addPanel(pageName,urlAddress,"");
    else if( window.opera && window.print )
    {
	    var mbm = document.createElement('a');
	    mbm.setAttribute('rel','sidebar');
	    mbm.setAttribute('href',urlAddress);
	    mbm.setAttribute('title',pageName);
	    mbm.click();
    }
    else if( window.external ) window.external.AddFavorite( urlAddress, pageName );
}

function submit_poll()
{
	var val = '';
	$each($$("input.polloption"), function(el) { if (el.checked) val=el.value; });

	if (val=='') alert('Please choose an option!');
	else $('pollcontainer').set('load', {url: $("pollform").get('action'), method: 'post', evalScripts: true, data: "silent=1&nfo[poll][poll_id]="+$("poll_id").value+"&nfo[poll][opt_id]="+val}).load();

	return false;
}

function init_window() 
{
	// quit if this function has already been called
	if (arguments.callee.done) return;

	// flag this function so we don't do the same thing twice
	arguments.callee.done = true;

	// add to favs
	bmlink_tag = $("bmlink");
	if (bmlink_tag) bmlink_tag.onclick = function() {addToFavorites(location.href, document.title);return false;}	

	// search
	si = $("searchinput");
	if ( si )
	{
		si.onfocus = function() {if ( si.value == 'KEYWORD' ) si.value = '';}
		si.onblur = function() {if ( si.value == '' ) si.value = 'KEYWORD';}
	}

	// poll
	poll = $("pollform");
	if ( poll )
	{
		poll.onsubmit = submit_poll;
	}
};

function writeConsole(content) {
 top.consoleRef=window.open('','myconsole',
  'width=1000,height=550'
   +',menubar=0'
   +',toolbar=1'
   +',status=0'
   +',scrollbars=1'
   +',resizable=1');
 top.consoleRef.document.writeln(
  '<html><head><title>Console</title><style type="text/css">body{font-size: 10px}</style></head>'
   +'<body bgcolor=white onLoad="">'
   +content
   +'</body></html>'
 )
 top.consoleRef.document.close()
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function addEngine(name,src,icon) {
    if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) { 
        window.sidebar.addSearchEngine(src, icon, name, '');
    } else {
        alert("Sorry, you need a Mozilla-based browser (such as Firefox) to install a search plugin.");
    } 
}

function hot_to(hot_new)
{
	$("hot_pin_"+hot_current).style.color = '#444444';
	hot_current = hot_new;
	$("hot_pin_"+hot_current).style.color = '#A6A6A6';
	$("hot_pin_"+hot_current).blur();
	
	$("hot_image_slot").src = hot_pics[hot_current];
	$("hot_url_title").innerHTML = hot_titles[hot_current];
	$("hot_url_title").href = hot_urls[hot_current];
	$("hot_url_more").href = hot_urls[hot_current];
	$("hot_url_image").href = hot_urls[hot_current];
	//$("hot_text").innerHTML = hot_text[hot_current];
	//$("hot_current").innerHTML = hot_current+1;

	// if(typeof Hyphenator == 'object') Hyphenator.run();
}

function hot_next()
{
	hot_to(hot_current == hotspot_articles-1 ? 0 : hot_current+1);
	return;

	$("hot_image_slot").src = hot_pics[hot_current];
	$("hot_url_title").innerHTML = hot_titles[hot_current];
	$("hot_url_title").href = hot_urls[hot_current];
	$("hot_url_more").href = hot_urls[hot_current];
	$("hot_url_image").href = hot_urls[hot_current];
	//$("hot_text").innerHTML = hot_text[hot_current];
	$("hot_current").innerHTML = hot_current+1;

	// if(typeof Hyphenator == 'object') Hyphenator.run();
}

function hot_prev()
{
	hot_to(hot_current == 0 ? hotspot_articles-1 : hot_current-1);
	return;

	$("hot_image_slot").src = hot_pics[hot_current];
	$("hot_url_title").innerHTML = hot_titles[hot_current];
	$("hot_url_title").href = hot_urls[hot_current];
	$("hot_url_more").href = hot_urls[hot_current];
	$("hot_url_image").href = hot_urls[hot_current];
	//$("hot_text").innerHTML = hot_text[hot_current];
	$("hot_current").innerHTML = hot_current+1;

	// if(typeof Hyphenator == 'object') Hyphenator.run();
}

var crt_tdr = 1; // current testdrive
function testdrive_change(sign)
{

	if (sign == '+')
	{
		if (crt_tdr >= max_tdr) crt_tdr = 1;
		else crt_tdr++;
	}
	else
	{
		if (crt_tdr < 2) crt_tdr = max_tdr;
		else crt_tdr--;
	}

	for (i=1; i<=max_tdr; i++ )
	{
		$('hpt_'+i).style.display = 'none';
	}

	$('hpt_'+crt_tdr).style.display = 'block';

}

function rot_next(j)
{
	rot_current[j]++;
	if(rot_current[j] >= rot_articles[j] ) rot_current[j] = 0;

	rot_change(j);
}

function rot_prev(j)
{
	rot_current[j]--;
	if(rot_current[j] < 0) { rot_current[j] = rot_articles[j]; rot_current[j]--; }

	rot_change(j);
}

function rot_change(j)
{
	eval("rot_pics = rot_pics_" + j);
	eval("rot_titles = rot_titles_" + j);
	eval("rot_text = rot_text_" + j);
	eval("rot_urls = rot_urls_" + j);

	$("rot_image_slot_"+j).src = rot_pics[rot_current[j]];
	$("rot_image_slot_"+j).alt = rot_titles[rot_current[j]];
	$("rot_url_title_"+j).innerHTML = rot_titles[rot_current[j]];
	$("rot_url_title_"+j).title = rot_titles[rot_current[j]];
	$("rot_url_title_"+j).href = rot_urls[rot_current[j]];
	$("rot_url_more_"+j).href = rot_urls[rot_current[j]];
	$("rot_url_image_"+j).href = rot_urls[rot_current[j]];
	$("rot_url_image_"+j).title = rot_titles[rot_current[j]];
	$("rot_text_"+j).innerHTML = rot_text[rot_current[j]];
}

/* MM Preloader */
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 MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// text size
var tt_size = 12;
var tt_lh = 15;
var ti_size = 11;
var ti_lh = 14;
var tt_img_plus = _baseurl + 'img/text_plus.gif';
var tt_img_minus = _baseurl + 'img/text_minus.gif';
var tt_img_plus_sel = _baseurl + 'img/text_plus_sel.gif';
var tt_img_minus_sel = _baseurl + 'img/text_minus_sel.gif';

function ttsz_inc()
{
	if(tt_size>12) return;
	tt_size+=2;
	tt_lh+=3;
	ti_size+=2;
	ti_lh+=3;
	$each($$("div.article_container", "div.article_container p", "div.article_container div", "table.iwithcomm tr td", "div.chapter_content", "div.chapter_content p"), function(el) 
	{ 
		el.style.fontSize = tt_size+'px';
		el.style.lineHeight = tt_lh+'px';	
	});

	$each($$("table.iwithcomm tr td"), function(el) 
	{ 
		el.style.fontSize = ti_size+'px';
		el.style.lineHeight = ti_lh+'px';	
	});

	$('tt_minus').src = tt_img_minus;
	$('tt_plus').src = tt_img_plus_sel;
}
function ttsz_dec()
{
	if(tt_size<13) return;		
	tt_size-=2;
	tt_lh-=3;
	ti_size-=2;
	ti_lh-=3;
	$each($$("div.article_container", "div.article_container p", "div.article_container div", "table.iwithcomm tr td", "div.chapter_content", "div.chapter_content p"), function(el) 
	{ 
		el.style.fontSize = tt_size+'px';
		el.style.lineHeight = tt_lh+'px';	
	});

	$each($$("table.iwithcomm tr td"), function(el) 
	{ 
		el.style.fontSize = ti_size+'px';
		el.style.lineHeight = ti_lh+'px';	
	});

	$('tt_minus').src = tt_img_minus_sel;
	$('tt_plus').src = tt_img_plus;
}

var ae__sharecontainer_created = 0;
function ae__sharecontainer(obj)
{
	ae__sharecontainer_created = 1;

	var xloc = obj.offsetWidth-280+3;
	var yloc = 30;

	do{ yloc += obj.offsetTop || 0; xloc += obj.offsetLeft || 0; obj = obj.offsetParent;} while (obj);

	$('sharecontainer').style.left = xloc+'px';
	$('sharecontainer').style.top = yloc+'px';
	$('sharecontainer').style.display = 'block';

	setTimeout('ae__sharecontainer_close()', 10000);
}

function ae__sharecontainer_toggle(obj)
{
	if(!ae__sharecontainer_created) ae__sharecontainer(obj);								
	else if($('sharecontainer').style.display == 'block') $('sharecontainer').style.display = 'none';
	else
	{
		$('sharecontainer').style.display = 'block';
		setTimeout('ae__sharecontainer_close()', 10000);
	}
}
function ae__sharecontainer_close()
{
	$('sharecontainer').style.display = 'none';
}

/* for Mozilla */
if (document.addEventListener) document.addEventListener("DOMContentLoaded", init_window, false);

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
   document.write("<script defer src=/js/ie_onload.js><"+"/script>");
/*@end @*/

/* for other browsers */
window.onload = init_window;