var ELEMENT_NODE=1;var ATTRIBUTE_NODE=2;var TEXT_NODE=3;var CDATA_SECTION_NODE=4;var ENTITY_REFERENCE_NODE=5;var ENTITY_NODE=6;var PROCESSING_INSTRUCTION_NODE=7;var COMMENT_NODE=8;var DOCUMENT_NODE=9;var DOCUMENT_TYPE_NODE=10;var DOCUMENT_FRAGMENT_NODE=11;var NOTATION_NODE=12;
function Browser() { var ua, s, i;  this.isIE = false; this.isNS  = false; this.version = null; ua = navigator.userAgent; s = "MSIE"; if ((i = ua.indexOf(s)) >= 0) {this.isIE = true; this.version = parseFloat(ua.substr(i + s.length));return; }; s = "Netscape6/"; if ((i = ua.indexOf(s)) >= 0) {this.isNS = true; this.version = parseFloat(ua.substr(i + s.length)); return; }; s = "Gecko"; if ((i = ua.indexOf(s)) >= 0) {this.isNS = true;this.version = 6.1;return; };};var browser = new Browser();
if(!browser.isIE){
XMLDocument.prototype.selectNodes = function(cXPathString, xNode){if( !xNode ) xNode = this;var oNSResolver = this.createNSResolver(this.documentElement);var aItems = this.evaluate(cXPathString, xNode, oNSResolver,  XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);var aResult = [];for( var i = 0; i < aItems.snapshotLength; i++) aResult[i] =  aItems.snapshotItem(i);return aResult;};
Element.prototype.selectNodes = function(cXPathString){if(this.ownerDocument.selectNodes) return this.ownerDocument.selectNodes(cXPathString, this); else throw "For XML Elements Only";};
XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode){if( !xNode ) xNode = this; var xItems = this.selectNodes(cXPathString, xNode); if( xItems.length > 0 ) return xItems[0]; else   return null;};
Element.prototype.selectSingleNode = function(cXPathString){if(this.ownerDocument.selectSingleNode) return this.ownerDocument.selectSingleNode(cXPathString, this); else throw "For XML Elements Only";	};
Element.prototype.xml = function() {var s=new XMLSerializer();return s.serializeToString(this);};
Element.prototype.transformNode = function (oXslDom){var oProcessor = new XSLTProcessor(); oProcessor.importStylesheet(oXslDom);var oResultDom = oProcessor.transformToDocument(this);var sResult = oResultDom.documentElement.xml();oProcessor=null;return sResult;};
Element.prototype.FirstChild = function (nodeType){if(!nodeType) nodeType=1; for(var i=0;i<this.childNodes.length;i++) if(this.childNodes[i].nodeType==nodeType) return(this.childNodes[i]); return(null);};
Element.prototype.LastChild = function (nodeType){if(!nodeType) nodeType=1; for(var i=this.childNodes.length-1;i>=0;i--)if(this.childNodes[i].nodeType==nodeType) return(this.childNodes[i]); return(null);};
Element.prototype.Childs = function (num){for(var i=num;i<this.childNodes.length;i++)if(this.childNodes[i].nodeType==1) return(this.childNodes[i]);};Element.prototype.removeNode=function(removeChildren){if(!removeChildren) return this.parentNode.removeChild(this);else{var range=document.createRange();range.selectNodeContents(this);return this.parentNode.replaceChild(range.extractContents(),this);}}}
Array.prototype.Contains=function(value){for(i=0;i<this.length;i++)if(this[i]==value) return(true);return(false);}
function Queue(){ var queue=new Array();var queueSpace=0;this.enqueue=function(element){queue.push(element);};this.dequeue=function(){if (queue.length){var element=queue[queueSpace]; if (++queueSpace*2 >= queue.length){for (var i=queueSpace;i<queue.length;i++) queue[i-queueSpace]=queue[i];queue.length-=queueSpace; queueSpace=0;};return element;}else return undefined;}}
function CreateHttp(){if(!browser.isIE) return (new XMLHttpRequest()); else return(new ActiveXObject("Microsoft.XMLHTTP"));}
function HttpSpooler()
{
    this.requestQueue=new Queue();this.HttpBusy=false;   
    this.CallNext=function(){if(this.requestQueue.queue.length>0){var q=this.requestQueue.dequeue();if(q) this.LoadHttp(q.Url,q.Data,q.Callback);}}    
    this.LoadHttp=function(Url,Data,Callback)
    {	
	    if(this.HttpBusy) return(0);
	    var http=CreateHttp();	    			    
	    if(Data) {http.open("POST",Url,true);http.send(Data);}
	    else{http.open("GET",Url,true);http.send(null);}
    	if(Callback){HttpBusy=true;				    		    
			if(!browser.isIE){
				http.onload=function(){		    
					this.HttpBusy=false;Callback.Load(http.responseText);
					http=null;
					try{this.CallNext();}catch(e){}
					}	
				}
			else{		        
				http.onreadystatechange=function(){	        
					if(http.readyState==4) 		    
						if(http.status==200){
							this.HttpBusy=false;Callback.Load(http.responseText);
							http=null;
							try{this.CallNext();}catch(e){}    				
						}
	    		
				}			
			}
		}
    }
    this.Get=function(Url,Data,Callback){if(!this.HttpBusy) this.LoadHttp(Url,Data,Callback);  else{var q=new Object();q.Url=Url;q.Data=Data;q.Callback=Callback; this.requestQueue.enqueue(q);}}     
    this.Post=function(url,data){var http=CreateHttp();http.open("GET",url,false);http.send(data);http=null; }
    
    this.Read=function(url,data)
    {        
        var res="";
        var http=CreateHttp();
        if(data) http.open("POST",url,false); else http.open("GET",url,false);
        http.send(data);
        res=http.responseText;
        http=null; 
        return(res);
     }
}
var HTTP;
//************************************ HTTP ***********************************************************************************
function isLeapYear (Year) {if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {return (true);} else { return (false); }}
function getDaysInMonth(month,year)  {var days;if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)  days=31;else if (month==4 || month==6 || month==9 || month==11) days=30;else if (month==2)  {if (isLeapYear(year)) { days=29; }else { days=28; }}return (days);}

