function setOpacity(eleid,opacity)
{
	if(document.getElementById(eleid))
		eleid = document.getElementById(eleid);
	var obj = eleid.style;
	obj.opacity = obj.MozOpacity = opacity/100;
	obj.filter = 'alpha(opacity=' + opacity + ')';
}

function SetOpacity(eleid,opacity)
{
	//setOpacity(eleid,opacity);
}

function GetCorner(obj,x_offset,y_offset)
{
	var pos = {x:0, y:0};
	
	if (obj.offsetParent)
	{
		pos.x = obj.offsetLeft+obj.offsetWidth+x_offset;
		pos.y = obj.offsetTop+y_offset;
		
		while (obj = obj.offsetParent)
		{
			pos.x += obj.offsetLeft;
			pos.y += obj.offsetTop;
		}
	}
	return pos;
}


function in_array(val,ar)
{
	var i;
	for(i=0;i<ar.length;i++) 
	{
		if(ar[i]==val)
		{
			return true;	
		}
	}
	return false;
}

function array_single_val(val,ar)
{
	var i,a;
	a = new Array();
	for(i=0;i<ar.length;i++) 
	{
		a[i] = ar[i][val];
	}
	return a;
}

function array_unset(val,ar)
{
	for (var i=0;i<ar.length;i++)
	{
		if (ar[i] == val)
		{
			ar.splice(i,1);
			break;
		}
	}
}

function array_push(array,value)
{
	return array.push(value);
}

function array_compact(array)
{
	return array.compact();	
}

function array_clear(array)
{
	return array.clear();	
}

function is_array(a)
{
	if(typeof(a)=="object")
		return true;
	return false;
}

function is_string(t)
{
	if(typeof(t)=="string")
		return true;
	return false;
}

function is_int(n){ return is_numeric(n); }
function is_str(t){ return is_string(t); }

function is_numeric(n)
{
	if(typeof(n)=="number")
		return true;
	return false;
}

function printc(obj,inherit) 
{
	var returner;
	if(typeof obj == "object") 
	{
		returner = "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
	} else {
		returner = "Type: "+typeof(obj)+"\nValue: "+obj;
	}
	developer(returner,inherit);
}

function developer(t,inherit)
{
	var pre;
	if(document.getElementById('devdiv_'))
	{
		if(inherit)
		{
			document.getElementById('devdiv_').innerHTML+="<br>\n\r"+t;
		} else {
			document.getElementById('devdiv_').innerHTML=t;
		}
	} else {
		pre = document.createElement("pre");
		pre.id="devdiv_";
		pre.name="devdiv_";
		pre.style.border="1px solid #000";
		pre.style.padding="2px";
		pre.innerHTML=t;
		document.body.appendChild(pre);
	}
}


function insertFirst(parent,element)
{
	parent.insertBefore(element,parent.firstChild);
}


function style_set(element,array,rev)
{
	var style;
	style = array[1];
	if(!rev) style = "";
	if (navigator.userAgent.indexOf("MSIE") >= 0)
	{
		element.style.setAttribute(array[0],style);
	} else {
		element.style.setProperty(array[0],style,null);
	}
}

function unhtmlentities(t)
{
	return t.unescapeHTML();	
}

function htmlentities(t)
{
	return t.EscapedHTML();	
}

function striptags(t)
{
	return t.stripTags();	
}


function empty(s)
{
	if(typeof(text)=='undefined'||!text.toString)
	{
		return true;
	} else {
		return false;
	}
}


function htmlspecialchars(text)
{
	if(empty(text)) return '';
	return text.toString().replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/'/g,'&#039;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
}

