
/*--------------- core -----------------*/
/*
 * Cross-browser event handling, by Scott Andrew
 */
function addEvent(element, eventType, lamdaFunction, useCapture) {
    if (element.addEventListener) {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } else if (element.attachEvent) {
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } else {
        return false;
    }
}
/*
 * Clear Default Text: functions for clearing and replacing default text in
 * <input> elements. Make sure they have a class "cleardefault"
 * (and remember you can more than one class!)
 */

addEvent(window, 'load', init, false);

function init() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];

        if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) {
            /* Add event handlers */
            addEvent(theInput, 'focus', clearDefaultText, false);
            addEvent(theInput, 'blur', replaceDefaultText, false);

            /* Save the current value */
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
}

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;

    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;

    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}

/*
	width:  expression(Math.abs((document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth)-192) + "px");
	height: expression(Math.abs((document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)-185) + "px");
*/


var isMSIE = /*@cc_on!@*/false;

function getWidth() {
	return document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;
}

function getHeight() {
	return document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
}

function center(win,width,height) {
	x=(getWidth() - width) /2;
	y=(getHeight() - height) /2;
	win.moveTo(x,y);	
}

function getCenter(width,height) {
	x=(getWidth() - width) /2;
	y=(getHeight() - height) /2;

	if (isMSIE) {	
		return 'top='+y+', left='+x;
		} else {
		return 'screenY='+y+', screenX='+x;
	}
}


function openWindow(target,w,h) {
   var tmp=window.open(target,'New',
		'directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=no,scrollbars=yes,height='+h+',width='+w+','+getCenter(w,h));
   if (!tmp) {
	   center(tmp,w,h);
   }   
   if (tmp.focus) { tmp.focus(); }
   return false;
}


function blinkWindow(target) {
   tmp=window.open(target,'New',
	'directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=no,scrollbars=yes,height=1,width=1');
   tmp.focus();
   return false;
}

function blackBox(target) {
	var w=getWidth();
	var h=getHeight();

   tmp=window.open(target,'New',
	'directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=no,scrollbars=no,height='+h+',width='+w+',0,0');
	center(tmp,w,h);
   tmp.focus();
   return false;
	
}//  from quicksmode.org
// http://www.quirksmode.org/js/xmlhttp.html

// usage: sendRequest('file.txt',handleRequest);

// function handleRequest(req) {
//        var writeroot = [some element];
//        writeroot.innerHTML = req.responseText;
//}

function sendRequest(url,callback,postData) {
        var req = createXMLHTTPObject();
        if (!req) return;
        var method = (postData) ? "POST" : "GET";
        req.open(method,url,true);
        req.setRequestHeader('User-Agent','XMLHTTP/1.0');
        if (postData)
                req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        req.onreadystatechange = function () {
                if (req.readyState != 4) return;
                if (req.status != 200 && req.status != 304) {
//                      alert('HTTP error ' + req.status);
                        return;
                }
                callback(req);
        }
        if (req.readyState == 4) return;
        req.send(postData);
}

var XMLHttpFactories = [
        function () {return new XMLHttpRequest()},
        function () {return new ActiveXObject("Msxml2.XMLHTTP")},
        function () {return new ActiveXObject("Msxml3.XMLHTTP")},
        function () {return new ActiveXObject("Microsoft.XMLHTTP")}
];

function createXMLHTTPObject() {
        var xmlhttp = false;
        for (var i=0;i<XMLHttpFactories.length;i++) {
                try {
                        xmlhttp = XMLHttpFactories[i]();
                }
                catch (e) {
                        continue;
                }
                break;
        }
        return xmlhttp;
}
function toggle(id) {
	var divID=document.getElementById(id);
	id.style.display=id.style.display=='hidden'?'block':'hidden';
}
/*--------------- menu -----------------*/

/*--------------- syndication -----------------*/

/*--------------- agenda -----------------*/

/*--------------- cal -----------------*/

/*--------------- gallery -----------------*/

/*--------------- filebase -----------------*/

/*--------------- faq -----------------*/

/*--------------- forms -----------------*/

