// JScript File
var popUpWindow = null;
function SwitchButton(id,state) {
    if (document.getElementById(id)) {
       var stateClass  = (state.toLowerCase() == "on")?"menuElementOver":"menuElement"
       document.getElementById(id).className = stateClass;
    }
}
function SwitchWindow(id,state) {
   if(document.getElementById(id)) {
        var stateVisibility  = (state.toLowerCase() == "on")?"block":"none";
        document.getElementById(id).style.display = stateVisibility;
   }
}

var currentPreviewUrl = null;
function ShowPreviewWindow(url,width,height) {    
    document.getElementById("PreviewWindow").style.visibility = "visible";
    document.getElementById("PWFrameHolder").innerHTML = "<iframe id='previewFrame' name='previewFrame' src='"+url+"' frameborder='no' scrolling='auto' width='"+width+"' height='"+height+"' marginheight='0' marginwidth='0'></iframe>";
    currentPreviewUrl = url;
}
function HidePreviewWindow() {
    if (!isIE) document.getElementById("PWFrameHolder").innerHTML = "";
    document.getElementById("PreviewWindow").style.visibility = "hidden";
}


var isOpera = (navigator.userAgent.toLowerCase().match("opera"))?true:false;
var isIE = (navigator.userAgent.toLowerCase().match("msie") && !isOpera)?true:false;
var isFireFox = (navigator.userAgent.toLowerCase().match("firefox"))?true:false;
function initMouseEvents() {
	document.onmousedown = mouseDown
	if (!isIE && !isOpera) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
}

var posX = 0;
var posY = 0;

function mouseDown(e) {
  posX = (!isIE && !isOpera)? e.pageX : event.x+document.body.scrollLeft
  posY = (!isIE && !isOpera)? e.pageY : event.y+document.body.scrollTop
  return true;
}

function Init() {
    initMouseEvents();
}

function LoadContactsWindow() {
    with(document.getElementById("ContactWindow")) {
        style.top = posY-200;
        style.left = posX-200;
        style.visibility = "visible";
    }
}
function UnloadContactsWindow() {
    document.getElementById("ContactWindow").style.visibility = "hidden";
}

var photoWin = null;
function ZoomPhoto(photoUrl,scrollable) {
        var params = "resizable=1,width=50,height=50,statusBar=0,scrollbars=";
        params += (scrollable)?"yes":"no";
        if (!isOpera) photoWin = window.open("PopUpPhoto.htm?img="+photoUrl,"",params);
        else photoWin = window.open(photoUrl,"","resizable=1,statusBar=0");
}

window.onload=Init;