function escape_js_quotes(text)
{
	return text.toString().replace(/\\/g,'\\\\').replace(/\n/g,'\\n').replace(/\r/g,'\\r').replace(/"/g,'\\x22').replace(/'/g,'\\\'').replace(/</g,'\\x3c').replace(/>/g,'\\x3e').replace(/&/g,'\\x26');
}

function trim(text)
{
	return text.toString().replace(/^\s*|\s*$/g,'');
}

function nl2br(text)
{
	return text.toString().replace(/\n/g,'<br />');
}

function sprintf(pattern,arguments)
{
	var error = new Array();
	if(arguments.length==0)
		error[error.length] = 'sprintf() was called with no arguments; it should be called with at least one argument.';
	
	var args=['This is an argument vector.'];
	for(var ii=arguments.length-1;ii>0;ii--)
	{
		if(typeof(arguments[ii])=="undefined")
		{
		error[error.length] = 'You passed an undefined argument (argument '+ii+' to sprintf(). '+'Pattern was: `'+(arguments[0])+'\'.','error';
		args.push('');
		} else if(arguments[ii]===null)
		{
			args.push('');
		} else if(arguments[ii]===true)
		{
			args.push('true');
		} else if(arguments[ii]===false)
		{
			args.push('false');
		} else {
			if(!arguments[ii].toString)
				error[error.length] = 'Argument '+(ii+1)+' to sprintf() does not have a toString() '+'method. The pattern was: `'+(arguments[0])+'\'.','error';
			args.push(arguments[ii]);
		}
	}
	var pattern=arguments[0];
	pattern=pattern.toString().split('%');
	var patlen=pattern.length;
	var result=pattern[0];
	for(var ii=1;ii<patlen;ii++)
	{
		if(args.length==0)
			error[error.length] = 'Not enough arguments were provide to sprintf(). The pattern was: '+'`'+(arguments[0])+'\'.','error';
		if(!pattern[ii].length)
			result+="%";continue;
		switch(pattern[ii].substr(0,1))
		{
			case's':
				result+=htmlspecialchars(args.pop().toString());
			break;
			case'h':
				result+=args.pop().toString();
			break;
			case'd':
				result+=parseInt(args.pop());
			break;
			case'f':
				result+=parseFloat(args.pop());
			break;
			case'q':
				result+="`"+htmlspecialchars(args.pop().toString())+"'";
			break;
			case'e':
				result+="'"+escape_js_quotes(args.pop().toString())+"'";
			break;
			case'x':
				x=args.pop();result+=x.toString()+' [at line '+x.line+' in '+x.sourceURL+']';
			break;
			default:
				result+="%"+pattern[ii].substring(0,1);
			break;
		}
		result+=pattern[ii].substring(1);
	}
	if(args.length>1)
		error[error.length] = ('Too many arguments ('+(args.length-1)+' extras) were passed to '+'sprintf(). Pattern was: `'+(arguments[0]));

	if(error.length>0)
	{
		alert(error);
		return '';
	}

	return result;
}



function tz_calculate(timestamp)
{
	var d=new Date();
	var raw_offset=d.getTimezoneOffset()/30;
	var time_sec=d.getTime()/1000;
	var time_diff=Math.round((timestamp-time_sec)/1800);
	var rounded_offset=Math.round(raw_offset+time_diff)%48;
	if(rounded_offset==0)
	{
		return 0;
	} else if (rounded_offset>24)
	{
		rounded_offset-=Math.ceil(rounded_offset/48)*48;
	} else if (rounded_offset<-28)
	{
		rounded_offset+=Math.ceil(rounded_offset/-48)*48;
	}
	return rounded_offset*30;
}


function detect_browser_size()
{
	var width=0;
	var height=0;
	if(typeof(window.innerWidth)=='number')
	{
	width=window.innerWidth;
	height=window.innerHeight;
	} else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight))
	{
		width=document.documentElement.clientWidth;height=document.documentElement.clientHeight;
	} else if(document.body&&(document.body.clientWidth||document.body.clientHeight))
	{
		width=document.body.clientWidth;height=document.body.clientHeight;
	}
	return parseInt(height)+","+parseInt(width)
}





Number.max = function (a,b) {
    return a<b?b:a;
}

Number.min = function (a,b) {
    return a>b?b:a;
}

Math.mod = function(val,mod) {
    if (val < 0) {
        while(val<0) val += mod;
        return val;
    } else {
        return val%mod;
    }
}

window.getInnerWidth = function() {
    if (window.innerWidth) {
        return window.innerWidth;
    } else if (document.body.clientWidth) {
        return document.body.clientWidth;
    } else if (document.documentElement.clientWidth) {
        return document.documentElement.clientWidth;
    }
} 

window.getInnerHeight = function() {
    if (window.innerHeight) {
        return window.innerHeight;
    } else if (document.body.clientHeight) {
        return document.body.clientHeight;
    } else if (document.documentElement.clientHeight) {
        return document.documentElement.clientHeight;
    }
} 

String.prototype.endsWith = function(str) {
    return (this.length-str.length)==this.lastIndexOf(str);
}

