//-------------------------------
// NEWWINDOW
//-------------------------------
function NewWindow(mypage,myname,w,h,scroll,pos,resize,menu){			  

	if(pos=="random"){							  		 
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}

	if(pos=="center"){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
		if (TopPosition>30){
			TopPosition=TopPosition-30;
		}
	}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=screen.width-w-20;TopPosition=30;}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location='+menu+',directories='+menu+',status='+menu+',menubar='+menu+',toolbar='+menu+',resizable='+resize+'';
	var hdl = window.open(mypage,myname,settings);
	hdl.window.focus();
}

//-------------------------------
// SHOWIMAGE
//-------------------------------
function showImage(key){
	NewWindow('p_photo.php?key='+key,'wnd_photo',599,399,'no','center','no','no')
}

//-------------------------------
// DOPRINT
//-------------------------------
function doPrint(){
   NewWindow('p_print.php','wnd_print',635,430,'yes','center','no','no');
}

//-------------------------------
// DOPOPUP
//-------------------------------
function doPopup(page){
   NewWindow(page,'wnd_popup',635,430,'yes','center','no','no');
}

//-------------------------------
// DOLOGIN
//-------------------------------
function doLoginWnd(str){
   NewWindow('p_login.php?goto='+str,'wnd_login',349,249,'no','center','no','no');
}


//-------------------------------
// FINDPOSX
//-------------------------------
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

//-------------------------------
// FINDPOSY
//-------------------------------
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

//-------------------------------
// GETPOSX
//-------------------------------
function getPosX(id)
{
	var el = document.getElementById(id);	
	return findPosX(el);
}

//-------------------------------
// GETPOSY
//-------------------------------
function getPosY(id)
{
	var el = document.getElementById(id);	
	return findPosY(el);
}

//-------------------------------
// TOGGLEBOX
//-------------------------------
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
	if(document.getElementById)	  //gecko(NN6) + IE 5+
	{
		var obj = document.getElementById(szDivID);
		if (obj!=null){
			obj.style.display = iState ? "block" : "none";
		}		
	}	
}

//-------------------------------
// GETCHILDS
//-------------------------------
function getChilds(el){
    var kids = el.childNodes;   // Get the list of children
    var numkids = kids.length;  // Figure out how many children there are
    for(var i = numkids-1; i >= 0; i--) {  // Loop backward through the children
        
    }
}
