﻿<!--  

/* -- Browser Detection -- */
var WIN = navigator.userAgent.indexOf("Win") != -1; 
var MAC = navigator.userAgent.indexOf("Mac") != -1; 
var LIN = navigator.userAgent.indexOf("Lin") != -1; 
var M2 = (navigator.userAgent.indexOf("Mozilla/2") != -1); 
var M3 = (navigator.userAgent.indexOf("Mozilla/3") != -1); 
var M4 = (navigator.userAgent.indexOf("Mozilla/4") != -1); 
var M5 = (navigator.userAgent.indexOf("Mozilla/5") != -1); 
var OP = (navigator.userAgent.indexOf("Opera") != -1); 
var OP3 = (navigator.userAgent.indexOf("Opera/3") != -1) && M3; 
var OP35 = (navigator.userAgent.indexOf("Opera/3") != -1) && M4; 
var OP36 = (navigator.userAgent.indexOf("Opera 3") != -1) && M4; 
var OP4 = (navigator.userAgent.indexOf("Opera 4") != -1) || (navigator.userAgent.indexOf("Opera/4") != -1); 
var OP5 = (navigator.userAgent.indexOf("Opera 5") != -1) || (navigator.userAgent.indexOf("Opera/5") != -1); 
var OP6 = (navigator.userAgent.indexOf("Opera 6") != -1) || (navigator.userAgent.indexOf("Opera/6") != -1); 
var OP7 = (navigator.userAgent.indexOf("Opera 7") != -1) || (navigator.userAgent.indexOf("Opera/7") != -1); 
var IE = (navigator.userAgent.indexOf("MSIE") != -1) && !OP; 
var IE3 = (navigator.userAgent.indexOf("MSIE 3") != -1); 
var IE4 = (navigator.userAgent.indexOf("MSIE 4") != -1); 
var IE50 = (navigator.userAgent.indexOf("MSIE 5.0") != -1) && !OP; 
var IE55 = (navigator.userAgent.indexOf("MSIE 5.5") != -1) && !OP; 
var IE60 = (navigator.userAgent.indexOf("MSIE 6.0") != -1) && !OP; 
var NN = (navigator.appName == "Netscape") && !OP; 
var NN2 = (navigator.appName == "Netscape") && M2 && !OP; 
var NN3 = (navigator.appName == "Netscape") && M3 && !OP; 
var NN4 = (navigator.appName == "Netscape") && M4 && !OP;
var ns4 = document.all?false:true

//var IE = document.all?true:false
//var op5 = false;
/* -- End Browser Detection --  */

function ShowComments(postID){
    var comments = getElement(postID);
    
    if ((comments != null)){
        comments.style.display = "block";
    }
}

function HideComments(postID){
    var comments = getElement(postID);
    
    if ((comments != null)){
        comments.style.display = "none";
    }
}

function toggleComments(postID){
    var comments = getElement(postID);
    
    if ((comments != null)){
        if ((comments.style.display == "none") || (comments.style.display == "")){
            comments.style.display = "block";
        }else{
            comments.style.display = "none";
        }
    }
}

function toogleScrollbars(hide)
{
    if(hide)
    {
        document.documentElement.style.overflow = "hidden";
    }else{
        //document.body.style.overflow = "scroll";
        document.documentElement.style.overflow = "auto";
        document.body.style.marginRight='0px';
    }
}

function ClearWaterMark(strWaterMark, textBox) {
    if (textBox.value == strWaterMark) {
        textBox.value = '';
    }
}

function SetWaterMark(strWaterMark, textBox) {
    if (textBox.value == '') {
        textBox.value = strWaterMark;
    }
}

function getElementHeight(Elem) {
    if (ns4) {
        var elem = getObjNN4(document, Elem);
        return elem.clip.height;
    } else {
        if(document.getElementById) {
            var elem = document.getElementById(Elem);
        } else if (document.all){
            var elem = document.all[Elem];
        }
        if (op5) { 
            xPos = elem.style.pixelHeight;
        } else {
            xPos = elem.offsetHeight;
        }
        return xPos;
    } 
}

