var ns = false;

var fixedObjID = "";
var fixedObjArray = new Array();

//assoc array
var styleSwapContainer = new Array();

//numerical array
var fixedStyleSwapIDs = new Array();


	function notifyFrames()
	{
		var i, objStr;
		
		for(i = 0; i < notifyFrames.arguments.length - 1; i += 2)
		{
			objStr = 'parent.' + notifyFrames.arguments[i] ;
	
			obj = eval(objStr);
			
			obj.location.href = notifyFrames.arguments[i+1];
			
		}
	}
	
	
	
	function open_Window(url, w, h)
	{
		if( ie || ns6 )	
			win = eval("window.open(url,'','location=yes,menubar=yes,resizable=yes,toolbar=yes,height=' + h + ',width=' + w)");
		else
			win = eval("window.open(url,'','location=yes,menubar=yes,resizable=yes,toolbar=yes,height=' + h + ',width=' + w)");
	
	
		return win;
	}
	
	
	function windowOpen(path, w, h)
	{
		
		myWin = window.open(path, "ProjektDetailansicht", "width=" + w +",height=" + h + ",scrollbars=no,location=no,resizable=yes,menubar=no");
	}


	function extractFromURL(url)
	{
		//alert (document.URL);
		if ( url != null && url != "" && url.lastIndexOf('?') != -1 )
		{
			return url.substring(url.lastIndexOf('?') + 1, url.length);
		}
		else
			return null;
	}	

	
	function changeColor(id, color)
	{
		document.getElementById(id).style.color = color;		
	}
	
	
	/**
	 *
	 * changes the given style attribute (e.g. color, backgroundColor, ...)
	 * of an html element, identified by id to newVal
	 *
	 **/
	function changeStyleValByID(id, styleAttr, newVal)
	{
		var elem = document.getElementById(id);
		
		if ( elem != null )
		{
			elem.style;
			
			if ( elem.style != null )
			{
				eval("elem.style." + styleAttr + "='" + newVal + "';");
			}
		}
	}
	
	
	function fixStyleValByID(id, styleAttr)
	{
		if ( fixedStyleSwapIDs[id] == null )
		{
			fixedStyleSwapIDs[id] = new Array();
		}
						
		fixedStyleSwapIDs[id][styleAttr] = true;
	}	
	
	
	function freeFixedStyleVals()
	{
		fixedStyleSwapIDs = new Array();
	}
	
	function freeAndRestoreFixedStyleVals()
	{
		for ( id in fixedStyleSwapIDs )
		{
			swapStyleRestore(id, null);
		}
		
		fixedStyleSwapIDs = new Array();
	}
	
	
	/**
	 *
	 * changes the given style attribute (e.g. color, backgroundColor, ...)
	 * of an html element, identified by id to newVal 
	 * and stores the original value in swapArray
	 *
	 **/
	function swapStyleValByID(id, styleAttr, newVal, oldVal)
	{
		var elem = document.getElementById(id);
			
		if ( elem != null )
		{
			if ( elem.style != null )
			{
				//var oldVal = eval("elem.style." + styleAttr + ";");
				eval("elem.style." + styleAttr + "='" + newVal + "';");
				
				if ( styleSwapContainer[id] == null )
				{
					styleSwapContainer[id] = new Array();
				}
				
				styleSwapContainer[id][styleAttr] = oldVal;
			}
		}
	}
	
	
	/**
	 *
	 * Restore the style attribute for id that was 
	 * changed by swapStyleValByID
	 *
	 **/
	function swapStyleRestore(id, attr)
	{		
		//alert("swapStyleRestore: " + id);
		
		if ( attr != null && attr != '' )
		{
			var oldVal = styleSwapContainer[id][attr];			
			var elem = document.getElementById(id);
			eval("elem.style." + attr + "='" + oldVal + "';");
		}
		// restore all style attribs
		else
		{
			for ( styleAttr in styleSwapContainer[id] )
			{
				var oldVal = styleSwapContainer[id][styleAttr];
				var elem = document.getElementById(id);
				//alert("swapStyleRestore(id, attr): ID: " + id + ", styleAttr: " + styleAttr+ ", oldVal: " + oldVal);
				eval("elem.style." + styleAttr + "='" + oldVal + "';");
			}
		}
		
	}
	
	
	/**
	 *
	 * do swapStyleRestore for multiple ids
	 *
	 **/
	function swapMultipleStyleRestore(ids)
	{
		//alert("swapMultipleStyleRestore(): IDs: " + ids);
		
		for ( id in ids )
		{
			//alert("swapMultipleStyleRestore(): ID: " + id);
			swapStyleRestore(id);
		}
		
		resetFixedStyleIDs();
	}
	
	
	function getFixedStyleIDs()
	{
		//alert("getFixedStyleIDs(): " + fixedStyleSwapIDs);
		
		return fixedStyleSwapIDs;
	}
	
	function resetFixedStyleIDs()
	{
		//alert("resetFixedStyleIDs(): " + fixedStyleSwapIDs);
		
		fixedStyleSwapIDs = new Array();
	}
	
	
	function isFixedStyleID(id, attr)
	{
		if ( attr != null && attr != "" )
		{			
			if ( fixedStyleSwapIDs[id] != null )
			{
				if ( fixedStyleSwapIDs[id][attr] != null )
				{
					return true;
				}
			}		
		}
		else
		{
			if ( fixedStyleSwapIDs[id] != null )
			{
				
				return true;
			}	
		}
		
		return false;
	}
	
		
	
	function changeStyleValByID(id, styleAttr, newVal)
	{
		var elem = document.getElementById(id);
		
		if ( elem != null )
		{
			elem.style;
			
			if ( elem.style != null )
			{
				eval("elem.style." + styleAttr + "='" + newVal + "';");
			}
		}
	}
	
	
	
	function changeTextWeight(id, weight)
	{
		document.getElementById(id).style.fontWeight = weight;		
	}
	
	
	
	function fixObject(objID, name)
	{
		if ( name == "" )
		{
			name = "std";
		}
		
		fixedObjArray[name] = objID;
	}

	function isFixed(objID, name)
	{
		if ( name == "" )
		{
			name = "std";
		}
		
		if ( fixedObjArray[name] == objID )
		{
			return true;
		}		

		return false;
	}

	function getFixedObject(name)
	{
		if ( name == "" )
		{
			name = "std";
		}
		
		return fixedObjArray[name];
	}

	function freeFixedObject(name)
	{
		if ( name == "" )
		{
			name = "std";
		}
		
		fixedObjArray[name] = '';
	}

