// JavaScript Document
function Lvl_openWin(u,n,w,h,l,t,c,f,x) { //v1.0 4LevelWebs
  	var ww=((screen.width-w)/2);
	if(c==1)
	{
		l=ww;
		t=(screen.height-h)/2;
	}
	if(c==2)
	{
		l=ww;
	}
	//f+=',top='+t+',left='+l;
	LvlWin = window.open(u,n,f);
	if(x==1)
	{
		LvlWin.focus()
	}
	document.MM_returnValue=false;
}
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 showHideCommingSoon(what) {
	if (!document.getElementById || what != "graz")
		return;
		
	var commingSoonGif = document.getElementById("portal-comming-soon-gif");
	
	if (commingSoonGif.style.display == "none") {
		commingSoonGif.style.display = "block";
	} else {
		commingSoonGif.style.display = "none";
	}
}


/*

	ObjectTabs
	
	
*/
if(typeof parkside == "undefined") var parkside = new Object();
if(typeof parkside.ObjectPaging == "undefined") parkside.ObjectTabs = new Object();

parkside.ObjectPaging = function(p_target_website, p_content_id, p_num_items, p_current_category) {
	this.target_website = p_target_website;
	this.content_id = p_content_id;
	this.num_items = p_num_items;
	this.current_category = p_current_category;
	
	var that = this;
	SWFAddress.addEventListener(SWFAddressEvent.CHANGE, function(event) { that.handleChange(event); });
}

parkside.ObjectPaging.prototype = {
	current_offset: 0
	, current_category: 0
	, active_nav: null
	, content_id: 0
	, num_items: 10
	, target_website: "graz"
	
	/*
		change
	*/
	, change: function ( offset, category ) {
		if (offset < 0 || category < 0 || offset == null || category == null )
			return;

		if (this.current_offset == offset && this.current_category == category )
			return;

		this.deactivateTab();

		this.current_offset = offset;
		this.current_category = category == 0 ? this.current_category : category;

		this.activateTab();
		
		var content_div = document.getElementById( "object_list_" + this.content_id );
		if (!content_div || !content_div.innerHTML)
			return;

		content_div.innerHTML = "<img src='images/ajax-loading.gif' style='margin: 10px;' />"; 

		if ( typeof http != "undefined" ) {
			var that = this;
			
			var params = new Object(); 
			params.offset = "" + this.current_offset;
			params.num_items = this.num_items;
			params.content_id = this.content_id;
			params.target_website = this.target_website;
			params.category_id = "" + this.current_category;
						
			http( "POST" , "custom/objects/ax_objects.cfc?method=getObjects" , function( cfc_result ) { that.populateObjects(cfc_result) }, params ); 
		}

	}
	
	/*
		populateObjects
	*/
	, populateObjects: function (cfc_result) {
		var content_div = document.getElementById("object_list_" + this.content_id );
		if (!content_div || !content_div.innerHTML)
			return;
		
		content_div.innerHTML = cfc_result[0]; 		
		
		content_div = document.getElementById("ajax_navi_" + this.content_id);
		if (content_div && content_div.innerHTML) {
			content_div.innerHTML = cfc_result[1]; 
			if (cfc_result[1].length > 0)
				content_div.style.visibility = "visible";
		}
		content_div = document.getElementById("ajax_navi_" + this.content_id + "_2");
		if (content_div && content_div.innerHTML) {
			content_div.innerHTML = cfc_result[1]; 
			content_div.innerHTML += '<a class="btn-up" style="margin-top:-20px;" href="##">Seitenanfang<' + '/a>';
			if (cfc_result[1].length > 0)
				content_div.style.visibility = "visible";
		}
	}
	
	, activateTab: function() {
		var active_tab = document.getElementById("tabset_link_" + this.content_id + "_" + this.current_category);
		if (active_tab)
			active_tab.className += " active";
	}
	
	, deactivateTab: function() {
		var last_active_tab = document.getElementById("tabset_link_" + this.content_id + "_" + this.current_category);
		if (last_active_tab)
			last_active_tab.className = last_active_tab.className.replace("active", "");		
	}
	/*
		handleChange
	*/
	, handleChange: function (event) {
		if (event.path.length > 1 ) {
			var params = event.path.replace("/", "").split(",");
			if (params.length == 2) {
				this.change (parseInt(params[0]), parseInt(params[1]));
			}
		} else if (event.path.length <= 2) {
			this.change (0,this.current_category);
		}
	}
}

var object_paging = {};