String.prototype.reverse = function() {
    var s = "";
    var i = this.length;
    while (i>0) {
        s += this.substring(i-1,i);
        i--;
    }
    return s;
}

// this trim was suggested by Tobias Hinnerup
String.prototype.trim = function() {
    return(this.replace(/^\s+/,'').replace(/\s+$/,''));
}

String.prototype.toInt = function() {
    var a = new Array();
    for (var i = 0; i < this.length; i++) {
        a[i] = this.charCodeAt(i);
    }
    return a;
}

Array.prototype.intArrayToString = function() {
    var a = new String();
    for (var i = 0; i < this.length; i++) {
        if(typeof this[i] != "number") {
            throw new Error("Array must be all numbers");
        } else if (this[i] < 0) {
            throw new Error("Numbers must be 0 and up");
        }
        a += String.fromCharCode(this[i]);
    }
    return a;    
}

Array.prototype.compareArrays = function(arr) {
    if (this.length != arr.length) return false;
    for (var i = 0; i < arr.length; i++) {
        if (this[i].compareArrays) { //likely nested array
            if (!this[i].compareArrays(arr[i])) return false;
            else continue;
        }
        if (this[i] != arr[i]) return false;
    }
    return true;
}

Array.prototype.map = function(fnc) {
    var a = new Array(this.length);
    for (var i = 0; i < this.length; i++) {
        a[i] = fnc(this[i]);
    }
    return a;
}

Array.prototype.foldr = function(fnc,start) {
    var a = start;
    for (var i = this.length-1; i > -1; i--) {
        a = fnc(this[i],a);
    }
    return a;
}

Array.prototype.foldl = function(fnc,start) {
    var a = start;
    for (var i = 0; i < this.length; i++) {
        a = fnc(this[i],a);
    }
    return a;
}

Array.prototype.exists = function (x) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == x) return true;
    }
    return false;
}

Array.prototype.filter = function(fnc) {
    var a = new Array();
    for (var i = 0; i < this.length; i++) {
        if (fnc(this[i])) {
            a.push(this[i]);
        }
    }
    return a;
}

Array.prototype.random = function() {
    return this[Math.floor((Math.random()*this.length))];
}

function fromvars(vars)
{
	var f,a,i,f2,k,v;
	f = vars.split(",");
	a = new arry();
	for(i=0;i<f.length;i++)
	{
		f2 = f[i].split(":");
		k = f2[0];
		v = f2[1];
		k = k.replace("&colen;",":");
		v = v.replace("&colen;",":");
		k = k.replace("&comma;",",");
		v = v.replace("&comma;",",");
		a.push(v,k);
	}
	return a;
}


function formatdate(time)
{
	if(time<60)
	{
		return Math.round(time) + " Second" + plural(Math.round(time));
	} else if(time < 60*60)
	{
		return Math.round(time/60) + " Minute" + plural(Math.round(time/60));
	} else if(time<60*60*24)
	{
		return Math.round(time/60/60) + " Hour" + plural(Math.round(time/60/60));
	} else if(time<60*60*24*360)
	{
		return Math.round(time/60/60/24) + " Day" + plural(Math.round(time/60/60/24));
	} else
	{
		return Math.round(time/60/60/24/360) + " Year" + plural(Math.round(time/60/60/24/360));
	}
}

function plural(n)
{
	if(n!=1)
		return "s";
	else
		return "";
}

function formatsize(bytes)
{
	if(bytes<1024)
	{
		return Math.round(bytes) + " Byte" + plural(Math.round(bytes));
	} else if(bytes < 1024*1024)
	{
		return Math.round(bytes/1024) + " Kilobyte" + plural(Math.round(bytes/1024));
	} else if(bytes<1024*1024*1024)
	{
		return (bytes/1024/1024).toFixed(1) + " Megabyte" + plural((bytes/1024/1024).toFixed(1));
	} else if(bytes<1024*1024*1024*1024)
	{
		return (bytes/1024/1024/1024).toFixed(2) + " Gigabyte" + plural((bytes/1024/1024/1024).toFixed(2));
	} else if(bytes<1024*1024*1024*1024*1024)
	{
		return (bytes/1024/1024/1024/1024).toFixed(3) + " Terrabyte" + plural((bytes/1024/1024/1024/1024).toFixed(3));
	}
}




function reverse2(str)
{
	str = str.toString();
      var newString = ""; 
	  var counter = str.length;
      for (counter  ;counter > 0 ;counter -- ) 
      { 
         newString += str.substring(counter-1, counter); 
      } 
	  
     return newString;
}

