/**
* Common javascript function.
*	Used by the index.php.
*/

//open popup....
popWin = null;
function popWindow(mypage,w,h,t,l){
    if(popWin)
    	popWin.close();
    if(!l) l = (screen.width) ? (screen.width - w) /2 : 100;
    if(!t) t = (screen.height) ? (screen.height - h) /2 : 100;
	settings='width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    popWin = window.open(mypage,'popWin',settings);
    popWin.focus();
}


function mainBut(obj,w){
 	obj.className = 'mainButton' + w;
}

/* OBSOLETE
function resizeCols(){
    if(document.getElementById('content')){
        a = new Array("left","right");
		for(i=0;i<a.length;i++){
			if(document.getElementById(a[i]).innerHTML){
				if(document.getElementById(a[i]).offsetHeight < parseInt(document.getElementById('content').offsetHeight))
					document.getElementById(a[i]).style.height = parseInt(document.getElementById('content').offsetHeight) + "px";
				else
					document.getElementById('content').style.height = parseInt(document.getElementById(a[i]).offsetHeight) + "px";
			}else{
				document.getElementById(a[i]).style.display = "none";
			}
		}
	}
}
*/

function changeHeaderPix(img){
	document.getElementById('header').style.backgroundImage = "url("+ img +")";
}

function resizeMiddle(){
    //adjust width of middle column depanding on the left and right column...
    found = 0;
    if(document.getElementById('middle')){
        a = new Array("left","right");
		for(i=0;i<a.length;i++){
			if(document.getElementById(a[i]).innerHTML)
				found++;
			else
				document.getElementById(a[i]).style.display = "none";
		}
	}
	if(found == 0){
		document.getElementById('middle').style.width = "100%";
    }else if(found == 1){
		document.getElementById('middle').style.width = "65%";
	}
}



function checkParentCls(obj,id){
	while(obj){
		if(obj && obj.id == id)
			return true;
		if(obj.parentNode)
			obj = obj.parentNode;
		else if(obj.parentElement)
			obj = obj.parentElement;
		else
			obj = null;
	}
	return false;
}

function patchColors(a){
	for(i=0;i<a.length;i++){
		if(a[i].style && checkParentCls(a[i],'content') == true)
			a[i].style.color = '';
	}
}