function getElementWidth(Elem) {
    if (ns4) {
        var elem = getObjNN4(document, Elem);
        return elem.clip.width;
    } else {
        if(document.getElementById) {
            var elem = document.getElementById(Elem);
        } else if (document.all){
            var elem = document.all[Elem];
        }
        if (op5) {
            xPos = elem.style.pixelWidth;
        } else {
            xPos = elem.offsetWidth;
        }
        return xPos;
    }
}

function getElementLeft(Elem) {
    if (ns4) {
        var elem = getObjNN4(document, Elem);
        return elem.pageX;
    } else {
        var elem;
        if(document.getElementById) {
            var elem = document.getElementById(Elem);
        } else if (document.all){
            var elem = document.all[Elem];
        }
        xPos = elem.offsetLeft;
        tempEl = elem.offsetParent;
        while (tempEl != null) {
            xPos += tempEl.offsetLeft;
            tempEl = tempEl.offsetParent;
        }
        return xPos;
    }
}

function getElementTop(Elem) {
    if (ns4) {
        var elem = getObjNN4(document, Elem);
        return elem.pageY;
    } else {
        if(document.getElementById) {	
            var elem = document.getElementById(Elem);
        } else if (document.all) {
            var elem = document.all[Elem];
        }
        yPos = elem.offsetTop;
        tempEl = elem.offsetParent;
        while (tempEl != null) {
            yPos += tempEl.offsetTop;
            tempEl = tempEl.offsetParent;
        }
        return yPos;
    }
}

function getObjNN4(obj,name)
{
    var x = obj.layers;
    var foundLayer;
    for (var i=0;i<x.length;i++)
    {
        if (x[i].id == name)
 	        foundLayer = x[i];
        else if (x[i].layers.length)
	        var tmp = getObjNN4(x[i],name);
        if (tmp) foundLayer = tmp;
    }
    return foundLayer;
}

function getElement(name){
    //if (ns4) {
    //    return getObjNN4(document, name);
    //} else {
        var elem;
        if(document.getElementById) {
            var elem = document.getElementById(name);
        } else if (document.all){
            var elem = document.all[name];
        }
        return elem;
    //}
}

window.size = function()
{
	var w = 0;
	var h = 0;

	//IE
	if(!window.innerWidth)
	{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};
}





function OpenNewWindow(url, name, width, height, resizable, scrollbars, toolbar, location, directories, status, menubar, copyhistory, replace) {
                
    var strAttrib = '';

    if (width != null) { if (strAttrib == '') { strAttrib += 'width=' + width; } else { strAttrib += ',width=' + width; } }
    if (height != null) { if (strAttrib == '') { strAttrib += 'height=' + height; } else { strAttrib += 'height=' + height; } }
    if (resizable != null) { if (strAttrib == '') { strAttrib += 'resizable=' + resizable; } else { strAttrib += ',resizable=' + resizable; } }
    if (scrollbars != null) { if (strAttrib == '') { strAttrib += 'scrollbars=' + scrollbars; } else { strAttrib += ',scrollbars=' + scrollbars; } }
    if (toolbar != null) { if (strAttrib == '') { strAttrib += 'toolbar=' + toolbar; } else { strAttrib += ',toolbar=' + toolbar; } }
    if (location != null) { if (strAttrib == '') { strAttrib += 'location=' + location; } else { strAttrib += ',location=' + location; } }
    if (directories != null) { if (strAttrib == '') { strAttrib += 'directories=' + directories; } else { strAttrib += ',directories=' + directories; } }
    if (status != null) { if (strAttrib == '') { strAttrib += 'status=' + status; } else { strAttrib += ',status=' + status; } }
    if (menubar != null) { if (strAttrib == '') { strAttrib += 'menubar=' + menubar; } else { strAttrib += ',menubar=' + menubar; } }
    if (copyhistory != null) { if (strAttrib == '') { strAttrib += 'copyhistory=' + copyhistory; } else { strAttrib += ',copyhistory' + copyhistory; } }
    
    window.open(url, name, strAttrib, replace)
}

