/* Cross Browser DOM
 * copyright Stephen Chapman, 4th Jan 2005
 * you may copy this code but please keep the copyright notice as well
 * 
 * Changes made by: oliver@maklott.com
 * Last Changes: 2009 01 09
*/

/* ---------------------- Definitions ----------------------*/
var aDOM = 0, ieDOM = 0, nsDOM = 0;
var stdDOM = document.getElementById;

var siteHeight = 0.75;

/* ---------------------- DOM Setup ----------------------*/
if (stdDOM)
	{ aDOM = 1; }
else
{
	ieDOM = document.all;
	if (ieDOM)
		{ aDOM = 1; }
	else
	{
		var nsDOM = ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) ==4));
		if (nsDOM) { aDOM = 1; }
	}
}

/* ---------------------- DOM Methods ----------------------*/
function xDOM(objectId, wS)
{
	try
	{
		var elem = null;
		
		if (stdDOM)
		{
			elem = document.getElementById(objectId);
			if (elem == null) return null;
			return wS ? elem.style : elem;
		}
		if (ieDOM)
		{
			elem = document.all[objectId];
			if (elem == null) return null;
			return wS ? elem.style : elem;
		}
		if (nsDOM)
		{
			elem = document.layers[objectId];
			if (elem == null) return null;
			return document.layers[objectId];
		}
		return null;
	}
	catch(e)
	{
		return null;
	}
}

/* Get Content of an iFrame
 * found: http://roneiv.wordpress.com/2008/01/18/get-the-content-of-an-iframe-in-javascript-crossbrowser-solution-for-both-ie-and-firefox/
 * modified: 2009 04 19 by Oliver Maklott, office@maklott.com
*/
function getIFrameDocument(iFrameName)
{
	if (iFrameName)
	{
		var myIFrame = document.getElementById(iFrameName);
		return myIFrame.contentWindow.document;
	}
	else
	{
		return null;
	}
}
function getIFrameContent(iFrameName)
{
	//var myIFrame = document.getElementById(iFrameName);
	//var content = myIFrame.contentWindow.document.body.innerHTML;
	
	var myIFrame = getIFrameDocument(iFrameName);
	var content = myIFrame.body.innerHTML;
	
	//Do whatever you need with the content
	
}


/* Browser Window Size and Position
 * copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
 * you may copy this code but please keep the copyright notice as well
 * 
 * Changes made by: oliver@maklott.com
 * Last Changes: 2009 01 09
*/
function pageWidth()
{
	return (window.innerWidth != null) ? 
				window.innerWidth : 
				(document.documentElement && document.documentElement.clientWidth) ? 
					document.documentElement.clientWidth : 
					(document.body != null) ? 
						document.body.clientWidth : 
						null;
}

function pageHeight()
{
	return (window.innerHeight != null) ? 
				window.innerHeight : 
				(document.documentElement && document.documentElement.clientHeight) ? 
					document.documentElement.clientHeight : 
					(document.body != null) ? 
						document.body.clientHeight : null;
}

function posLeft()
{
	return (typeof window.pageXOffset != 'undefined') ? 
				window.pageXOffset : 
				(document.documentElement && document.documentElement.scrollLeft) ? 
					document.documentElement.scrollLeft : 
					document.body.scrollLeft ? 
						document.body.scrollLeft : 
						0;
}

function posTop()
{
	return (typeof window.pageYOffset != 'undefined') ? 
				window.pageYOffset : 
				(document.documentElement && document.documentElement.scrollTop) ? 
					document.documentElement.scrollTop : 
					document.body.scrollTop ? 
						document.body.scrollTop : 
						0;
}

function posRight()
	{ return posLeft() + pageWidth(); }

function posBottom()
	{ return posTop() + pageHeight(); }
                    

/* Object Functions
 * copyright Stephen Chapman, 4th Jan 2005
 * you may copy this code but please keep the copyright notice as well
 * 
 * Changes made by: oliver@maklott.com
 * Last Changes: 2009 01 09
*/
function objWidth(objectID)
{
	var obj = xDOM(objectID, 0);
	
	if(obj == null) return 0;
	if(obj.offsetWidth)
		{ return  obj.offsetWidth; }
	if (obj.clip)
		{ return obj.clip.width; }
	return 0;
}

function objHeight(objectID)
{
	var obj = xDOM(objectID, 0);
	
	if(obj == null) return 0;
	if(obj.offsetHeight)
		{ return obj.offsetHeight; }
	if (obj.clip)
		{ return obj.clip.height; }
	return 0;
}

function objLeft(objectID)
{
	var obj = xDOM(objectID, 0);
	var objs = xDOM(objectID, 1);
	
	if(obj == null) return 0;
	if (obj.offsetLeft)
		{ return obj.offsetLeft; }
	if(objs.left)
		{ return objs.left; }
	if (objs.pixelLeft)
		{ return objs.pixelLeft; }
	return 0;
}

function objTop(objectID)
{
	var obj = xDOM(objectID, 0);
	var objs = xDOM(objectID, 1);
	
	if(obj == null) return 0;
	if (obj.offsetTop)
		{ return obj.offsetTop; }
	if(objs.top)
		{ return objs.top; }
	if (objs.pixelTop)
		{ return objs.pixelTop; }
	return 0;
}

function objRight(objectID)
	{ return objLeft(objectID) + objWidth(objectID); }

function objBottom(objectID)
	{ return objTop(objectID) + objHeight(objectID); }