function GetStrings(source,pattern){ var re=new RegExp(pattern,"g"); var tags=source.match(re); re=null; return(tags);}

//*************************************************************************************************************
function AppendChildsToNode(node,xml){try{var doc=CreateXMLDOM();doc=LoadXml(doc,"<doccc>"+xml+"</doccc>");var c=doc.documentElement.childNodes.length;for(var i=0;i<c;i++)if(doc.documentElement.childNodes[0].nodeType==ELEMENT_NODE) node.appendChild(doc.documentElement.childNodes[0]);doc=null;}catch(e){alert("AppendChildsToNode="+ e.description);}}
function RemoveChild(n,cnum){if(n.childNodes.length-1>cnum) n.removeChild(n.childNodes[cnum]);}
function AddTextNode(n,txt){var tnode=document.createTextNode(txt);n.appendChild(tnode);}
function GetInnerText(n){if(n.childNodes.length>0) return(n.childNodes[0].nodeValue); return(n.nodeValue);}
function CreateXMLDOM(){if(!browser.isIE)	return  document.implementation.createDocument("", "", null);	else 		return new ActiveXObject("Microsoft.XMLDOM");};function LoadXml(doc,xml){	if(!browser.isIE){			var p=new DOMParser();	doc=p.parseFromString(xml,"text/xml");	p=null;} else 	doc.loadXML(xml);	return(doc)};function GetXml(doc){if(!browser.isIE) return(doc.documentElement.xml());	else return(doc.documentElement.xml);};
function GetNodeXml(node){if(!browser.isIE) return(node.xml());	else return(node.xml);};
function AppendArrayToArray(arr1,arr2){	for(var i=0;i<arr2.length;i++)	arr1.push(arr2[i]);	return(arr1);};function GetNodeList(source){var nodes=new Array();for(var i=0;i<source.childNodes.length;i++){nodes.push(source.childNodes[i]);if(source.childNodes[i].hasChildNodes()) AppendArrayToArray(nodes,GetNodeList(source.childNodes[i]));};return(nodes);};function ChangeNode(node,xml){try{var doc=CreateXMLDOM();doc=LoadXml(doc,xml);var p=node.parentNode;p.removeChild(node);p.appendChild(doc.documentElement);doc=null;}catch(e){alert(e.description);}};function ReplaceNode(node,xml){	try{var doc=CreateXMLDOM();doc=LoadXml(doc,xml);var p=node.parentNode;p.replaceChild(doc.documentElement,node);doc=null;return(p);}catch(e){alert(e.description);}};function AppendChildsToNode(node,xml){try{var doc=CreateXMLDOM();doc=LoadXml(doc,"<doccc>"+xml+"</doccc>");var c=doc.documentElement.childNodes.length;for(var i=0;i<c;i++)if(doc.documentElement.childNodes[0].nodeType==ELEMENT_NODE) node.appendChild(doc.documentElement.childNodes[0]);doc=null;}catch(e){alert("AppendChildsToNode="+ e.description);}};function countChilds(Node,Type){var c=0;for(var i=0;i<Node.childNodes.length;i++)if(Node.childNodes[i].nodeType==Type) c++;return(c);};function GetURLXml(source){	var doc=CreateXMLDOM();doc.async=false;doc.load(source);var res=GetXml(doc);doc=nullreturn(res);};function escapeChars (text){if(text==null) return text; text=text.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&"); return(text);};function GetString(source,pattern){var re=new RegExp(pattern,"g");var tags=source.match(re);re=null;return(tags);};function ParseGlobal(source){var re=new RegExp("{<%[\\s\\S]*?%>}","g");var tags=source.match(re);if(tags!=null){for(var i=0;i<tags.length;i++){var k =tags[i].replace("{<%","").replace("%>}","");source=source.replace(tags[i],eval(k));}};re=null;return(source);}function ReplaceChildNodes(node,xml){try{var doc=CreateXMLDOM();doc=LoadXml(doc,"<doccc>"+xml+"</doccc>");var c=node.childNodes.length;	for(var i=0;i<c;i++) node.removeChild (node.childNodes[0]);	c=doc.documentElement.childNodes.length;	for(var i=0;i<c;i++) if(doc.documentElement.childNodes[0].nodeType==ELEMENT_NODE) node.appendChild(doc.documentElement.childNodes[0]);	doc=null;}catch(e){alert("ReplaceChildNodes="+ e.description);}};function cloneFirstChild(node){if(!browser.isIE) return(node.FirstChild(ELEMENT_NODE).cloneNode(true)); else 	return(node.firstChild.cloneNode(true));}
function INode(_parent,_node)
{
    this.index=0;	
	if(_parent){this.parent=_parent;this.childs=_parent.childNodes.length;}
	this.current=0;	
	this.vSet=function(key,value){this[key]=value;};
	this.vSet("node",_node);this.vSet("number",0);this.vSet("cancel",false);
	//if(_node) this.ParseNode(_node);
	
	if(_node)
	{
	   //alert(_node.attributes.length);
	   this.node=_node;
	   for(var i=0;i<_node.attributes.length;i++)
	        this.vSet(_node.attributes[i].name,_node.attributes[i].value);
	
	
	}
	this.Iterate=function()
	{
		if(this.current>=this.childs) return(false);
		this.node=this.parent.childNodes[this.current++];
		if(this.node.nodeType!=ELEMENT_NODE ) return this.Iterate(); else {this.index++;return(true);}
		
	};	
	this.IsElement=function(n){if(n.nodeType==ELEMENT_NODE)  {this.node=n;return(true);}   else return(false);};
	this.Get=function(field){ var v=this.node.getAttribute(field);   if(v)   v=v.replace("&amp;","&");    return(v);};
	this.Set=function(field,value){	this.node.setAttribute(field,value);};
	
	this.GetNodeCData=function(path){
		try{var n=this.node.selectSingleNode(path);	if(n==null) return "node not found";
		if(n.nodeType==ATTRIBUTE_NODE) return n.nodeValue;if(n.nodeType==ELEMENT_NODE) if(!browser.isIE) return n.FirstChild(CDATA_SECTION_NODE).nodeValue.replace("&amp;","&"); 	else  return n.firstChild.nodeValue.replace("&amp;","&");}catch(e){return (e.description)};return "some error";	
	};
	
	this.GetNode=function(path){return(this.node.selectSingleNode(path));};	
	this.GetCData=function(){try{if(!browser.isIE) return this.node.FirstChild(CDATA_SECTION_NODE).nodeValue.replace("&amp;","&");else return this.node.firstChild.nodeValue.replace("&amp;","&");}catch(e){return (e.description)};return "some error";};
	this.GetNodeXml=function(path){try{var n=this.node.selectSingleNode(path);	if(n==null) return "node not found";return  GetNodeXml(n);}			
		catch(e){return (e.description)};return "some error";	
	};
	this.FirstElement=function()
	{
	
	
	} 
	this.GetXml=function(){
		try{
		    var n=GetFirstChild(this.node,ELEMENT_NODE);
		    //alert(n);
		    if(n) return  GetNodeXml(n); else return(this.node.firstChild.nodeValue);
			
		}			
		catch(e){return (e.description)};
		
		
	};
	
	this.GetValue=function(){return(this.node.firstChild.nodeValue);};	
	this.Reset=function (){this.current=0;this.index=0;}
}
//*************************************************************************************************************
//***************************************** Iterator *******************************************************
function PageQuery(q) {	if(q.length > 1) this.q = q.substring(1, q.length); else this.q = null;this.keyValuePairs = new Array();if(q) {for(var i=0; i < this.q.split("&").length; i++) {this.keyValuePairs[i] = this.q.split("&")[i];}}	this.getKeyValuePairs = function() { return this.keyValuePairs; };this.getValue = function(s) {for(var j=0; j < this.keyValuePairs.length; j++) { if(this.keyValuePairs[j].split("=")[0] == s) return this.keyValuePairs[j].split("=")[1];}return false;};this.getParameters = function() {var a = new Array(this.getLength());for(var j=0; j < this.keyValuePairs.length; j++) {a[j] = this.keyValuePairs[j].split("=")[0];}	return a;};this.getLength = function() { return this.keyValuePairs.length; }}var QueryString;
//********************************************************************************************************************
function DecodeBase64 (input) {var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output = "";var chr1, chr2, chr3; var enc1, enc2, enc3, enc4;var i = 0; while (i < input.length){enc1 = keyStr.indexOf(input.charAt(i++));enc2 = keyStr.indexOf(input.charAt(i++));enc3 = keyStr.indexOf(input.charAt(i++));enc4 = keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) output = output + String.fromCharCode(chr2);if (enc4 != 64) output = output + String.fromCharCode(chr3);}	return(output);}
function EncodeBase64(input) 
{
  var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; input = escape(input);var output = "";var chr1, chr2, chr3 = "";var enc1, enc2, enc3, enc4 = "";var i = 0;
  do {chr1 = input.charCodeAt(i++);chr2 = input.charCodeAt(i++);chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);enc4 = chr3 & 63;  
     if (isNaN(chr2)) { enc3 = enc4 = 64;} else if (isNaN(chr3)) {   enc4 = 64;  }
     output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);  chr1 = chr2 = chr3 = "";  enc1 = enc2 = enc3 = enc4 = "";
  } while (i < input.length);
  return output;
}
function elm(id){return(document.getElementById(id));}
function elmn(id){return(document.getElementsByName   (id)[0] );}


function decodeHTML (str){return (str.replace("&lt;","<").replace("&gt;",">").replace("&amp;","&"));}
function escapeHTML (str){  var div = document.createElement('div');var text = document.createTextNode(str);  div.appendChild(text);  return div.innerHTML;}; 
function GetFirstChild(n,e){if(!browser.isIE) return n.FirstChild(e); else  return n.firstChild;}
function leftPad(n, len,chr) {return (new Array(len - String(n).length + 1)).join(chr).concat(n);}  


function zeroFill( number, width )
{
  width -= number.toString().length;
  if ( width > 0 )
  {
    return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( '0' ) + number;
  }
  return number;
}


function body_onload_call()
{   
    QueryString=new PageQuery(window.location.search);HTTP=new HttpSpooler();		
    
	try{body_onload();}catch(e){}			
}

function reminder_reply(r_id,rem_text,rem_id)
{

//alert(elmn(rem_text).value);
var d=elm("reminder_"+r_id);
if(d.childNodes.length==0)
{

d.appendChild(elm("reminder_reply_control"));

elmn(rem_text).value="";
elmn(rem_id).value=r_id;

}

}
