﻿/// <reference path="jquery-1.3.1.js"/>









// ------------------------------------------------------------
// Returns the x coordinate of the specified object
// ------------------------------------------------------------
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.clientLeft) {
        curleft += obj.clientLeft;
    }
    return curleft;
}

// ------------------------------------------------------------
// Returns the y coordinate of the specified object
// ------------------------------------------------------------
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.clientTop) {
        curtop += obj.clientTop;
    }
    return curtop;
}





function hideElementIDOnMouseOut(commentid) {

    if (!e) var e = window.event;
    var tg = (window.event) ? e.srcElement : e.target;
    if (tg.nodeName != 'DIV') return;
    var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
    while (reltg != tg && reltg.nodeName != 'BODY')
        reltg = reltg.parentNode
    if (reltg == tg) return

    $('#' + commentid).hide('fast');
}

function hideElementID(commentid) {
    $('#' + commentid).hide('fast');
}


function showElementIDOnMouseOut(commentid) {
    if (!e) var e = window.event;
    var tg = (window.event) ? e.srcElement : e.target;
    if (tg.nodeName != 'DIV') return;
    var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
    while (reltg != tg && reltg.nodeName != 'BODY')
        reltg = reltg.parentNode
    if (reltg == tg) return

    $('#' + commentid).show('slow');
}

function showElementID(commentid) {
    $('#' + commentid).show('slow');
}

function slideElementID(commentid) {
    $('#' + commentid).slideDown('slow');
}




function showAlphaID(commentid) {

    $('#' + commentid).show('slow');

    if ($().ulcolumns) {
        $('.alphaonelist').ulcolumns({
            cClass: 'alphalist',
            cols: 4
        });
    }


}

//function centerpopup(url, width, height, scroll) {
//    x = screen.width;
//    y = screen.height;

//    // Get the main content area and other stuff we need
////    var contentdiv = document.getElementById('contentDiv');

////	if (contentdiv) {
////	    var contentHtml = '<div style="padding:5px; border: solid 1px; border-color:#006699; margin:20px;"><iframe src="' + url +'"/></div>';
////	    
////	    var beginHtml = 
////		      '<html>' +
////			  '<head>' +
////			  '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' + 
////			  '<link rel="stylesheet" type="text/css" href="/templates/core/Styles/all.css">' +
////			  '<title>Janusinfo</title>' +
////			  '<style>.NoPrint{display:none;}</style>' +
////			  '</head>';

////		var endHtml = '</body></html>';

////		var printWin = window.open(url + '?popup=true', "dummy", "top=" + parseInt(y / 2 - height / 2 - 16) + ",left=" + parseInt(x / 2 - width / 2 - 5) + ",width=" + width + ",height=" + height + ", scrollbars=" + scroll);
////		//var printWin = window.open(url+'?popup=true' ', 'width=700,height=600,scrollbars=yes,toolbar=yes');
////	    printWin.document.open();
////	    printWin.document.write(beginHtml + contentHtml + endHtml);
//	}
//}

function centerpopup(url, width, height, scroll) {
    x = screen.width;
    y = screen.height;

    window.open(url + '&image=true&popup=true', "dummy", "top=" + parseInt(y / 2 - height / 2 - 16) + ",left=" + parseInt(x / 2 - width / 2 - 5) + ",width=" + width + ",height=" + height + ", scrollbars=" + scroll);
}

function popup(id, width, height) {
    var arr = new Array(3);
    arr[0] = id;
    arr[1] = width;
    arr[2] = height;

    SetDateForTabb(arr.join('$'));
}

/* 

Blankwin function 
written by Alen Grakalic, provided by Css Globe (cssglobe.com)
please visit http://cssglobe.com/post/1281/open-external-links-in-new-window-automatically/ for more info
	
*/

this.blankwin = function() {
    var hostname = window.location.hostname;
    hostname = hostname.replace("www.", "").toLowerCase();
    var a = document.getElementsByTagName("a");
    this.check = function(obj) {
        var href = obj.href.toLowerCase();
        return (href.indexOf("http://") != -1 && href.indexOf(hostname) == -1) ? true : false;
    };
    this.set = function(obj) {
        obj.target = "_blank";
        obj.className = "external";
    };
    for (var i = 0; i < a.length; i++) {
        if (check(a[i])) set(a[i]);
    };
};



// script initiates on page load. 

this.addEvent = function(obj, type, fn) {
    if (obj.attachEvent) {
        obj['e' + type + fn] = fn;
        obj[type + fn] = function() { obj['e' + type + fn](window.event); }
        obj.attachEvent('on' + type, obj[type + fn]);
    } else {
        obj.addEventListener(type, fn, false);
    };
};
addEvent(window, "load", blankwin);

function SetDateForTabb_Callback(retVal) {
    var openwindow = retVal.split("$")

    window.open(openwindow[0] + "?popup=true", "", "'resizable=0, width=" + openwindow[1] + ", height=" + openwindow[2] + "'" ,""); 
}