getElementByName = function(name)
{
	var a = document.body.childNodes;
	for(i=0;i<a.length;i++)
	{
		if(a[i].name==name)
			return a[i];
	}
	return false;
}



function GetWindowSize()
{
	if (typeof(window.innerWidth) == 'number') return {x:window.innerWidth,y:window.innerHeight};
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) return {x:document.documentElement.clientWidth,y:document.documentElement.clientHeight};
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) return {x:document.body.clientWidth,y:document.body.clientHeight};
}


function getPadding(x,side){
var p=getStyleProp(x,"padding"+side);
if(p==null || !p.find("px")) return(0);
return(parseInt(p));
}

function getStyleProp(x,prop){
if(x.currentStyle)
    return(x.currentStyle[prop]);
if(document.defaultView.getComputedStyle)
    return(document.defaultView.getComputedStyle(x,'')[prop]);
return(null);
}

function rgb2hex(value){
var hex="",v,h,i;
var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
var h=regexp.exec(value);
for(i=1;i<4;i++){
    v=parseInt(h[i]).toString(16);
    if(v.length==1) hex+="0"+v;
    else hex+=v;
    }
return("#"+hex);
}

function getStyleAttribute(ident,attr)
{
	var a = document.getElementsByTagName("style");
	for(i=0;i<a.length;i++)
	{
		text = a[i].innerHTML;
		patt = ident+"([\\n\\s\\r]+)?{([a-zA-Z0-9:;#\\n\\s\\r]+)}";
		var Pattern = new RegExp(patt,"gim");
		text2 = text.match(Pattern);
		if(text2!=null)
		{
			if(text2.length==1)
			{
				var re2 = new RegExp(attr+"\:([a-zA-Z0-9\(\)\"\'\,\.\\s\#\-]+)\;","gi");
				text3 = text2[0].match(re2);
				if(text3!=null)
				{
					if(text3.length==1)
					{
						return text3[0].replace(new RegExp(attr,"gi"),"").replace(new RegExp(":|;","gi"),"");
					}
				}
			}
		}
	}
	return null;
}


/*
function getElementsBySelector(selector){
var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
if(selector.find("#")){ //id selector like "tag#id"
    if(selector.find(" ")){  //descendant selector like "tag#id tag"
        s=selector.split(" ");
        var fs=s[0].split("#");
        if(fs.length==1) return(objlist);
        f=document.getElementById(fs[1]);
        if(f){
            v=f.getElementsByTagName(s[1]);
            for(i=0;i<v.length;i++) objlist.push(v[i]);
            }
        return(objlist);
        }
    else{
        s=selector.split("#");
        tag=s[0];
        selid=s[1];
        if(selid!=""){
            f=document.getElementById(selid);
            if(f) objlist.push(f);
            return(objlist);
            }
        }
    }
if(selector.find(".")){      //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    if(selclass.find(" ")){   //descendant selector like tag1.classname tag2
        s=selclass.split(" ");
        selclass=s[0];
        tag2=s[1];
        }
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass==""){
    for(i=0;i<v.length;i++) objlist.push(v[i]);
    return(objlist);
    }
for(i=0;i<v.length;i++){
    c=v[i].className.split(" ");
    for(j=0;j<c.length;j++){
        if(c[j]==selclass){
            if(tag2=="") objlist.push(v[i]);
            else{
                v2=v[i].getElementsByTagName(tag2);
                for(k=0;k<v2.length;k++) objlist.push(v2[k]);
                }
            }
        }
    }
return(objlist);
}
*/



/* document.getElementsBySelector(selector)
   - returns an array of element objects from the current document
     matching the CSS selector. Selectors can contain element names, 
     class names and ids and can be nested. For example:
     
       elements = document.getElementsBySelect('div#main p a.external')
     
     Will return an array of all 'a' elements with 'external' in their 
     class attribute that are contained inside 'p' elements that are 
     contained inside the 'div' element which has id="main"

   New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
   See http://www.w3.org/TR/css3-selectors/#attribute-selectors

   Version 0.4 - Simon Willison, March 25th 2003
   -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
   -- Opera 7 fails 
*/

function getElementsBySelector(selector){return document.getElementsBySelector(selector);}
document.getElementBySelector=function(selector){return document.getElementsBySelector(selector)[0];}
function getElementBySelector(selector){return document.getElementsBySelector(selector)[0];}

