function isObject(ref) {
    return (ref && (typeof(ref) == 'object'));
}

function show(ref, display){
    if (!isObject(ref)){
        ref = document.getElementById(ref);
    }
    
    ref.style.display = (display==null?"":display);
    return ref.style.display;
}

function hide(ref){
    if (!isObject(ref)){
        ref = document.getElementById(ref);
    }
    
    ref.style.display = "none";
    return "none";
}

function toggle(ref, display){
    var display;
    
    if (!isObject(ref)){
        ref = document.getElementById(ref);
    }
    
    if (ref.style.display == "none"){
        return show(ref, display);
    } else {
        hide(ref);
        return "none";
    }
}

function getNextSibling(object){
	do {
	    object = object.nextSibling;
	} while (object && object.nodeType != 1);
	
	return object;
}

function getPreviousSibling(object){
	do {
	    object = object.previousSibling;
	} while (object && object.nodeType != 1);
	
	return object;
}

var openPicWindow;

function openPic(url){
	var validWindow;
    
	try{    
		//if a previous window already exists, this will work:
		openPicWindow.pic.src=url;
		openPicWindow.focus();
	} catch (e) {
		//if a preview window does not exists, create a new one and write the needed HTML
		//for some reason all this do while try catch stuff makes this work right, otherwise i sometimes get an 'Object Required' error on the OpenPicWin = self.open(''); line
		validWindow = false;
		
		do{
			try{
				openPicWindow = self.open('');
				validWindow = true;
				openPicWindow.document.write("<div style='text-align:center;vertical-align:middle;'><img id='pic' src='" + url + "' /></div>");
			} catch (e) {}
		} while (validWindow = false)
	}
}