// Softloop site.js - Copyright 2008 by Softloop (Hirbod)

// www.softloop.net

// Ajax Abfrage

var homeAktiv = true;
var hManager = null; //History Manager
var noUpdate = false;

// Dem a active geben
function updateNav(el){
	$$('#navi_top a').each(function(item, index){
    		item.className='';
	});
	if(el)
		el.className='active';
}

// Dem li von firstlevel active geben
function updateNavFirst(el2){
	$$('#navi_top ul.firstLevel li').each(function(item, index){
    		item.className='';
	});
	if(el2)
		el2.className='active';
}


function resetNav() {
	$$('#navi_top ul.firstLevel li').each(function(item, index){
    		item.className='';
	});
	$$('#navi_top a').each(function(item, index){
    		item.className='';
	});
}

Slimbox.scanPage = function() { // added 25.05.2009
	$$(document.links).filter(function(el) {
		return el.rel && el.rel.test(/^lightbox/i);
	}).slimbox({/* Put custom options here */}, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	});
};

function callAJAX(pageid, id, templateId, seite, sprache, accordionIndex, secondLevelId) {
	


	updateNav($('A' + pageid));
	updateNavFirst($('firstLevelLI' + id));

	if(secondLevelId){
		el = $('A' + secondLevelId);
		if(el) {
			el.className='active';
		}
	}	

	showAccordion(accordionIndex);

	// var url = "index.php?article_id=22&pageid=" + pageid + "&clang=" + sprache + "&seite=" + seite;
	
	var url = "index.php?article_id=22&pageid=" + pageid + "&clang=" + sprache + "&seite=" + seite + "&accordionIndex=" + accordionIndex;

	//alert(pageid + '-' + id + '-' + templateId + '-' + seite + '-' + sprache);
	hManager.setValues('callAJAX', [pageid, id, templateId, seite, sprache, accordionIndex, secondLevelId]);

	var className = '';
	if(templateId==9 || templateId==3){
		className = 'kurz';
	} else if(templateId==10 || templateId==4){
		className = 'home';
	}

	if(className=="home"){
		new Fx.Tween('article').start('width', '360');
	} else {
		new Fx.Tween('article').start('width', '545');
	}

	if((className == "home" && !homeAktiv) || (className != "home" && homeAktiv)){
		new Fx.Tween('sidebar_bottom').start('opacity', '1', '0');
	}

	if($('article_top')){
		if(sprache==0)
			$('article_top').innerHTML = '<a href="index.php?article_id=' + pageid + '&clang=1">english version</a>';
		if(sprache==1)
			$('article_top').innerHTML = '<a href="index.php?article_id=' + pageid + '&clang=0">deutsche version</a>';
	}

	new Fx.Tween('article_bottom',{
			onComplete: function(){

				document.getElementsByTagName("body")[0].setAttribute('id', 'catid_' + id);
				$('wrapper').className=className;

				new Request.HTML({
					method: 'get',
					update: $('article_bottom'),
					url: url,
					onSuccess: function(responseText, responseXML){
						
						if((className == "home" && !homeAktiv) || (className != "home" && homeAktiv)){
							$('sidebar_bottom').innerHTML = $('sidebar_bottom_content').innerHTML;
							if(templateId!=10 && templateId!=4)
								$('sidebar_bottom').innerHTML += $('sidenav_bottom_content').innerHTML;
							new Fx.Tween('sidebar_bottom').start('opacity', '0', '1');
						}

						if(className == "home"){
							homeAktiv = true;
						} else {
							homeAktiv = false;
						}

						$('article_bottom').innerHTML = $('article_bottom_content').innerHTML;
						new Fx.Tween('article_bottom').start('opacity', '0', '1');
						
						// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)

						Slimbox.scanPage(); // added 25.05.2009
						
					}
				}).send();			
			}
		}).start('opacity', '1', '0');

	return false;
}

var cs = new SWFObject("http://aragon.factsheetslive.com/base/charts/stock/csStock.swf", "StockChart", "513", "400", "8", "#fff");
cs.addVariable("path", "http://aragon.factsheetslive.com/base/cache/.cache/");

cs.addVariable("settings_file", escape("http://aragon.factsheetslive.com/charts/stock/stock_settings.php?name=Aragon AG&benchmark=Entry+Standard&fonds=Y"));

cs.addVariable("preloader_color", "#0f4d96");
cs.addVariable("loading_settings", "Die Settings des Charts werden geladen");
cs.addVariable("loading_data", "Darzustellende Daten werden geladen");

var csEn = new SWFObject("http://aragon.factsheetslive.com/base/charts/stock/csStock.swf", "StockChart", "513", "400", "8", "#fff");
csEn.addVariable("path", "http://aragon.factsheetslive.com/base/cache/.cache/");

csEn.addVariable("settings_file", escape("http://aragon.factsheetslive.com/charts/stock/stock_settings.php?name=Aragon AG&benchmark=Entry+Standard&fonds=Y&lang=En"));

csEn.addVariable("preloader_color", "#0f4d96");
csEn.addVariable("loading_settings", "Die Settings des Charts werden geladen");
csEn.addVariable("loading_data", "Darzustellende Daten werden geladen");

function loadCharts(lang){
	if(lang == 1){
		csEn.write("stockChart");
	}else{
		cs.write("stockChart");
	}
}

function noBlur() {
  if(document.getElementsByTagName) {
    var as = document.getElementsByTagName("a");
    var l  = as.length;
    for(i=0; i < l; i++) {
      as[i].onfocus = _blur;
    }
  }
}

window.addEvent('domready', function(){ // added 25.05.2009
	Slimbox.scanPage(); 
});