function getAllChildren(e) 
{
  // Returns all children of element. Workaround required for IE5/Windows. Ugh.
  return e.all ? e.all : e.getElementsByTagName('*');
}

document.getElementsBySelector = function(selector) 
{
	if (!document.getElementsByTagName) 
		return new Array();
	
	var tokens = selector.split(' ');
	var currentContext = new Array(document);
	var currentC2 = new Array();
	for (var i = 0; i < tokens.length; i++) 
	{
		token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
		if (token.indexOf('#') > -1) 
		{
			var bits = token.split('#');
			var tagName = bits[0];
			var id = bits[1];
			var a = document.getElementsByTagName(tagName);
			for(j=0;j<a.length;j++)
			{
				if(Prototype.Browser.Firefox)
					pid = a[j].hasId(id);
				else
					pid = a[j].id==id;
				if(pid)
				{
					currentC2[currentC2.length] = a[j];
				}
			}
			continue;
		}
		if (token.indexOf('.') > -1) 
		{
			var bits = token.split('.');
			var tagName = bits[0];
			var className = bits[1];
			if (!tagName) 
			{
				tagName = '*';
			}
			
			var a = document.getElementsByTagName(tagName);
			for(j=0;j<a.length;j++)
			{
				if(Prototype.Browser.Firefox)
					pid = a[j].hasClassName(className);
				else
					pid = a[j].className==className;
				if(pid)
				{
					currentC2[currentC2.length] = a[j];
				}
			}
			continue;
		}
		if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) 
		{
			var tagName = RegExp.$1;
			var attrName = RegExp.$2;
			var attrOperator = RegExp.$3;
			var attrValue = RegExp.$4;
			if (!tagName) 
			{
				tagName = '*';
			}
			// Grab all of the tagName elements within current context
			var found = new Array;
			var foundCount = 0;
			for (var h = 0; h < currentContext.length; h++) 
			{
				var elements;
				if (tagName == '*') 
					elements = getAllChildren(currentContext[h]);
				else
					elements = currentContext[h].getElementsByTagName(tagName);
				for (var j = 0; j < elements.length; j++) 
				{
					found[foundCount++] = elements[j];
				}
			}
			currentContext = new Array;
			var currentContextIndex = 0;
			var checkFunction; // This function will be used to filter the elements
			switch (attrOperator) 
			{
				case '=': // Equality
				checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
				break;
				case '~': // Match one of space seperated words 
				checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
				break;
				case '|': // Match start with value followed by optional hyphen
				checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
				break;
				case '^': // Match starts with value
				checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
				break;
				case '$': // Match ends with value - fails with "Warning" in Opera 7
				checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
				break;
				case '*': // Match ends with value
				checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
				break;
				default:// Just test for existence of attribute
				checkFunction = function(e) { return e.getAttribute(attrName); };
			}
			currentContext = new Array;
			var currentContextIndex = 0;
			for (var k = 0; k < found.length; k++) 
			{
				if (checkFunction(found[k])) 
				{
					currentContext[currentContextIndex++] = found[k];
				}
			}
			// alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
			continue // Skip to next token
		}
		// If we get here, token is JUST an element (not a class or ID selector)
		tagName = token;

		var found = new Array;
		var foundCount = 0;
		for (var h = 0; h < currentContext.length; h++) 
		{
			var elements = currentContext[h].getElementsByTagName(tagName);
			for (var j = 0; j < elements.length; j++) 
			{
				found[foundCount++] = elements[j];
			}
		}
		currentC2[currentC2.length] = found;
	}
	return currentC2;
}

/* That revolting regular expression explained 
/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
  \---/  \---/\-------------/    \-------/
    |      |         |               |
    |      |         |           The value
    |      |    ~,|,^,$,* or =
    |   Attribute 
   Tag
*/



function stringReplace(originalString, findText, replaceText) 
{
	var pos,len;
	pos = 0;
    len = findText.length;
    pos = originalString.indexOf(findText);
    while (pos != -1) 
	{
        preString = originalString.substring(0, pos);
        postString = originalString.substring(pos + len, originalString.length);
        originalString = preString + replaceText + postString;
        pos = originalString.indexOf(findText);
    }
      return originalString;
}

function obj_show(obj_id) 
{
	if(document.getElementById(obj_id))
		obj_id = document.getElementById(obj_id);
	obj_id.style.display="block";
}

