// -------------------------------------------------------
// changes the style of the active link in the top menu
// -------------------------------------------------------
function setActive () {

	var strHref = window.location.href;
	var strParamName='tab'
	var strReturn='';

  	if ( strHref.indexOf("?") > -1 ){
    		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    		var aQueryString = strQueryString.split("&");
    
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      			if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        			var aParam = aQueryString[iParam].split("=");
        			strReturn = aParam[1];
        			break;
      			}
    	}
  	}
	
  	if (strReturn == '') {
		strReturn = 'one'
	}
	
	if (strReturn.indexOf("#")>-1) {
		strReturn=strReturn.replace("#","");
	}
	
	var el = document.getElementById(strReturn);

	if (el==null)
		el = document.getElementById('one');
	
	el.src = 'images/menu/'+strReturn+'_red.gif';
}

// ------------------------------------------------
// SET LOGO IMAGE
// ------------------------------------------------

function setLogoImage (imageSrc, containerId) {
	var container = $(containerId);
	if (container) {
		container.setAttribute('src',imageSrc);
	}
}

// ------------------------------------------------
// CHANGE IMAGE SRC ON SELECTED CONTAINER
// ------------------------------------------------

function showImage (imageSrc, containerId) {
	var container = $(containerId);

	if (container) {
		im=getFirstchild(container);
		im.setAttribute('src',imageSrc);
	}
}


// ------------------------------------------------
// CHANGE TEXT FOR CURRENT WORK
// ------------------------------------------------
function showText(parentEl, el) {
	arr = $(parentEl).immediateDescendants();
	for (i=0;i<arr.length;i++) {
		if(arr[i].className=='worksText' && arr[i].id!=el){
			arr[i].style.display="none";
		}
		else if (arr[i].className=='worksText' && arr[i].id==el){
			arr[i].style.display="block";
			
		}
	} 
}



// ------------------------------------------------
// SET ACTIVE LINK NEW
// ------------------------------------------------
function setActiveLink (el, parentEl, reqClass) {
	arr = $(parentEl).immediateDescendants();
	
	for (i=0;i<arr.length;i++) {
		if(arr[i].tagName=='A' && arr[i].id==el){
			arr[i].addClassName(reqClass)		
		}
		else if (arr[i].tagName=='A' && arr[i].id!=el){
			arr[i].removeClassName(reqClass);
		}
	} 
}

// ------------------------------------------------
// swap class of layers
// ------------------------------------------------

function swapLayers(showClass, containerId) {
	var container = $(containerId);

	if (container.getAttribute("className"))
		currentClass = container.getAttribute("className");
	else
		currentClass = container.getAttribute("class");
		
	container.removeClassName(currentClass);
	container.addClassName(showClass);
}

// ------------------------------------------------
// hide/show layers of parent
// ------------------------------------------------
function hideShow (el, parentEl) {
	arr = $(parentEl).immediateDescendants();
	for (i=0;i<arr.length;i++) {
		arr[i].setStyle({display:'none'});
	}
	$(el).setStyle({display:'block'}); 
	
}


// ------------------------------------------------
//help functions for handling the DOM in mozilla
// ------------------------------------------------

function isIgnorable (nod) {
  	return !(/[^\t\n\r ]/.test(nod.data));
}


function getFirstchild (par) {
 	var res=par.firstChild;
	while (res) {
    		if (!isIgnorable(res)) return res;
    		res = res.nextSibling;
  	}
  	return null;
}