function ResizePopup() {
    var popup = getElement(currPopupID);

    if (popup != null) {
        popup.style.width = window.size().width + 'px';
        popup.style.height = window.size().height + 'px';
    }
    return true;
};

function TogglePopup(popupName){
    var popup = getElement(popupName);
    currPopupID = popupName;
    
    if (popup != null) {
        if ((popup.style.display == 'none') || (popup.style.display == '')){
            //Show the popup
            popup.style.zIndex += 200;
            toogleScrollbars(true);
            ResizePopup();
            try{popup.style.display = 'table-cell';}catch(e){popup.style.display = 'block';}
            addEvent(window, 'resize', ResizePopup);
        }else{
            //Hide the popup
            removeEvent(window, 'onresize', ResizePopup);
            popup.style.display = 'none';
            toogleScrollbars(false);
        }
    }
}

function addEvent(element, type, handler) {
    if (element.addEventListener) {
        element.addEventListener(type, handler, false);
    } else {
        // assign each event handler a unique ID
        if (!handler.$$guid) handler.$$guid = addEvent.guid++;
        // create a hash table of event types for the element
        if (!element.events) element.events = {};
        // create a hash table of event handlers for each element/event pair
        var handlers = element.events[type];
        if (!handlers) {
            handlers = element.events[type] = {};
            // store the existing event handler (if there is one)
            if (element["on" + type]) {
                handlers[0] = element["on" + type];
            }
        }
        // store the event handler in the hash table
        handlers[handler.$$guid] = handler;
        // assign a global event handler to do all the work
        element["on" + type] = handleEvent;
    }
};
// a counter used to create unique IDs
addEvent.guid = 1;

function removeEvent(element, type, handler) {
    if (element.removeEventListener) {
        element.removeEventListener(type, handler, false);
    } else {
        // delete the event handler from the hash table
        if (element.events && element.events[type]) {
            delete element.events[type][handler.$$guid];
        }
    }
};

function handleEvent(event) {
    var returnValue = true;
    // grab the event object (IE uses a global event object)
    event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
    // get a reference to the hash table of event handlers
    var handlers = this.events[event.type];
    // execute each event handler
    for (var i in handlers) {
        this.$$handleEvent = handlers[i];
        if (this.$$handleEvent(event) === false) {
            returnValue = false;
        }
    }
    return returnValue;
};

function fixEvent(event) {
    // add W3C standard event methods
    event.preventDefault = fixEvent.preventDefault;
    event.stopPropagation = fixEvent.stopPropagation;
    return event;
};
fixEvent.preventDefault = function() {
    this.returnValue = false;
};
fixEvent.stopPropagation = function() {
    this.cancelBubble = true;
};

var currPopupID = '';

/* AJax Loading Screen */
function toggleLoading(){
    var Loader = getElement('ajaxLoading');
    
    //alert(Loader != null);
    
    if (Loader != null){
        if ((Loader.style.display == 'none') || (Loader.style.display == '')){
            //show loading screen
            Loader.style.display = 'block';
            toogleScrollbars(true);
            Loader.style.width = window.size().width + 'px';
            Loader.style.height = window.size().height + 'px';
        }else{
            // show data, and not loading screen
            Loader.style.display = 'none';
            toogleScrollbars(false);
        }
    }
}

function Refreshed(){
    try{toggleLoading();}catch(e){}
    try{dp.SyntaxHighlighter.HighlightAll('code');}catch(e){}
}

function MagnafyImage(src){
    var win = window.open('about:blank', 'mag', '', true); //window.open('_blank','image mag', null, true);
    win.document.write('<img src="' + src + '" />');
    win.focus();
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
//-->