function obj_hide(obj_id) 
{
	if(document.getElementById(obj_id))
		obj_id = document.getElementById(obj_id);
	obj_id.style.display="none";
}

function GetParams()
{
	var idx = document.URL.indexOf('?');
	var params = new Array();
	if (idx != -1) 
	{
		var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
		for (var i=0; i<pairs.length; i++) 
		{
			nameVal = pairs[i].split('=');
			params[nameVal[0]]=stringReplace(nameVal[1],"+"," ")
		}
	}
	return params;
}

function openYahooMap(addr, city)
{
	var url = '';
	url += "http://maps.yahoo.com/py/maps.py?Pyt=Tmap&addr=";
    url += stringReplace(addr, " ", "%20");
	url += "&csz=" + stringReplace(city, " ", "%20");
   	url += "+CA&Get+Map=Get+Map";
   	openwindow(url);
}


function openwindow(url,v) 
{
	if(v==null)
		v = 1;
    var ItsTheWindow,vars,w,h,name;
	w = 600;
	h = 400;
	name = "New Window -> "+url;
	if(v==1)
		vars = "status=no,scrollbars=yes,resizable=yes,toolbar=yes";
	if(v==2)
		vars = "scrollbars=yes,toolbar=yes,directories=yes,location=yes,menubar=yes,resizable=yes,status=yes";
		
    ItsTheWindow = window.open(url,name,vars+"width="+w+",height="+h);
	ItsTheWindow = open(url,name,vars);
	ItsTheWindow.focus();
}


function is_intstring(str) 
{
	for(var i = 0; i != str.length; i++) 
	{
		aChar = str.substring(i,i+1);
		if(aChar < "0" || aChar > "9") 
		{
			return false;
		}
	}
	return true;
}

function numToString(number)
{
	return number + '';
}

function containsElement(arr, ele) 
{
	var found = false, index = 0;
	while(!found && index < arr.length)
	{
		if(arr[index] == ele)
		{
			found = true;
		} else {
			index++;
		}
	}
	return found;
}

function bookmarkSite(url,title)
{
	if(!title)
		title = ' ';
	if (document.all)
	{
		window.external.AddFavorite(url, title);
	} else if (window.sidebar) {
		window.sidebar.addPanel(title, url, "");
	} else {
		return false;
	}
}

function characterCounter(field, countfieldid, maxlimit)
{
	if(field.value.length > maxlimit)
	{
		field.value = field.value.substring(0, maxlimit);
	} else {
		countfield = document.getElementById(countfieldid);
		countfield.value = maxlimit - field.value.length;
	}
}


function valid_browser_js()
{
	if(navigator.userAgent.indexOf("Mozilla/")==0) 
	{
		return(parseInt(navigator.appVersion)>=4);
	}
	
	return false;
}


function rhex(num)
{
	var hex_chr="0123456789abcdef";
	str="";
	for(j=0;j<=3;j++)
	{
	str+=hex_chr.charAt((num>>(j*8+4))&0x0F)+hex_chr.charAt((num>>(j*8))&0x0F);
	}
	return str;
}


function trimWS(str)
{
	str=str.replace(/,/g,' ');
	str=str.replace(/^\s*(\S+)*\s*$/,"$1");
	str=str.replace(/(\s{1})\s*/g,"$1");
	return str;
}

function urlEncode(str)
{
	str=trimWS(str);
	str=escape(str);
	return str;
}

function urlDecode(str)
{
	return unescape(str);
}

function checkZip(str)
{
	str=trimWS(str.toString());
	var bool=(str.match(/^\d{5}$/)!=null && str!='00000'?true:false);
	return bool;
}

