// JavaScript Document

//// HTTP Request objects
function getNewRequestObject()
{
    var http = null;

	try{
		http=new ActiveXObject("Msxml2.XMLHTTP")
	}
	catch(b){
		try{
			http=new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch(c){
			http=null
		}
	}
	if(!http&&typeof XMLHttpRequest!="undefined"){
		http=new XMLHttpRequest
	}
    return http;
}

// Cookies 

//Creates or overwrites exsting cookie with same name

function putCookie(name, value, domain, path, days) {
	value = escape(value);
	var pc = name + "=" + value;
	var expr;
	if (domain)
		pc += ";domain=" + domain;
	if (path)
		pc += ";path=" + path;
	if (days) {
		expr = new Date();
		expr.setTime(days * 86400000 + expr.getTime());
		pc += ";expires=" + expr.toGMTString();
	}
	document.cookie = pc;
};

// get value of a cookie.

function getCookie(name){ 
	var srch = name + "=";
	var indxPos = 0;
	while (indxPos < document.cookie.length) {
		var valueOffset = indxPos + srch.length;
		if (document.cookie.substring(indxPos, valueOffset) == srch) {
			var endIndex = document.cookie.indexOf(";", valueOffset);
			if (endIndex == -1) { // Last cookie
				endIndex = document.cookie.length;
			}
			return unescape(document.cookie.substring(valueOffset, endIndex));
		}
		indxPos=document.cookie.indexOf(" ",indxPos)+1;
		if (indxPos == 0) {
			break;
		}
	}
	return null;
}

function getQueryString(qName) {
	qs = window.location.search.substring(1);
	qa = qs.split("&");
	var retString = "";
	for (i=0;i<qa.length;i++) {
		qi = qa[i].split("=");
		if (qi[0] == qName) {
			retString = qi[1];
		}
	}
	return retString;
}