﻿
/// <summary>
/// Variable decleared to be able to compare variables to what is undefined. (decleared but unnasignet variable is undefined.)
/// </summary>
var undefined;


/// <summary>
/// Method for splitting a string into an array. (this method is not implemented in some browsers)
/// </summary>
String.prototype.split=function(d){
	var a=[];var b=-1;var i=this.indexOf(d);
//TODO if no delimiter, push all into 0'th element.
	while(i >= 0){a[a.length]=this.substring(b+1,i);b=i;i=this.indexOf(d,i+1);}a[a.length]=this.substring(b+1,this.length);
	return(a);
}

/// <summary>
/// Method for trimming off whitespace at beginning and end of string.
/// </summary>
String.prototype.trim=function(){
	try{
		var a=this;	if(a.length==0)return(a);
		while(a.charAt(0)==" ")a=a.substring(1,this.length);
		while(a.charAt(a.length-1)==" ")a=a.substring(0,a.length-1);
		return(a);
	}catch(e){return(this);}
	return(this);
}

/// <summary>
/// Method for cutting off the left part of the string.
/// </summary>
String.prototype.right=function(length){
	try{
		var a=this;	if(a.length<=length)return(a);
		return(a.substring(a.length-length, a.length));
	}catch(e){return(this);}
	return(this);
}

/// <summary>
/// Static method for validating string emptyness.
/// </summary>
String.IsNullOrEmpty=function(value){
	try{
		if(value=="")return(true);
		if(value==undefined)return(true);
		if(value!="undefined" && value+""=="undefined")return(true);
		if(typeof(value)=="string" & value.length > 0)return(true);
		//if(typeof(value)!="string")return(false);//No need to test for this, will return false anyways.
	}catch(e){return(false);}
	return(false);
}

String.prototype.HTMLSafe=function(){
	try{
		return(this.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/&/g,"&amp;").replace(/"/g,"&quot;"));
	}catch(e){return(this);}
	return(this);
}

function RequestClass(){
	this.Cookies=[];
	var a=location.search;
	var b=a.substring(1,a.length).split("&");
	for(var i=0;i<b.length;i++)this[unescape(b[i].split("=")[0])]=unescape(b[i].split("=")[1]);
	var c=window.top.document.cookie;var d=c.split(";");
	for(var i=d.length-1;i>=0;i--){var e=d[i].split("=");var k=unescape(e[0]).trim();var v=unescape(e[1]).trim();this.Cookies[k]=v;}
	a=null;b=null;c=null;d=null;e=null;k=null;v=null;
} RequestClass.prototype = new Array();
try{RequestClass.prototype.constructor=RequestClass;}catch(e){}

var Request = new RequestClass();//Now use this just like .NET Request object.

// ------ Browser detection! (outdated) ------------------------------------------------------------------------------------------------------
var IE4 = (document.all && !document.getElementById) ? true : false;
var IE5 = (document.all &&  document.getElementById && document.documentElement && ((document.designMode+"") != "undefined")) ? true : false;
var IE6 = IE5;
//var IE6 = (document.all &&  document.getElementById && document.documentElement && ((document.designMode+"") != "undefined")) ? true : false;
var NS4 = (document.layers) ? true : false;
var NS6 = (document.getElementById && !document.all && document.documentElement) ? true : false;
var OP5 = (document.getElementById && !document.documentElement) ? true : false;
var OP7 = (document.all &&  document.getElementById && document.documentElement && ((document.designMode+"") == "undefined")) ? true : false;
var OP5pure = (document.getElementById && !document.all && !document.documentElement) ? true : false;
var KDE = (navigator.vendor == "KDE") ? true : false;
// ------------------------------------------------------------------------------------------------------------------------------------------