addEvent = function(o, e, f, s)
{
    var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
    r[r.length] = [f, s || o], o[e] = function(e){
        try{
            (e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
            e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
            e.target || (e.target = e.srcElement || null);
            e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
        }catch(f){}
        for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
        return e = null, !!d;
    }
};

removeEvent = function(o, e, f, s)
{
    for(var i = (e = o["_on" + e] || []).length; i;)
        if(e[--i] && e[i][0] == f && (s || o) == e[i][1])
            return delete e[i];
    return false;
};



function findPos(obj) 
{
	if(!Prototype.Browser.IE)
	{
		return obj.cumulativeOffset();
	} else {
		var curleft = curtop = 0;
		if (obj.offsetParent) 
		{
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) 
			{
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		return [curleft,curtop];
	}
}

function findPosX(obj){ return findPos(obj)[0]; }
function findPosY(obj){ return findPos(obj)[1]; }

Element.isParent = function(child, element) 
{
  if (!child.parentNode || child == element) return false;
  if (child.parentNode == element) return true;
  return Element.isParent(child.parentNode, element);
}

function getMousePosition(e) 
{
	if (Prototype.Browser.IE) 
	{
		tempX = event.clientX + document.body.scrollLeft
		tempY = event.clientY + document.body.scrollTop
	} else {
		tempX = e.pageX
		tempY = e.pageY
	}  
	
	if (tempX < 0)
		tempX = 0
	if (tempY < 0)
		tempY = 0
	var final = new Array();
	final[0] = tempX;
	final[1] = tempY;
	return final;
}

function pst2local(pst)
{
  var local, month;
  local = new Date(pst+" PST");
  month = local.getMonth();
  if (month > 2 && month < 10) {
    local = new Date(pst+" PDT");
  }
  return local;
}

function delay(seconds)
{
var ms = parseInt(seconds)/1000;
  var date = new Date();
  var curDate = null;
  do{
    curDate = new Date();
  }while((curDate - date) - ms);
}



function getMouseXY(e)
{
	var x,y,ie;
	IE = document.all?true:false;
	if(!e){e = window.event;}
	if (IE) 
	{
		x = event.clientX + document.body.scrollLeft;
		y = event.clientY + document.body.scrollTop;
	} else {
		x = e.screenX;
		y = e.screenY-134;
	}
	return new Array(x,y);
}

function getMouseX(e)
{
	return getMouseXY(e)[0];
}

function getMouseY(e)
{
	return getMouseXY(e)[1];
}


function load_js(url)
{
	var js = document.createElement("script");
	js.type="text/javascript";
	js.src=url;
	return load_head(js);
}

function load_css(url)
{
	var css = document.createElement("link");
	css.href=url;
	css.media="screen";
	css.type="text/css";
	css.rel="stylesheet";
	return load_head(css);
}

function load_head(ele)
{
	if(document.getElementsByTagName("head"))
	{
		document.getElementsByTagName("head")[0].appendChild(ele);
		return true;
	} else {
		return false;
	}
}

function test(){}
function blank(){}
function dosomething(){}
function nullvoid(){}
function voidnull(){}



function retrieveCookie(cookieName) 
{
	var cookieJar = document.cookie.split( "; " );
	for( var x = 0; x < cookieJar.length; x++ ) {
		var oneCookie = cookieJar[x].split( "=" );
		if( oneCookie[0] == escape( cookieName ) ) { return unescape( oneCookie[1] ); }
	}
	return null;
}

function setCookie(cookieName, cookieValue, lifeTime, path, domain, isSecure ) 
{
	if( !cookieName ) { return false; }
	if( lifeTime == "delete" ) { lifeTime = -10; }
	document.cookie = escape( cookieName ) + "=" + escape( cookieValue ) +
		( lifeTime ? ";expires=" + ( new Date( ( new Date() ).getTime() + ( 1000 * lifeTime ) ) ).toGMTString() : "" ) +
		( path ? ";path=" + path : "") + ( domain ? ";domain=" + domain : "") + 
		( isSecure ? ";secure" : "");
	//check if the cookie has been set/deleted as required
	if( lifeTime < 0 ) { if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return false; } return true; }
	if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return true; } return false;
}

function getCookie(name){return retrieveCookie(name);}


function capsDetect( e ) 
{
	if( !e ) { e = window.event; } if( !e ) { MWJ_say_Caps( false ); return; }
	//what (case sensitive in good browsers) key was pressed
	var theKey = e.which ? e.which : ( e.keyCode ? e.keyCode : ( e.charCode ? e.charCode : 0 ) );
	//was the shift key was pressed
	var theShift = e.shiftKey || ( e.modifiers && ( e.modifiers & 4 ) ); //bitWise AND
	//if upper case, check if shift is not pressed. if lower case, check if shift is pressed
	MWJ_say_Caps( ( theKey > 64 && theKey < 91 && !theShift ) || ( theKey > 96 && theKey < 123 && theShift ) );
}
function MWJ_say_Caps( oC ) {
	if( typeof( capsError ) == 'string' ) { if( oC ) { alert( capsError ); } } else { capsError( oC ); }
}



