var isCSS, isW3C, isIE6, IE;
var SAFIX;

function initbrowserdet() {
	isCSS=(document.body && document.body.style) ? true : false;
	isW3C=(isCSS && document.getElementById) ? true : false;
	isIE6=(document.compatMode && document.compatMode.indexOf("CSS1")>=0) ? true : false;
	SAFIX = (isIE6) ? "px" : "";
	IE = (navigator.userAgent && navigator.userAgent.indexOf("MSIE ")!=-1) ? parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE ")+5, navigator.userAgent.indexOf(";", navigator.userAgent.indexOf("MSIE ")))) : false;
}

document.onclick=onclickO;

function getOBJ(obj) {
	var retOBJ;
	if(typeof obj=="string") {
		if(isW3C) retOBJ=document.getElementById(obj);
	} else retOBJ=obj;
	return retOBJ;	
}

function getOBJstyle(obj) {
	var retOBJ=getOBJ(obj);
	if(retOBJ && isCSS) retOBJ=retOBJ.style;
	return retOBJ;
}

function getEvent(evt) {
	return (evt) ? evt : ((event) ? event : null);
}

function getSrcElem(evt)
{
	evt = getEvent(evt);
	var sl = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	return sl;
}

function getToElem(evt)
{
	evt = getEvent(evt);
	var sl = (evt.relatedTarget) ? evt.relatedTarget : ((evt.toElement) ? evt.toElement : null);
	return sl;
}

/////////////////POSITION///////////////////////////////
// Set the z-order of an object
function setZIndex(o, zo) {
    getOBJstyle(o).zIndex = zo;
}

// Get the z-order of an object
function getZIndex(o) {
	o = getOBJ(o);
	do {
    	if(o.style.zIndex || o.style.zIndex===0) return o.style.zIndex;
    	o = o.parentNode;
    } while (o && o.nodeName!='html')
    return 0;
}

// Get window scroll factors
function getScrollXY(){
	var scroll = {X:0, Y:0};
	if (document.body && typeof document.body.scrollTop != "undefined") {
		scroll.X += document.body.scrollLeft;
        scroll.Y += document.body.scrollTop;
        if (document.body.parentNode && 
            typeof document.body.parentNode.scrollTop != "undefined") {
            scroll.X += document.body.parentNode.scrollLeft;
            scroll.Y += document.body.parentNode.scrollTop
        }
    } else if (typeof window.pageXOffset != "undefined") {
        scroll.X += window.pageXOffset;
        scroll.Y += window.pageYOffset;
    }
    return scroll;
}

// Position an object at a specific pixel coordinate
function shiftOBJ(obj, xi, yi, ri) {//alert(xi);
	var theObj = getOBJstyle(obj);
    if (theObj) {
        if (isCSS) {
            // equalize incorrect numeric value type
            var units = (typeof theObj.left == "string") ? "px" : 0;
            if(xi || xi===0) theObj.left = xi + units;
            if(yi || yi===0) theObj.top = yi + units;
            if(ri || ri===0) theObj.right = ri + units;
        }
    }
}

// Position an object in the center of the browser win
function centerOBJ(e, wi, he, offx) {
	var obj = getOBJ(e);
	var scroll = getScrollXY();
	if(!wi) wi = getOWidth(obj);
	if(!he) he = getOHeight(obj);
	offx = (offx) ? 1+(2*offx/100) : 1;
	var xi = Math.round((getInsideWWidth()*offx/2)-(wi/2)) + scroll.X;
	var yi = Math.round((getInsideWHeight()/2)-(he/2)) + scroll.Y;
	shiftOBJ(obj, xi, yi);
}
// Retrieve the rendered top of an element
function getOTop(o)  {
    var e = getOBJ(o);
    var r = 0;
    if (document.defaultView) {
		var s = document.defaultView;
		var c = s.getComputedStyle(e, "");
		r = c.getPropertyValue("top");
    } else if (e.currentStyle) r = e.currentStyle.top;
    else if (e.style) r = e.style.top;
    else r = e.top;
    return parseInt(r);
}
// Retrieve the rendered left of an element
function getOLeft(o)  {
    var e = getOBJ(o);
    var r = 0;
    if (document.defaultView) {
		var s = document.defaultView;
		var c = s.getComputedStyle(e, "");
		r = c.getPropertyValue("left");
    } else if (e.currentStyle) r = e.currentStyle.left;
    else if (e.style) r = e.style.left;
    else r = e.left;
    return parseInt(r);
}
// Retrieve the rendered right of an element
function getORight(o)  {
    var e = getOBJ(o);
    var r = 0;
    if (document.defaultView) {
		var s = document.defaultView;
		var c = s.getComputedStyle(e, "");
		r = c.getPropertyValue("right");
    } else if (e.currentStyle) r = e.currentStyle.right;
    else if (e.style) r = e.style.right;
    else r = e.right;
    return parseInt(r);
}
// Retrieve the rendered width of an element
function getOWidth(o)  {
    var elem = getOBJ(o);
    var result = 0;
    if (elem.offsetWidth) {
//        if (elem.scrollWidth && (elem.offsetWidth != elem.scrollWidth)) {
//            result = elem.scrollWidth;
//        } else {
            result = elem.offsetWidth;
//        }
    } else if (elem.clip && elem.clip.width) {
        result = elem.clip.width;
    } else if (elem.style && elem.style.pixelWidth) {
        result = elem.style.pixelWidth;
    }
    return parseInt(result);
}

// Retrieve the rendered height of an element
function getOHeight(obj)  {
    var elem = getOBJ(obj);
    var result = 0;
    if (elem.offsetHeight) {
        result = elem.offsetHeight;
    } else if (elem.clip && elem.clip.height) {
        result = elem.clip.height;
    } else if (elem.style && elem.style.pixelHeight) {
        result = elem.style.pixelHeight;
    }
    return parseInt(result);
}

// Return the available content width space in browser window
function getInsideWWidth() {
    if (window.innerWidth) {
        return window.innerWidth;
    } else if (isIE6) {
        return document.body.parentElement.clientWidth;
    } else if (document.body && document.body.clientWidth) {
        return document.body.clientWidth;
    }
    return 0;
}
// Return the available content height space in browser window
function getInsideWHeight() {
    if (window.innerHeight) {
        return window.innerHeight;
    } else if (isIE6) {
        return document.body.parentElement.clientHeight;
    } else if (document.body && document.body.clientHeight) {
        return document.body.clientHeight;
    }
    return 0;
} 
function equalNV(objS)
{
	return (typeof objS.left=="string") ? "px" : 0;
}

function onclickO(event) {
	if(getSrcElem(event).blur) {
		var s = getSrcElem(event);
		if(s.type && s.type!="text" && s.type!="textarea" && s.type!="password" && s.type!="select-one") s.blur();
	}
}

function sm(o, a) {
	o.href = (a) ? "mailto:webmaster@paxos-sunrises.com" : "mailto:contact@paxos-sunrises.com";
}

var _Inheritance = function(p, c) {var prop;for(prop in p) if(!c[prop]) c[prop] = p[prop];};