function objLayer(objectID)
{
	var objs = xDOM(objectID, 1);
	
	if(objs == null) return 0;
	if(objs.zIndex)
		{ return objs.zIndex; }
	return 0;
}

function objVisible(objectID)
{
	var objs = xDOM(objectID, 1);
	
	if(objs == null) return 'visible';
	if(objs.visibility == 'hide' || objs.visibility == 'hidden')
		{ return 'hidden'; }
	return 'visible';
}


/* More Object Functions
 * copyright Stephen Chapman, 18th Jan 2005
 * you may copy this code but please keep the copyright notice as well
 * 
 * Changes made by: oliver@maklott.com
 * Last Changes: 2009 01 09
*/
function setObjVis(objectID, vis)
{
	var objs = xDOM(objectID, 1);
	
	if (objs == null) return;
	objs.visibility = (vis == "visible" || vis == "show") ? 'visible' : 'hidden';
}

function toggleObjVis(objectID)
{
	var vis = 'visible';
	var objs = xDOM(objectID, 1);
	
	if (objs == null) return;
	vis = objs.visibility;
	objs.visibility = (vis == "visible" || vis == "show") ? 'hidden' : 'visible';
}

function moveObjTo(objectID, x, y)
{
	var objs = xDOM(objectID, 1);
	
	if (objs == null) return;
	objs.left = x;
	objs.top = y;
}

function moveObjBy(objectID, x, y)
{
	var obj = xDOM(objectID, 0);
	var objs = xDOM(objectID, 1);
	
	if (obj == null) return;
	if (obj.offsetLeft != null)
	{
		var l = obj.offsetLeft;
		var t = obj.offsetTop;
		
		objs.left = l + x;
		objs.top = t + y;
	}
	else if (obj.pixelLeft != null)
	{
		objs.pixelLeft += x;
		objs.pixelTop += y;
	}
	else 
	{
		obj.moveBy(x, y);
	}
}
function moveObjLayer(objectID, z)
{
	var objs = xDOM(objectID, 1);
	
	if (objs == null) return;
	objs.zIndex = z;
}

function setObjWidth(objectID, w)
{
	var obj = xDOM(objectID, 0);
	var objs = xDOM(objectID, 1);
	
	if (obj == null) return;
	if(obj.offsetWidth)
	{
		objs.width = w;
		obj.offsetWidth = w;
	}
	if (obj.clip)
	{
		objs.clip.width = w;
	}
}
function setWidth (elemID, width)
{
	var objs = xDOM(elemID, 1);
	if (objs == null) return;
	objs.width = width;
}

function setObjHeight(objectID, h)
{
	var obj = xDOM(objectID, 0);
	var objs = xDOM(objectID, 1);
	
	if (obj == null) return;
	if(obj.offsetHeight)
	{
		objs.height = h;
		obj.offsetHeight = h;
	}
	if (obj.clip)
	{
		objs.clip.height = h;
	}
}
function setHeight (elemID, height)
{
	var objs = xDOM(elemID, 1);
	if (objs == null) return;
	objs.height = height;
}


//alert("setObjHeight ... \n    obj: " + obj);


/* MCOM Site Modification Functions
 * -----------------------------------------------------------------------------
 * This program is free software; you can redistribute it and/or modify it under 
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 3 of the License, or (at your option) any later version.
 * 
 * This program is distributed AS IS in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * -----------------------------------------------------------------------------
 * Changes made by: oliver@maklott.com
 * Last Changes: 2009 01 09
*/
/*function setupSite()
{
	createPlayer();
	fitSiteHeight();
	
	window.onresize = fitSiteHeight;
}
function setupSubContentContainer()
{
	writeStringToHTMLElement('subContentTitle',activeType);
	writeGroupToHTMLElement('year');
	writeGroupToHTMLElement('album');
	writeGroupToHTMLElement('author');
	writeGroupToHTMLElement('genre');
	writeGroupToHTMLElement('tag');
	fitContentHeight();
	
	window.onresize = fitContentHeight;
	
	
	parent.jshistory.setID('subContentFiltered_frame');
	parent.jshistory.setTarget(jshistory);
}

function fitSiteHeight()
{
	var content_height = 0;
	var shadow_height = 0;
	
	if (navigator.appName.search(/Opera/i) == 0)
	{
		content_height = pageHeight() * siteHeight;
		shadow_height = content_height - 90; // 55px -> Top Part | 35px -> Bottom Part
		
		setHeight('siteContent_cell', content_height);
		setHeight('siteContent_frame', content_height);
		
		setHeight('siteShadowConstruct_left_middle_div', shadow_height);
		setHeight('siteShadowConstruct_right_middle_div', shadow_height);
	}
}
function fitContentHeight()
{
	//alert("fitContentHeight ... \n    pageHeight: " + pageHeight() + "\n    subContentTitle Height: " + objHeight('subContentTitle') + "\n    query_dataVisContainer Height: " + objHeight('query_dataVisContainer'));
	
	var page_height = pageHeight();
	var content_height = page_height - objHeight('subContentTitle') - objHeight('query_dataVisContainer') - 4;
	
	setHeight('subContentConstruct_cell', page_height);
	setHeight('subContentConstruct_div', page_height);
	
	setHeight('subNavigation_cell', page_height);
	setHeight('subNavigation_div', page_height);
	
	setHeight('subContentFiltered_frame', content_height);
}
*/