function outerHTML(obj) 
{ 
return obj.outerHTML || document.createElement('div').appendChild(obj.cloneNode(true)).parentNode.innerHTML;
}








function selectchk(id, type, kind)
{
	var aab = document.getElementById(id).getElementsByTagName(type);
	var len1 = aab.length;
	var b1 = '';
	var checkedstr = '';
	
	if(kind.toLowerCase() == "all")
	{
		checkedstr = "checked";
	} else {
		checkedstr = "";
	}
	
	for(i=0;i<len1;i++) {
		document.getElementById(id).getElementsByTagName(type)[i].checked=checkedstr;
	}
}



function collapse(id, id2) 
{ 
	if(document.getElementById(id).style.display=="none") 
	{ 
		document.getElementById(id).style.display="block"; 
		document.getElementById(id2).style.display="none"; 
	} else { 
		document.getElementById(id).style.display="none"; 
		document.getElementById(id2).style.display="block"; 
	}
}


function collapseToggle(id)
{ 
	if(document.getElementById(id).style.display=="none") 
		document.getElementById(id).style.display="block"; 
	else 
		document.getElementById(id).style.display="none"; 
}


function isInteger(op)
{
	if(op==0)
		return true;
	else
	{
	exp = /^\s*[-+]?\d+\s*$/;
      if (op.match(exp) == null) 
      	return null;
      num = parseInt(op, 10);
      return (isNaN(num) ? null : num);
	}
}

function isValidEmail(str) 
{
   var bob = (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
   return bob;
}

function conferm(str)
{
	var answer = confirm(str)
	if (answer)
	{
		return true;
	} else {
		return false;
	}
}

function disable(ele)
{
	if(document.getElementById(ele))
		ele = $(ele);
	ele.disabled="disabled";
}


function reverseString(inp) 
{
	var outp = 0;
	for (i = 0; i <= inp.length; i++) 
	{
		outp = inp.charAt (i) + outp;
	}
	return outp;
} 

function replace(string,text,by) 
{
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function highlight(field) 
{
	field.focus();
	field.select();
}

function hideshow(ida, idb)
{
	if(document.getElementById(ida).style.display=="none")
	{
		document.getElementById(ida).style.display="block";
		document.getElementById(idb).style.display="none";
	} else {
		document.getElementById(ida).style.display="none";
		document.getElementById(idb).style.display="block";
	}
}

function copy(inElement) 
{
	if (Prototype.Browser.IE)
	{
		temp1 = inElement.createTextRange();
		temp1.select();
		temp1.execCommand( 'copy' );
		inElement.focus();
	} else {
		if (inElement.createTextRange)
		{
			var range = inElement.createTextRange();
			if (range && BodyLoaded==1)
			range.execCommand('Copy');
		} else {
			var flashcopier = 'flashcopier';
			if(!document.getElementById(flashcopier)) 
			{
				var divholder = document.createElement('div');
				divholder.id = flashcopier;
				document.body.appendChild(divholder);
			}
			document.getElementById(flashcopier).innerHTML = '';
			var divinfo = '<embed src="http://www.csscobalt.com/uploads/_clipboard.swf" FlashVars="clipboard='+escape(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
			document.getElementById(flashcopier).innerHTML = divinfo;
			inElement.focus();
			inElement.select();
		}
	}
}

function dec2hex(n)
{
    n = parseInt(n); var c = 'ABCDEF';
    var b = n / 16; var r = n % 16; b = b-(r/16); 
    b = ((b>=0) && (b<=9)) ? b : c.charAt(b-10);    
    return ((r>=0) && (r<=9)) ? b+''+r : b+''+c.charAt(r-10);
}

function randomNumber()
{
    return Math.ceil(Math.random() * 85);
}


function ClipBoard(id)
{
	var ccc = MM_findObj(id);
    if (document.all){
	ccc.value = ccc.innerText;
	Copied = ccc.createTextRange();
	Copied.execCommand("Copy");
    alert("URL copied!");
    }
    else
    {
        alert('Close this box and press \'CTL-c\' to copy');
        ccc.focus();
        ccc.select();
    }
}


function tableParse()
{
	var a = document.getElementsByTagName("table");
	for(i=0;i<a.length;i++)
	{
		var ele = a[i];
		ele.cellSpacing="0";
		ele.cellPadding="0";
	}
}