
globalEval=function(){return eval(arguments[0]);}
Class=function(className,superClass,classScope){if(arguments.length==2){classScope=superClass;if(typeof className!="string"){superClass=className;className="anonymous";}else{superClass=Object;}}else if(arguments.length==1){classScope=className;superClass=Object;className="anonymous";}
var NewClass=function(calledBy){if(calledBy!==Class){return this.init.apply(this,arguments);}}
NewClass.createPrototype=function(){return new NewClass(Class);}
NewClass.superClass=superClass;NewClass.className=className;NewClass.toString=function(){return"[class %s]".format(NewClass.className);}
if(superClass.createPrototype!=null){NewClass.prototype=superClass.createPrototype();}else{NewClass.prototype=new superClass();}
NewClass.prototype.constructor=NewClass;if(superClass==Object){NewClass.prototype.toString=function(){return"[object %s]".format(this.constructor.className);}}
if(NewClass.prototype.init==null){NewClass.prototype.init=function(){}}
var supr=function(self){var wrapper={};var superProto=superClass.prototype;for(var n in superProto){if(typeof superProto[n]=="function"){wrapper[n]=function(){var f=arguments.callee;return superProto[f._name].apply(self,arguments);}
wrapper[n]._name=n;}}
return wrapper;}
classScope(NewClass.prototype,supr);return NewClass;}
Class.toString=function(){return"[object Class]";}
Class.createPrototype=function(){throw"Can't use Class as a super class.";}
Module=function(name,version,moduleScope){var mod=new Object();mod.version=version;mod.name=name;mod.toString=function(){return"[module '%s' version: %s]".format(mod.name,mod.version);}
mod.Exception=Class("Exception",function(publ){publ.init=function(msg,trace){this.name=this.constructor.className;this.message=msg;this.trace=trace;}
publ.toString=function(){var s="%s %s\n\n".format(this.name,this.module);s+=this.message;return s;}
publ.toTraceString=function(){var s="%s %s:\n    ".format(this.name,this.module);s+="%s\n\n".format(this.message);if(this.trace){if(this.trace.toTraceString){s+=this.trace.toTraceString();}else{s+=this.trace;}}
return s;}
publ.name;publ.message;publ.module=mod;publ.trace;})
moduleScope(mod);for(var n in mod){if(mod[n].className=="anonymous"){mod[n].className=n;}}
if(name!="jsolait"){jsolait.registerModule(mod);}
return mod;}
Module.toString=function(){return"[object Module]";}
Module.createPrototype=function(){throw"Can't use Module as a super class.";}
Module("jsolait","0.1.0",function(mod){jsolait=mod;mod.baseURL=".";mod.libURL="./jsolait";mod.modules=new Array();mod.moduleURLs={urllib:"%(libURL)s/lib/urllib.js",xml:"%(libURL)s/lib/xml.js",crypto:"%(libURL)s/lib/crypto.js",codecs:"%(libURL)s/lib/codecs.js",jsonrpc:"%(libURL)s/lib/jsonrpc.js",lang:"%(libURL)s/lib/lang.js",iter:"%(libURL)s/lib/iter.js",xmlrpc:"%(libURL)s/lib/xmlrpc.js"};mod.init=function(){var ws=null;try{ws=WScript;}catch(e){}
if(ws!=null){initWS();}}
var initWS=function(){print=function(msg){WScript.echo(msg);}
alert=function(msg){print(msg);}
var args=WScript.arguments;try{if(args(0)=="--test"){var fileURL=args(1);var doTest=true;}else{var fileURL=args(0);var doTest=false;}
var baseURL=fileURL.replace(/\\/g,"/");baseURL=baseURL.split("/");baseURL=baseURL.slice(0,baseURL.length-1);mod.baseURL=baseURL.join("/");}catch(e){throw new mod.Exception("Missing script filename to be run.",e);}
urlInit=WScript.ScriptFullName;urlInit=urlInit.replace(/\\/g,"/");urlInit=urlInit.split("/");urlInit=urlInit.slice(0,urlInit.length-1);mod.libURL="file://"+urlInit.join("/");try{mod.loadScript(fileURL);}catch(e){WScript.stdErr.write("%s(1,1) jsolait runtime error:\n%s\n".format(args(0).replace("file://",""),e.toTraceString()));}
if(doTest){var modName=fileURL.split("\\");modName=modName.pop();modName=modName.slice(0,modName.length-3);modName.replace(/\//g,".");print("importing module: %s".format(modName));var m=importModule(modName);print("%s imported\ntesting...\n".format(m));m.test();print("\nfinished testing.".format(modName));}}
mod.importModule=function(name){if(mod.modules[name]){return mod.modules[name];}else{var src,modURL;if(mod.moduleURLs[name]){modURL=mod.moduleURLs[name].format(mod);}else{modURL="%s/%s.js".format(mod.baseURL,name.split(".").join("/"));}
try{src=getFile(modURL);}catch(e){throw new mod.ModuleImportFailed(name,modURL,e);}
try{globalEval(src);}catch(e){throw new mod.ModuleImportFailed(name,modURL,e);}
return mod.modules[name];}}
importModule=mod.importModule;mod.loadScript=function(url){var src=getFile(url);try{globalEval(src);}catch(e){throw new mod.EvalFailed(url,e);}}
mod.registerModule=function(module){this.modules[module.name]=module;}
var getHTTP=function(){var obj;try{obj=new XMLHttpRequest();}catch(e){try{obj=new ActiveXObject("Msxml2.XMLHTTP.4.0");}catch(e){try{obj=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{obj=new ActiveXObject("microsoft.XMLHTTP");}catch(e){throw new mod.Exception("Unable to get an HTTP request object.");}}}}
return obj;}
var getFile=function(url,headers){headers=(headers!=null)?headers:[];try{var xmlhttp=getHTTP();xmlhttp.open("GET",url,false);for(var i=0;i<headers.length;i++){xmlhttp.setRequestHeader(headers[i][0],headers[i][1]);}
xmlhttp.send("");}catch(e){throw new mod.Exception("Unable to load URL: '%s'.".format(url),e);}
if(xmlhttp.status==200||xmlhttp.status==0){return xmlhttp.responseText;}else{throw new mod.Exception("File not loaded: '%s'.".format(url));}}
Error.prototype.toTraceString=function(){if(this.message){return"%s\n".format(this.message);}
if(this.description){return"%s\n".format(this.description);}
return"unknown error\n";}
mod.ModuleImportFailed=Class(mod.Exception,function(publ,supr){publ.init=function(moduleName,url,trace){supr(this).init("Failed to import module: '%s' from URL:'%s'".format(moduleName,url),trace);this.moduleName=moduleName;this.url=url;}
publ.moduleName;publ.url;})
mod.EvalFailed=Class(mod.Exception,function(publ,supr){publ.init=function(url,trace){supr(this).init("File '%s' Eval of script failed.".format(url),trace);this.url=url;}
publ.url;})
mod.reportException=function(exception){if(exception.toTraceString){var s=exception.toTraceString();}else{var s=exception.toString();}
var ws=null;try{ws=WScript;}catch(e){}
if(ws!=null){WScript.stderr.write(s);}else{alert(s);}}
reportException=mod.reportException;})
Module("stringformat","0.1.0",function(mod){var FormatSpecifier=function(s){var s=s.match(/%(\(\w+\)){0,1}([ 0-]){0,1}(\+){0,1}(\d+){0,1}(\.\d+){0,1}(.)/);if(s[1]){this.key=s[1].slice(1,-1);}else{this.key=null;}
this.paddingFlag=s[2];if(this.paddingFlag==""){this.paddingFlag=" "}
this.signed=(s[3]=="+");this.minLength=parseInt(s[4]);if(isNaN(this.minLength)){this.minLength=0;}
if(s[5]){this.percision=parseInt(s[5].slice(1,s[5].length));}else{this.percision=-1;}
this.type=s[6];}
String.prototype.format=function(){var sf=this.match(/(%(\(\w+\)){0,1}[ 0-]{0,1}(\+){0,1}(\d+){0,1}(\.\d+){0,1}[dibouxXeEfFgGcrs%])|([^%]+)/g);if(sf){if(sf.join("")!=this){throw new mod.Exception("Unsupported formating string.");}}else{throw new mod.Exception("Unsupported formating string.");}
var rslt="";var s;var obj;var cnt=0;var frmt;var sign="";for(var i=0;i<sf.length;i++){s=sf[i];if(s=="%%"){s="%";}else if(s.slice(0,1)=="%"){frmt=new FormatSpecifier(s);if(frmt.key){if((typeof arguments[0])=="object"&&arguments.length==1){obj=arguments[0][frmt.key];}else{throw new mod.Exception("Object or associative array expected as formating value.");}}else{if(cnt>=arguments.length){throw new mod.Exception("Not enough arguments for format string");}else{obj=arguments[cnt];cnt++;}}
if(frmt.type=="s"){if(obj==null){obj="null";}
s=obj.toString().pad(frmt.paddingFlag,frmt.minLength);}else if(frmt.type=="c"){if(frmt.paddingFlag=="0"){frmt.paddingFlag=" ";}
if(typeof obj=="number"){s=String.fromCharCode(obj).pad(frmt.paddingFlag,frmt.minLength);}else if(typeof obj=="string"){if(obj.length==1){s=obj.pad(frmt.paddingFlag,frmt.minLength);}else{throw new mod.Exception("Character of length 1 required.");}}else{throw new mod.Exception("Character or Byte required.");}}else if(typeof obj=="number"){if(obj<0){obj=-obj;sign="-";}else if(frmt.signed){sign="+";}else{sign="";}
switch(frmt.type){case"f":case"F":if(frmt.percision>-1){s=obj.toFixed(frmt.percision).toString();}else{s=obj.toString();}
break;case"E":case"e":if(frmt.percision>-1){s=obj.toExponential(frmt.percision);}else{s=obj.toExponential();}
s=s.replace("e",frmt.type);break;case"b":s=obj.toString(2);s=s.pad("0",frmt.percision);break;case"o":s=obj.toString(8);s=s.pad("0",frmt.percision);break;case"x":s=obj.toString(16).toLowerCase();s=s.pad("0",frmt.percision);break;case"X":s=obj.toString(16).toUpperCase();s=s.pad("0",frmt.percision);break;default:s=parseInt(obj).toString();s=s.pad("0",frmt.percision);break;}
if(frmt.paddingFlag=="0"){s=s.pad("0",frmt.minLength-sign.length);}
s=sign+s;s=s.pad(frmt.paddingFlag,frmt.minLength);}else{throw new mod.Exception("Number required.");}}
rslt+=s;}
return rslt;}
String.prototype.pad=function(flag,len){var s="";if(flag=="-"){var c=" ";}else{var c=flag;}
for(var i=0;i<len-this.length;i++){s+=c;}
if(flag=="-"){s=this+s;}else{s+=this;}
return s;}
String.prototype.mul=function(c){var a=new Array(this.length*c);var s=""+this;for(var i=0;i<c;i++){a[i]=s;}
return a.join("");}})
jsolait.init();if(Function.prototype.apply==null){Function.prototype.apply=function(thisObj,args){var a=[];for(var i=0;i<args.length;i++){a[i]="args["+i+"]";}
thisObj.__apply__=this;a="thisObj.__apply__("+a.join(",")+")";var r=eval(a);delete thisObj.__apply__;return r;}}
if(Function.prototype.call==null){Function.prototype.call=function(thisObj){var args=[];for(var i=1;i<arguments.length;i++){args[i-1]=arguments[i];}
return this.apply(thisObj,args);}}
if(Array.prototype.splice==null){Array.prototype.splice=function(index,howMany){var a=this.slice(0,index);var e=this.slice(index+howMany,this.length);var r=this.slice(index,index+howMany);this.length=0;for(var i=0;i<a.length;i++){this[this.length]=a[i];}
for(var i=2;i<arguments.length;i++){this[this.length]=arguments[i];}
for(var i=0;i<e.length;i++){this[this.length]=e[i];}
return r;}}
if(Array.prototype.pop==null){Array.prototype.pop=function(){var e=this[this.length-1];this.length-=1;return e;}}
if(Array.prototype.push==null){Array.prototype.push=function(){for(var i=0;i<arguments.length;i++){this[this.length]=arguments[i];}
return this.length;}}
if(Array.prototype.shift==null){Array.prototype.shift=function(){var e=this[0];for(var i=1;i<this.length;i++){this[i-1]=this[i];}
this.length-=1;return e;}}
if(Array.prototype.unshift==null){Array.prototype.unshift=function(){var a=[]
for(var i=0;i<arguments.length;i++){a[i]=arguments[i];}
for(var i=0;i<this.length;i++){a[a.length]=this[i];}
this.length=a.length;for(var i=0;i<a.length;i++){this[i]=a[i];}
return this.length;}}
if(Number.prototype.toFixed==null){Number.prototype.toFixed=function(d){var n=this;d=d||0;var f=Math.pow(10,d);n=Math.round(f*n)/f;n=(n>=0)?n+Math.pow(10,-(d+1)):n-Math.pow(10,-(d+1));n+='';return d==0?n.substring(0,n.indexOf('.')):n.substring(0,n.indexOf('.')+d+1);}}
if(Number.prototype.toExponential==null){Number.prototype.toExponential=function(d){var n=this;var e=0;if(n!=0){e=Math.floor(Math.log(Math.abs(n))/Math.LN10);}
n/=Math.pow(10,e);if(isFinite(d)){if(Math.abs(n)+5*Math.pow(10,-(d+1))>=10.0){n/=10;e+=1;}
n=n.toFixed(d);}
n+="e";if(e>=0){n+="+";}
n+=e;return n;}}
Module("urllib","1.1.4",function(mod){mod.NoHTTPRequestObject=Class("NoHTTPRequestObject",mod.Exception,function(publ,supr){publ.init=function(trace){supr(this).init("Could not create an HTTP request object",trace);}})
mod.RequestOpenFailed=Class("RequestOpenFailed",mod.Exception,function(publ,supr){publ.init=function(trace){supr(this).init("Opening of HTTP request failed.",trace);}})
mod.SendFailed=Class("SendFailed",mod.Exception,function(publ,supr){publ.init=function(trace){supr(this).init("Sending of HTTP request failed.",trace);}})
var ASVRequest=Class("ASVRequest",function(publ){publ.init=function(){if((getURL==null)||(postURL==null)){throw"getURL and postURL are not available!";}else{this.readyState=0;this.responseText="";this.__contType="";this.status=200;}}
publ.open=function(type,url,async){if(async==false){throw"Can only open asynchronous connections!";}
this.__type=type;this.__url=url;this.readyState=0;}
publ.setRequestHeader=function(name,value){if(name=="Content-Type"){this.__contType=value;}}
publ.send=function(data){var self=this;var cbh=new Object();cbh.operationComplete=function(rsp){self.readyState=4;self.responseText=rsp.content;if(this.ignoreComplete==false){if(self.onreadystatechange){self.onreadystatechange();}}}
cbh.ignoreComplete=false;try{if(this.__type=="GET"){getURL(this.__url,cbh);}else if(this.__type=="POST"){postURL(this.__url,data,cbh,this.__contType);}}catch(e){cbh.ignoreComplete=true;throw e;}}})
var getHTTP=function(){var obj;try{obj=new XMLHttpRequest();}catch(e){try{obj=new ActiveXObject("Msxml2.XMLHTTP.4.0");}catch(e){try{obj=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{obj=new ActiveXObject("microsoft.XMLHTTP");}catch(e){try{obj=new ASVRequest();}catch(e){throw new mod.NoHTTPRequestObject("Neither Mozilla, IE nor ASV found. Can't do HTTP request without them.");}}}}}
return obj;}
mod.sendRequest=function(type,url,user,pass,data,headers,callback){var async=false;if(arguments[arguments.length-1]instanceof Function){var async=true;callback=arguments[arguments.length-1];}
var headindex=arguments.length-((async||arguments[arguments.length-1]==null)?2:1);if(arguments[headindex]instanceof Array){headers=arguments[headindex];}else{headers=[];}
if(typeof user=="string"&&typeof pass=="string"){if(typeof data!="string"){data="";}}else if(typeof user=="string"){data=user;user=null;pass=null;}else{user=null;pass=null;}
var xmlhttp=getHTTP();try{if(user!=null){xmlhttp.open(type,url,async,user,pass);}else{xmlhttp.open(type,url,async);}}catch(e){throw new mod.RequestOpenFailed(e);}
for(var i=0;i<headers.length;i++){try{xmlhttp.setRequestHeader(headers[i][0],headers[i][1]);}catch(e){}}
if(async){xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){callback(xmlhttp);xmlhttp=null;}else if(xmlhttp.readyState==2){try{var isNetscape=netscape;try{var s=xmlhttp.status;}catch(e){callback(xmlhttp);xmlhttp=null;}}catch(e){}}}}
try{xmlhttp.send(data);}catch(e){if(async){callback(xmlhttp,e);xmlhttp=null;}else{throw new mod.SendFailed(e);}}
return xmlhttp;}
mod.getURL=function(url,user,pass,headers,callback){var a=new Array("GET");for(var i=0;i<arguments.length;i++){a.push(arguments[i]);}
return mod.sendRequest.apply(this,a)}
mod.postURL=function(url,user,pass,data,headers,callback){var a=new Array("POST");for(var i=0;i<arguments.length;i++){a.push(arguments[i]);}
return mod.sendRequest.apply(this,a)}})
Module("xml","1.1.2",function(mod){mod.NoXMLParser=Class("NoXMLParser",mod.Exception,function(publ,supr){publ.init=function(trace){supr(this).init("Could not create an XML parser.",trace);}})
mod.ParsingFailed=Class("ParsingFailed",mod.Exception,function(publ,supr){publ.init=function(xml,trace){supr(this).init("Failed parsing XML document.",trace);this.xml=xml;}
publ.xml;})
mod.parseXML=function(xml){var obj=null;var isMoz=false;var isIE=false;var isASV=false;try{var p=window.parseXML;if(p==null){throw"No ASV paseXML";}
isASV=true;}catch(e){try{obj=new DOMParser();isMoz=true;}catch(e){try{obj=new ActiveXObject("Msxml2.DomDocument.4.0");isIE=true;}catch(e){try{obj=new ActiveXObject("Msxml2.DomDocument");isIE=true;}catch(e){try{obj=new ActiveXObject("microsoft.XMLDOM");isIE=true;}catch(e){throw new mod.NoXMLParser(e);}}}}}
try{if(isMoz){obj=obj.parseFromString(xml,"text/xml");return obj;}else if(isIE){obj.loadXML(xml);return obj;}else if(isASV){return window.parseXML(xml,null);}}catch(e){throw new mod.ParsingFailed(xml,e);}}
mod.importNode=function(importedNode,deep){deep=(deep==null)?true:deep;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;var importChildren=function(srcNode,parent){if(deep){for(var i=0;i<srcNode.childNodes.length;i++){var n=mod.importNode(srcNode.childNodes.item(i),true);parent.appendChild(n);}}}
var node=null;switch(importedNode.nodeType){case ATTRIBUTE_NODE:node=document.createAttributeNS(importedNode.namespaceURI,importedNode.nodeName);node.value=importedNode.value;break;case DOCUMENT_FRAGMENT_NODE:node=document.createDocumentFragment();importChildren(importedNode,node);break;case ELEMENT_NODE:node=document.createElementNS(importedNode.namespaceURI,importedNode.tagName);for(var i=0;i<importedNode.attributes.length;i++){var attr=this.importNode(importedNode.attributes.item(i),deep);node.setAttributeNodeNS(attr);}
importChildren(importedNode,node);break;case ENTITY_REFERENCE_NODE:node=importedNode;break;case PROCESSING_INSTRUCTION_NODE:node=document.createProcessingInstruction(importedNode.target,importedNode.data);break;case TEXT_NODE:case CDATA_SECTION_NODE:case COMMENT_NODE:node=document.createTextNode(importedNode.nodeValue);break;case DOCUMENT_NODE:case DOCUMENT_TYPE_NODE:case NOTATION_NODE:case ENTITY_NODE:throw"not supported in DOM2";break;}
return node;}
mod.node2XML=function(node){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;var s="";switch(node.nodeType){case ATTRIBUTE_NODE:s+=node.nodeName+'="'+node.value+'"';break;case DOCUMENT_NODE:s+=this.node2XML(node.documentElement);break;case ELEMENT_NODE:s+="<"+node.tagName;for(var i=0;i<node.attributes.length;i++){s+=" "+this.node2XML(node.attributes.item(i));}
if(node.childNodes.length==0){s+="/>\n";}else{s+=">";for(var i=0;i<node.childNodes.length;i++){s+=this.node2XML(node.childNodes.item(i));}
s+="</"+node.tagName+">\n";}
break;case PROCESSING_INSTRUCTION_NODE:s+="<?"+node.target+" "+node.data+" ?>";break;case TEXT_NODE:s+=node.nodeValue;break;case CDATA_SECTION_NODE:s+="<"+"![CDATA["+node.nodeValue+"]"+"]>";break;case COMMENT_NODE:s+="<!--"+node.nodeValue+"-->";break;case ENTITY_REFERENCE_NODE:case DOCUMENT_FRAGMENT_NODE:case DOCUMENT_TYPE_NODE:case NOTATION_NODE:case ENTITY_NODE:throw new mod.Exception("Nodetype(%s) not supported.".format(node.nodeType));break;}
return s;}})
Module("xmlrpc","1.3.3",function(mod){var xmlext=importModule("xml");var urllib=importModule("urllib");mod.InvalidServerResponse=Class("InvalidServerResponse",mod.Exception,function(publ,supr){publ.init=function(status){supr(this).init("The server did not respond with a status 200 (OK) but with: "+status);this.status=status;}
publ.status;})
mod.MalformedXmlRpc=Class("MalformedXmlRpc",mod.Exception,function(publ,supr){publ.init=function(msg,xml,trace){supr(this).init(msg,trace);this.xml=xml;}
publ.xml;})
mod.Fault=Class("Fault",mod.Exception,function(publ,supr){publ.init=function(faultCode,faultString){supr(this).init("XML-RPC Fault: "+faultCode+"\n\n"+faultString);this.faultCode=faultCode;this.faultString=faultString;}
publ.faultCode;publ.faultString;})
mod.marshall=function(obj){if(obj.toXmlRpc){return obj.toXmlRpc();}else{var s="<struct>";for(var attr in obj){if(typeof obj[attr]!="function"){s+="<member><name>"+attr+"</name><value>"+mod.marshall(obj[attr])+"</value></member>";}}
s+="</struct>";return s;}}
mod.unmarshall=function(xml){try{var doc=xmlext.parseXML(xml);}catch(e){throw new mod.MalformedXmlRpc("The server's response could not be parsed.",xml,e);}
var rslt=mod.unmarshallDoc(doc,xml);doc=null;return rslt;}
mod.unmarshallDoc=function(doc,xml){try{var node=doc.documentElement;if(node==null){throw new mod.MalformedXmlRpc("No documentElement found.",xml);}
switch(node.tagName){case"methodResponse":return parseMethodResponse(node);case"methodCall":return parseMethodCall(node);default:throw new mod.MalformedXmlRpc("'methodCall' or 'methodResponse' element expected.\nFound: '"+node.tagName+"'",xml);}}catch(e){if(e instanceof mod.Fault){throw e;}else{throw new mod.MalformedXmlRpc("Unmarshalling of XML failed.",xml,e);}}}
var parseMethodResponse=function(node){try{for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes.item(i);if(child.nodeType==1){switch(child.tagName){case"fault":throw parseFault(child);case"params":var params=parseParams(child);if(params.length==1){return params[0];}else{throw new mod.MalformedXmlRpc("'params' element inside 'methodResponse' must have exactly ONE 'param' child element.\nFound: "+params.length);}
default:throw new mod.MalformedXmlRpc("'fault' or 'params' element expected.\nFound: '"+child.tagName+"'");}}}
throw new mod.MalformedXmlRpc("No child elements found.");}catch(e){if(e instanceof mod.Fault){throw e;}else{throw new mod.MalformedXmlRpc("'methodResponse' element could not be parsed.",null,e);}}}
var parseMethodCall=function(node){try{var methodName=null;var params=new Array();for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes.item(i);if(child.nodeType==1){switch(child.tagName){case"methodName":methodName=new String(child.firstChild.nodeValue);break;case"params":params=parseParams(child);break;default:throw new mod.MalformedXmlRpc("'methodName' or 'params' element expected.\nFound: '"+child.tagName+"'");}}}
if(methodName==null){throw new mod.MalformedXmlRpc("'methodName' element expected.");}else{return new Array(methodName,params);}}catch(e){throw new mod.MalformedXmlRpc("'methodCall' element could not be parsed.",null,e);}}
var parseParams=function(node){try{var params=new Array();for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes.item(i);if(child.nodeType==1){switch(child.tagName){case"param":params.push(parseParam(child));break;default:throw new mod.MalformedXmlRpc("'param' element expected.\nFound: '"+child.tagName+"'");}}}
return params;}catch(e){throw new mod.MalformedXmlRpc("'params' element could not be parsed.",null,e);}}
var parseParam=function(node){try{for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes.item(i);if(child.nodeType==1){switch(child.tagName){case"value":return parseValue(child);default:throw new mod.MalformedXmlRpc("'value' element expected.\nFound: '"+child.tagName+"'");}}}
throw new mod.MalformedXmlRpc("'value' element expected.But none found.");}catch(e){throw new mod.MalformedXmlRpc("'param' element could not be parsed.",null,e);}}
var parseValue=function(node){try{for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes.item(i);if(child.nodeType==1){switch(child.tagName){case"string":var s=""
for(var j=0;j<child.childNodes.length;j++){s+=new String(child.childNodes.item(j).nodeValue);}
return s;case"int":case"i4":case"double":return(child.firstChild)?new Number(child.firstChild.nodeValue):0;case"boolean":return Boolean(isNaN(parseInt(child.firstChild.nodeValue))?(child.firstChild.nodeValue=="true"):parseInt(child.firstChild.nodeValue));case"base64":return parseBase64(child);case"dateTime.iso8601":return parseDateTime(child);case"array":return parseArray(child);case"struct":return parseStruct(child);case"nil":return null;default:throw new mod.MalformedXmlRpc("'string','int','i4','double','boolean','base64','dateTime.iso8601','array' or 'struct' element expected.\nFound: '"+child.tagName+"'");}}}
if(node.firstChild){var s=""
for(var j=0;j<node.childNodes.length;j++){s+=new String(node.childNodes.item(j).nodeValue);}
return s;}else{return"";}}catch(e){throw new mod.MalformedXmlRpc("'value' element could not be parsed.",null,e);}}
var parseBase64=function(node){try{var s=node.firstChild.nodeValue;return s.decode("base64");}catch(e){throw new mod.MalformedXmlRpc("'base64' element could not be parsed.",null,e);}}
var parseDateTime=function(node){try{if(/^(\d{4})-?(\d{2})-?(\d{2})T(\d{2}):?(\d{2}):?(\d{2})/.test(node.firstChild.nodeValue)){return new Date(Date.UTC(RegExp.$1,RegExp.$2-1,RegExp.$3,RegExp.$4,RegExp.$5,RegExp.$6));}else{throw new mod.MalformedXmlRpc("Could not convert the given date.");}}catch(e){throw new mod.MalformedXmlRpc("'dateTime.iso8601' element could not be parsed.",null,e);}}
var parseArray=function(node){try{for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes.item(i);if(child.nodeType==1){switch(child.tagName){case"data":return parseData(child);default:throw new mod.MalformedXmlRpc("'data' element expected.\nFound: '"+child.tagName+"'");}}}
throw new mod.MalformedXmlRpc("'data' element expected. But not found.");}catch(e){throw new mod.MalformedXmlRpc("'array' element could not be parsed.",null,e);}}
var parseData=function(node){try{var rslt=new Array();for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes.item(i);if(child.nodeType==1){switch(child.tagName){case"value":rslt.push(parseValue(child));break;default:throw new mod.MalformedXmlRpc("'value' element expected.\nFound: '"+child.tagName+"'");}}}
return rslt;}catch(e){throw new mod.MalformedXmlRpc("'data' element could not be parsed.",null,e);}}
var parseStruct=function(node){try{var struct=new Object();for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes.item(i);if(child.nodeType==1){switch(child.tagName){case"member":var member=parseMember(child);if(member[0]!=""){struct[member[0]]=member[1];}
break;default:throw new mod.MalformedXmlRpc("'data' element expected.\nFound: '"+child.tagName+"'");}}}
return struct;}catch(e){throw new mod.MalformedXmlRpc("'struct' element could not be parsed.",null,e);}}
var parseMember=function(node){try{var name="";var value=null;for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes.item(i);if(child.nodeType==1){switch(child.tagName){case"value":value=parseValue(child);break;case"name":if(child.hasChildNodes()){name=new String(child.firstChild.nodeValue);}
break;default:throw new mod.MalformedXmlRpc("'value' or 'name' element expected.\nFound: '"+child.tagName+"'");}}}
return[name,value];}catch(e){throw new mod.MalformedXmlRpc("'member' element could not be parsed.",null,e);}}
var parseFault=function(node){try{for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes.item(i);if(child.nodeType==1){switch(child.tagName){case"value":var flt=parseValue(child);return new mod.Fault(flt.faultCode,flt.faultString);default:throw new mod.MalformedXmlRpc("'value' element expected.\nFound: '"+child.tagName+"'");}}}
throw new mod.MalformedXmlRpc("'value' element expected. But not found.");}catch(e){throw new mod.MalformedXmlRpc("'fault' element could not be parsed.",null,e);}}
mod.XMLRPCMethod=Class("XMLRPCMethod",function(publ){var postData=function(url,user,pass,data,callback){if(callback==null){var rslt=urllib.postURL(url,user,pass,data,[["Content-Type","text/xml"]]);return rslt;}else{urllib.postURL(url,user,pass,data,[["Content-Type","text/xml"]],callback);}}
var handleResponse=function(resp){var status=null;try{status=resp.status;}catch(e){}
if(status==200){var respDoc=null;try{respDoc=resp.responseXML;}catch(e){}
var respTxt="";try{respTxt=resp.responseText;}catch(e){}
if(respDoc==null){if(respTxt==null||respTxt==""){throw new mod.MalformedXmlRpc("The server responded with an empty document.","");}else{return mod.unmarshall(respTxt);}}else{return mod.unmarshallDoc(respDoc,respTxt);}}else{throw new mod.InvalidServerResponse(status);}}
var getXML=function(methodName,args){var data='<?xml version="1.0"?><methodCall><methodName>'+methodName+'</methodName>';if(args.length>0){data+="<params>";for(var i=0;i<args.length;i++){data+='<param><value>'+mod.marshall(args[i])+'</value></param>';}
data+='</params>';}
data+='</methodCall>';return data;}
publ.init=function(url,methodName,user,pass){var fn=function(){if(typeof arguments[arguments.length-1]!="function"){var data=getXML(fn.methodName,arguments);var resp=postData(fn.url,fn.user,fn.password,data);return handleResponse(resp);}else{var args=new Array();for(var i=0;i<arguments.length;i++){args.push(arguments[i]);}
var cb=args.pop();var data=getXML(fn.methodName,args);postData(fn.url,fn.user,fn.password,data,function(resp){var rslt=null;var exc=null;try{rslt=handleResponse(resp);}catch(e){exc=e;}
try{cb(rslt,exc);}catch(e){}
args=null;resp=null;});}}
fn.methodName=methodName;fn.url=url;fn.user=user;fn.password=pass;fn.toMulticall=this.toMulticall;fn.toString=this.toString;fn.setAuthentication=this.setAuthentication;fn.constructor=this.constructor;return fn;}
publ.toMulticall=function(){var multiCallable=new Object();multiCallable.methodName=this.methodName;var params=[];for(var i=0;i<arguments.length;i++){params[i]=arguments[i];}
multiCallable.params=params;return multiCallable;}
publ.setAuthentication=function(user,pass){this.user=user;this.password=pass;}
publ.methodName;publ.url;publ.user;publ.password;})
mod.ServiceProxy=Class("ServiceProxy",function(publ){publ.init=function(url,methodNames,user,pass){if(methodNames instanceof Array){if(methodNames.length>0){var tryIntrospection=false;}else{var tryIntrospection=true;}}else{pass=user;user=methodNames;methodNames=[];var tryIntrospection=true;}
this._url=url;this._user=user;this._password=pass;this._addMethodNames(methodNames);if(tryIntrospection){try{this._introspect();}catch(e){}}}
publ._addMethodNames=function(methodNames){for(var i=0;i<methodNames.length;i++){var obj=this;var names=methodNames[i].split(".");for(var n=0;n<names.length-1;n++){var name=names[n];if(obj[name]){obj=obj[name];}else{obj[name]=new Object();obj=obj[name];}}
var name=names[names.length-1];if(obj[name]){}else{var mth=new mod.XMLRPCMethod(this._url,methodNames[i],this._user,this._password);obj[name]=mth;this._methods.push(mth);}}}
publ._setAuthentication=function(user,pass){this._user=user;this._password=pass;for(var i=0;i<this._methods.length;i++){this._methods[i].setAuthentication(user,pass);}}
publ._introspect=function(){this._addMethodNames(["system.listMethods","system.methodHelp","system.methodSignature"]);var m=this.system.listMethods();this._addMethodNames(m);}
publ._url;publ._user;publ._password;publ._methods=new Array();})
mod.ServerProxy=mod.ServiceProxy;String.prototype.toXmlRpc=function(){return"<string>"+this.replace(/&/g,"&amp;").replace(/</g,"&lt;")+"</string>";}
Number.prototype.toXmlRpc=function(){if(this==parseInt(this)){return"<int>"+this+"</int>";}else if(this==parseFloat(this)){return"<double>"+this+"</double>";}else{return false.toXmlRpc();}}
Boolean.prototype.toXmlRpc=function(){if(this==true){return"<boolean>1</boolean>";}else{return"<boolean>0</boolean>";}}
Date.prototype.toXmlRpc=function(){var padd=function(s,p){s=p+s
return s.substring(s.length-p.length)}
var y=padd(this.getUTCFullYear(),"0000");var m=padd(this.getUTCMonth()+1,"00");var d=padd(this.getUTCDate(),"00");var h=padd(this.getUTCHours(),"00");var min=padd(this.getUTCMinutes(),"00");var s=padd(this.getUTCSeconds(),"00");var isodate=y+m+d+"T"+h+":"+min+":"+s
return"<dateTime.iso8601>"+isodate+"</dateTime.iso8601>";}
Array.prototype.toXmlRpc=function(){var retstr="<array><data>";for(var i=0;i<this.length;i++){retstr+="<value>"+mod.marshall(this[i])+"</value>";}
return retstr+"</data></array>";}
mod.test=function(){print("creating ServiceProxy object using introspection for method construction...\n");var s=new mod.ServiceProxy("http://localhost/testx.py");print("%s created\n".format(s));print("creating and marshalling test data:\n");var o=[1.234,5,{a:"Hello & < ",b:new Date()}];print(mod.marshall(o));print("\ncalling echo() on remote service...\n");var r=s.echo(o);print("service returned data(marshalled again):\n")
print(mod.marshall(r));}})
Module("jsonrpc","0.4.2",function(mod){var urllib=importModule("urllib");mod.InvalidServerResponse=Class(mod.Exception,function(publ,supr){publ.init=function(status){supr(this).init("The server did not respond with a status 200 (OK) but with: "+status);this.status=status;}
publ.status;})
mod.MalformedJSONRpc=Class(mod.Exception,function(publ,supr){publ.init=function(msg,s,trace){supr(this).init(msg,trace);this.source=s;}
publ.source;})
mod.JSONRPCError=Class(mod.Exception,function(publ,supr){publ.init=function(err,trace){supr(this).init(err,trace);}})
mod.marshall=function(obj){if(obj==null){return"null";}else if(obj.toJSON){return obj.toJSON();}else{var v=[];for(var attr in obj){if(typeof obj[attr]!="function"){v.push('"'+attr+'": '+mod.marshall(obj[attr]));}}
return"{"+v.join(", ")+"}";}}
mod.unmarshall=function(source){try{var obj;eval("obj="+source);return obj;}catch(e){throw new mod.MalformedJSONRpc("The server's response could not be parsed.",source,e);}}
mod.JSONRPCMethod=Class(function(publ){var postData=function(url,user,pass,data,callback){if(callback==null){var rslt=urllib.postURL(url,user,pass,data,[["Content-Type","text/plain"]]);return rslt;}else{urllib.postURL(url,user,pass,data,[["Content-Type","text/xml"]],callback);}}
var handleResponse=function(resp){var status=null;try{status=resp.status;}catch(e){}
if(status==200){var respTxt="";try{respTxt=resp.responseText;}catch(e){}
if(respTxt==null||respTxt==""){throw new mod.MalformedJSONRpc("The server responded with an empty document.","");}else{var rslt=mod.unmarshall(respTxt);if(rslt.error!=null){throw new mod.JSONRPCError(rslt.error);}else{return rslt.result;}}}else{throw new mod.InvalidServerResponse(status);}}
var jsonRequest=function(id,methodName,args){var p=[mod.marshall(id),mod.marshall(methodName),mod.marshall(args)];return'{"id":'+p[0]+', "method":'+p[1]+', "params":'+p[2]+"}";}
publ.init=function(url,methodName,user,pass){var fn=function(){var args=new Array();for(var i=0;i<arguments.length;i++){args.push(arguments[i]);}
if(typeof arguments[arguments.length-1]!="function"){var data=jsonRequest("httpReq",fn.methodName,args);var resp=postData(fn.url,fn.user,fn.password,data);return handleResponse(resp);}else{var cb=args.pop();var data=jsonRequest("httpReq",fn.methodName,args);postData(fn.url,fn.user,fn.password,data,function(resp){var rslt=null;var exc=null;try{rslt=handleResponse(resp);}catch(e){exc=e;}
try{cb(rslt,exc);}catch(e){}
args=null;resp=null;});}}
fn.methodName=methodName;fn.notify=this.notify;fn.url=url;fn.user=user;fn.password=pass;fn.toString=this.toString;fn.setAuthentication=this.setAuthentication;fn.constructor=this.constructor;return fn;}
publ.setAuthentication=function(user,pass){this.user=user;this.password=pass;}
publ.notify=function(){var args=new Array();for(var i=0;i<arguments.length;i++){args.push(arguments[i]);}
var data=jsonRequest(null,this.methodName,args);postData(this.url,this.user,this.password,data,function(resp){});}
publ.methodName;publ.url;publ.user;publ.password;})
mod.ServiceProxy=Class("ServiceProxy",function(publ){publ.init=function(url,methodNames,user,pass){this._url=url;this._user=user;this._password=pass;this._addMethodNames(methodNames);}
publ._addMethodNames=function(methodNames){for(var i=0;i<methodNames.length;i++){var obj=this;var names=methodNames[i].split(".");for(var n=0;n<names.length-1;n++){var name=names[n];if(obj[name]){obj=obj[name];}else{obj[name]=new Object();obj=obj[name];}}
var name=names[names.length-1];if(obj[name]){}else{var mth=new mod.JSONRPCMethod(this._url,methodNames[i],this._user,this._password);obj[name]=mth;this._methods.push(mth);}}}
publ._setAuthentication=function(user,pass){this._user=user;this._password=pass;for(var i=0;i<this._methods.length;i++){this._methods[i].setAuthentication(user,pass);}}
publ._url;publ._user;publ._password;publ._methods=new Array();})
mod.ServerProxy=mod.ServiceProxy;String.prototype.toJSON=function(){var s='"'+this.replace(/(["\\])/g,'\\$1')+'"';s=s.replace(/(\n)/g,"\\n");return s;}
Number.prototype.toJSON=function(){return this.toString();}
Boolean.prototype.toJSON=function(){return this.toString();}
Date.prototype.toJSON=function(){var padd=function(s,p){s=p+s
return s.substring(s.length-p.length)}
var y=padd(this.getUTCFullYear(),"0000");var m=padd(this.getUTCMonth()+1,"00");var d=padd(this.getUTCDate(),"00");var h=padd(this.getUTCHours(),"00");var min=padd(this.getUTCMinutes(),"00");var s=padd(this.getUTCSeconds(),"00");var isodate=y+m+d+"T"+h+":"+min+":"+s;return'{"jsonclass":["sys.ISODate", ["'+isodate+'"]]}';}
Array.prototype.toJSON=function(){var v=[];for(var i=0;i<this.length;i++){v.push(mod.marshall(this[i]));}
return"["+v.join(", ")+"]";}
mod.test=function(){try{print("creating ServiceProxy object using introspection for method construction...\n");var s=new mod.ServiceProxy("http://localhost/testj.py",["echo"]);print("%s created\n".format(s));print("creating and marshalling test data:\n");var o=[1.234,5,{a:"Hello ' \" World",b:new Date()}];print(mod.marshall(o));print("\ncalling echo() on remote service...\n");var r=s.echo(o);print("service returned data(marshalled again):\n")
print(mod.marshall(r));}catch(e){reportException(e);}}})
function setReplyID(yc_id){findObj('yc_reply_id').value=yc_id;}
var yourCornerMessagesList;function editThis(a,b)
{if(b=='demo')
{findObj('note_my_corner').style.display='none';findObj('note_my_corner_edit').style.display='block';findObj('edit_but').style.display='none';findObj('save_but').style.display='block';findObj('cancel_but').style.display='block';findObj('your_corner_edit_txt').focus();}else if(b=='guest')
{findObj('note_my_corner').style.display='none';findObj('note_my_corner_edit').style.display='block';findObj('edit_but').style.display='none';findObj('save_but').style.display='block';findObj('cancel_but').style.display='block';findObj('your_corner_edit_txt').focus();findObj('yclogin').style.display='none';createCookie("mt_guest","yes",1);}else{if(chklogin())
{findObj('note_my_corner').style.display='none';findObj('note_my_corner_edit').style.display='block';findObj('edit_but').style.display='none';findObj('save_but').style.display='block';findObj('cancel_but').style.display='block';findObj('your_corner_edit_txt').focus();}
else
{findObj('yclogin').style.display='';}}}
function closeLogin(){findObj('yclogin').style.display='none';}
function chklogin(){if(readCookie("mt_username")&&readCookie("mt_uid")&&readCookie("mt_sid")){return true;}
else{return false;}}
function logout(){eraseCookie("mt_username");eraseCookie("mt_uid");eraseCookie("mt_sid");findObj('logged_in_box').style.display='none';if(AjaxFuntionController=="product"){findObj('tags_suggestions').style.display="none";findObj('add_tags_box').style.display='none';findObj('yclogin').style.display='none';}
if(AjaxFuntionController=="userpage"){findObj('add_comment_box').style.display='none';findObj('yclogin').style.display='none';findObj('yc_history').style.display='none';}
if(findObj('yc_login_form'))
{findObj('yc_login_form').reset();if(AjaxFuntionController=="yourCorner")
cancelYourCorner();}
if(AjaxFuntionController=="userprofile")
location.href='/';}
function cancelYourCorner()
{findObj('note_my_corner').style.backgroundColor="#ffffff";findObj('note_my_corner').style.display='block';findObj('note_my_corner_edit').style.display='none';findObj('edit_but').style.display='';findObj('save_but').style.display='none';findObj('cancel_but').style.display='none';}
function highlightMe(b)
{switch(b.style.backgroundColor){case"rgb(255, 248, 219)":b.style.backgroundColor="#ffffff";break;case"#fff8db":b.style.backgroundColor="#ffffff";break;case"#ffffff":b.style.backgroundColor="#fff8db";break;case"rgb(255, 255, 255)":b.style.backgroundColor="#fff8db";break;}}
function getHistory(id,type,page)
{findObj('yc_history').style.display='';findObj('yc_history').style.visibility='visible';if(historyUptoDate==false||page!=1){jsonrpc.methodName="getHistory";jsonrpc(new Array(id,type,page),getHistoryCB);}}
function forgotP(){findObj('login_box').style.display='none';findObj('forgot_pass_tb').style.display='';}
function gobackS(){findObj('login_box').style.display='';findObj('forgot_pass_tb').style.display='none';}
function forgot(){rpc.methodName="montred.forgotP";rpc(new Array(findObj('email_id_2').value),forgotCB);}
function forgotCB(a,b)
{if(!a.result)
{findObj('yc_msg_2').style.display='';findObj('yc_msg_2').innerHTML=a.message;}
else
{findObj('yc_msg_2').style.display='none';findObj('tr_1').style.display='none';findObj('tr_2').style.display='none';findObj('tr_3').style.display='none';findObj('fp_em').innerHTML=a.message;findObj('tr_4').style.display='';findObj('yc_login_form').reset();}}
function resetFP(){findObj('yc_msg_2').style.display='none';findObj('tr_1').style.display='';findObj('tr_2').style.display='';findObj('tr_3').style.display='';findObj('tr_4').style.display='none';}
function signup(){if(!document.MM_returnValue)
return false;if(findObj('password').value!=findObj('verify_password').value)
{alert('The passwords do not match!');return false;}
findObj('yc_msg').style.display='';findObj('yc_msg').innerHTML="Loading....Please wait!";rpc.methodName="montred.signup";rpc(new Array(findObj('login_name').value,findObj('password').value,findObj('email_id').value,findObj('recv_news').checked),signupCB);}
function signupCB(a,b)
{if(!a.result)
{findObj('yc_msg').style.display='';findObj('yc_msg').innerHTML=a.message;}
else
{createCookie("mt_username",a.message,1);createCookie("mt_uid",a.uid,1);createCookie("mt_sid",a.sid,1);findObj('yclogin').style.display='none';findObj('yc_login_form').reset();findObj('login_nm_span').innerHTML=a.message;findObj('login_nm_span_users_page').innerHTML='<a href="/user-'+a.message+'.html" style="font-size:11px;text-decoration:underline;cursor:pointer;color:#4c4c4c;">View '+a.message+'\'s page</a>';findObj('logged_in_box').style.display='';if(AjaxFuntionController=="yourCorner")
editThis(findObj('note_my_corner'));if(AjaxFuntionController=="product")
addTags();if(AjaxFuntionController=="userpage")
addcomment(this,'');}}
function login(){if(!document.MM_returnValue)
return false;findObj('yc_msg').style.display='';findObj('yc_msg').innerHTML="Logging in....Please wait!";rpc.methodName="montred.login";rpc(new Array(findObj('login_name').value,findObj('password').value),loginCB);}
function loginCB(a,b)
{if(b)
alert("Please try again later!");else if(a.result)
{createCookie("mt_username",a.message,1);createCookie("mt_uid",a.uid,1);createCookie("mt_sid",a.sid,1);if(AjaxFuntionController=="userprofile")
location.href='userprofile-'+a.message+'.html';findObj('yclogin').style.display='none';findObj('login_nm_span').innerHTML=findObj('login_name').value;findObj('login_nm_span_users_page').innerHTML='<a href="/user-'+findObj('login_name').value+'.html" style="font-size:11px;text-decoration:underline;cursor:pointer;color:#4c4c4c;">View '+findObj('login_name').value+'\'s page</a>';findObj('logged_in_box').style.display='';if(AjaxFuntionController=="yourCorner")
editThis(findObj('note_my_corner'));if(AjaxFuntionController=="product")
addTags();if(AjaxFuntionController=="userpage")
addcomment(this,'');}
else
findObj('yc_msg').innerHTML="Username or password is incorrect! Please re-enter.";}
function closeHistory()
{findObj('yc_history').style.visibility='hidden';}
function getHistoryCB(a,b)
{var txt='';if(Math.ceil(a.total_count/10)>1){var mytxt='<font style="font-size: 11px; color: #4c4c4c;"><b>Page</b> &nbsp; ';}else{var mytxt='';}
for(i=0;i<a.result.length;i++)
{if (a.result[i].name!="guest"){txt+='<div>'+a.result[i].message+'<br><br clear=all><b><a href="/user-'+a.result[i].name+'.html" style="color:#4c4c4c;text-decoration:underline;">'+a.result[i].name+'</a></b><i>'+a.result[i].time+'</i><br clear=all></div>';}else{txt += '<div>'+a.result[i].message+'<br><br clear=all><b>'+a.result[i].name+'</b><i>'+a.result[i].time+'</i><br clear=all></div>';}}
if(Math.ceil(a.total_count/10)>1){for(i=1;i<=Math.ceil(a.total_count/10);i++)
{if(i==a.current){mytxt+=''+i+' &nbsp;';}else{mytxt+='<a href="Javascript:;" onClick="getHistory('+a.id+',\''+a.type+'\','+i+');" style="color: #4c4c4c; font-size: 11px; text-decoration: underline;">'+i+'</a> &nbsp;';}}}
if(Math.ceil(a.total_count/10)>1){mytxt+='</font>';}
findObj('ychistorytd').innerHTML=txt;findObj('ycnavigationtd').innerHTML=mytxt;if(a.current==1){historyUptoDate=true;}else{historyUptoDate=false;}
urchinTracker("/history-"+a.type+"-"+a.id+"-"+i+".html");}
function saveYourCorner(a){if(findObj('your_corner_edit_txt').value.length>500)
{alert('The maximum character length is 500. Please try with less characters. Thanks.');return false;}
if(findObj('your_corner_edit_txt').value.length<10)
{alert('The minimum character length is 10. Please try with more characters. Thanks.');return false;}
if(!checkForPossibleAttack()){alert('Server Busy! Please try later. Thanks.');return false;}
rpc.methodName="montred.saveYC";txt=findObj('your_corner_edit_txt').value;type=findObj('yc_type').value;yc_id=findObj('yc_id').value;yc_reply_id=findObj('yc_reply_id').value;yourCornerMessagesList=findObj('note_my_corner').innerHTML;findObj('note_my_corner').innerHTML="Saving...Please wait!";findObj('note_my_corner').style.display='block';findObj('note_my_corner_edit').style.display='none';if(readCookie("mt_guest")){rpc(new Array(yc_id,type,txt,'guest',21,findObj('whatIsThisPageURL').value,yc_reply_id),saveYourCornerCB);}
else if(a=='demo')
rpc(new Array(yc_id,type,txt,'guest',21,findObj('whatIsThisPageURL').value,yc_reply_id),saveYourCornerCB);else
rpc(new Array(yc_id,type,txt,readCookie('mt_username'),readCookie('mt_uid'),findObj('whatIsThisPageURL').value,yc_reply_id),saveYourCornerCB);}
function saveYourCornerCB(a,b)
{if(b)
{alert(b);findObj('note_my_corner').innerHTML=yourCornerMessagesList;findObj('edit_but').style.display='';findObj('save_but').style.display='none';findObj('cancel_but').style.display='none';}
else if(a.error){alert(a.error);findObj('note_my_corner').innerHTML=yourCornerMessagesList;findObj('edit_but').style.display='';findObj('save_but').style.display='none';findObj('cancel_but').style.display='none';}
else if(a){var temptxt;var d=new Date();var months=new Array(13);months[0]="Jan";months[1]="Feb";months[2]="Mar";months[3]="Apr";months[4]="May";months[5]="Jun";months[6]="Jul";months[7]="Aug";months[8]="Sep";months[9]="Oct";months[10]="Nov";months[11]="Dec";var d=new Date();var t_mon=d.getMonth();var monthname=months[t_mon];var t_date=d.getDate();var t_year=d.getFullYear();
if (a.userSpaceCommentCount > 0) { temptxt = '<div style="margin:0;padding:0;"><table width="267px" class="note_my_corner_div_main"><tr><td colspan=2>'+a.html+'</td></tr><tr><td align="left" valign="bottom" class="note_my_corner_div_i">'+monthname+' '+t_date+' '+t_year+'</td><td width="50%" class="note_my_corner_div_b" align="right" valign="bottom">'; if(readCookie('mt_username')) { temptxt += '<a href="/user-'+readCookie('mt_username')+'.html" style="color:#4c4c4c;text-decoration:underline;">'+readCookie('mt_username')+'</a>'; } else { temptxt += 'guest'; } temptxt += '</td></tr></table></div>'; findObj('note_my_corner').innerHTML=temptxt+''+yourCornerMessagesList; } else if (a.reply==0) { temptxt = '<div style="margin:0px 0px 10px 0px;padding:0px 0px 5px 0px;" class="note_my_corner_div_main"><table width="267px"  cellspacing=0 cellpadding=0><tr><td colspan=2 style="padding-bottom:7px">'+a.html+'</td></tr><tr><td align="left" width="30%" valign="bottom" class="note_my_corner_div_b"><div onClick=\'javascript: setReplyID('+a.main_insert_id+'); editThis(findObj("note_my_corner"));\' style="color:#4c4c4c;text-decoration:underline;margin:0px;padding:0px;font-style:normal;cursor:pointer">Reply</div></td><td width="70%" class="note_my_corner_div_b" align="right" valign="bottom">'; if(readCookie('mt_username')) { temptxt += ''+monthname+' '+t_date+' '+t_year+', <a href="/user-'+readCookie('mt_username')+'.html" style="color:#4c4c4c;text-decoration:underline;">'+readCookie('mt_username')+'</a>'; } else { temptxt += ''+monthname+' '+t_date+' '+t_year+', guest'; } temptxt += '</td></tr></table><!--reply-id-'+a.main_insert_id+'--></div>'; findObj('note_my_corner').innerHTML=temptxt+''+yourCornerMessagesList; findObj('your_corner_edit_txt').value = ""; } else if (a.reply>0) { tempDIVId = '<!--reply-id-'+a.reply+'-->'; chunckedPicesYC = yourCornerMessagesList.split(tempDIVId); temptxt = '<table width="267px"><tr><td width="15%" valign=top align=center><img src="http://www.montred.com/images/your-corner-arrow.gif" style="margin:0px 3px 0px 0px"></td><td>'+a.html+'</td></tr><tr><td colspan=2 class="note_my_corner_div_b" align="right" valign="bottom">'; if(readCookie('mt_username')) { temptxt += ''+monthname+' '+t_date+' '+t_year+', <a href="/user-'+readCookie('mt_username')+'.html" style="color:#4c4c4c;text-decoration:underline;">'+readCookie('mt_username')+'</a>'; } else { temptxt += ''+monthname+' '+t_date+' '+t_year+', guest'; } temptxt += '</td></tr></table>'; findObj('note_my_corner').innerHTML= chunckedPicesYC[0]+''+temptxt+'<!--reply-id-'+a.reply+'-->'+chunckedPicesYC[1]; findObj('your_corner_edit_txt').value = ""; } else { findObj('note_my_corner').innerHTML=yourCornerMessagesList; findObj('your_corner_edit_txt').value = ""; }
findObj('edit_but').style.display='';findObj('save_but').style.display='none';findObj('cancel_but').style.display='none';historyUptoDate=false;}
if(readCookie("mt_guest"))
eraseCookie("mt_guest");}
var url='';function toggleDiv(a,c){with(a){newid="item_"+id;b=findObj(newid);if(b.style.display=='block')
{style.backgroundColor="#D8E0CB";b.style.display='none';style.backgroundImage="url("+url+"images/itm_close.gif)";}
else{style.backgroundColor="#DBE0E6";b.style.display='block';style.backgroundImage="url("+url+"images/itm_open.gif)";}}}
function mouse_over_links(obj){pos=findpos(obj);b=obj.id+"_over";c=findObj(b);c.style.left=pos.x+'px';c.style.top=pos.y+'px';c.style.display='';}
function findpos(obj){return{x:findPosX(obj),y:findPosY(obj)};}
function findPosX(obj)
{var curleft=0;if(obj.offsetParent)
{while(obj.offsetParent)
{curleft+=obj.offsetLeft
obj=obj.offsetParent;}}
else if(obj.x)
curleft+=obj.x;return curleft;}
function findPosY(obj)
{var curtop=0;if(obj.offsetParent)
{while(obj.offsetParent)
{curtop+=obj.offsetTop
obj=obj.offsetParent;}}
else if(obj.y)
curtop+=obj.y;return curtop;}
function findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x;}
// @Description (Start): Added one more field in updateQuantity function
// @Identifier: Product Upgrade
// @Author: Sunil Khedar
// @Date: August 21, 2006
function updateQuantity(a,b,c){findObj('product_id').value=b;findObj('quan').value=a;findObj('product_upgrade').value=c;document.forms.cartUpdate.submit();}
// @Description (Start): Added one more field in updateRingSize function
// @Identifier: Product Upgrade
// @Author: Sunil Khedar
// @Date: August 21, 2006
function updateRingSize(a,b,c,d){findObj('product_id').value=b;findObj('quan').value=a;findObj('ring_size').value=c;findObj('product_upgrade').value=d;document.forms.cartUpdate.submit();}
function select_price_range(a,id,cat,show)
{range=a.options[a.options.selectedIndex].value;url='cid-'+id+'-'+cat+'.html';if(a.options.selectedIndex>0){if(show)
url+="?show="+show+"&";else
url+="?";url+="range="+range;}
else{if(show)
url+="?show="+show+"&";}
window.location=url;}
function MM_openBrWindow(theURL,winName,features){window.open(theURL,winName,features);}
function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x;}
function MM_validateForm(){var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;for(i=0;i<(args.length-2);i+=3){test=args[i+2];val=MM_findObj(args[i]);if(val){nm=val.name;if((val=val.value)!=""){if(test.indexOf('isEmail')!=-1){p=val.indexOf('@');if(p<1||p==(val.length-1))errors+='- '+nm+' must contain an e-mail address.\n';}else if(test!='R'){num=parseFloat(val);if(isNaN(val))errors+='- '+nm+' must contain only integer.\n';if(test.indexOf('inRange')!=-1){p=test.indexOf(':');min=test.substring(8,p);max=test.substring(p+1);if(num<min||max<num)errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';}}}else if(test.charAt(0)=='R')errors+='- '+nm+' is required.\n';}}if(errors){alert('The following error(s) occurred:\n'+errors);}
document.MM_returnValue=(errors=='');}
function createCookie(name,value,days)
{if(days)
{var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/; domain=.montred.com";}
function readCookie(name)
{var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++)
{var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name)
{createCookie(name,"",-1);}
function chksz(a,s)
{f=s-a.value.length;if(f>-1)
{g=a.id+'_cs';findObj(g).innerHTML=f;}
else
{t=a.value;a.value=t.substr(0,200);g=a.id+'_cs';findObj(g).innerHTML=0;}}
function checkRingSize(){if(findObj('ring_size').options.selectedIndex>0)
return true;else{alert("Please select a ring size");return false;}}
function checkForPossibleAttack(){nowhistoryUpdateDate=new Date();nowhistoryUpdateTime=nowhistoryUpdateDate.getTime();if((nowhistoryUpdateDate-historyUpdateTime)>60000){historyUpdateTime=nowhistoryUpdateDate;historyUpdateRPCRequestsInMin=0;return true;}else{if(historyUpdateRPCRequestsInMin>10){return false;}else{historyUpdateRPCRequestsInMin++;return true;}}}
function MM_reloadPage(init){if(init==true)with(navigator){if((appName=="Netscape")&&(parseInt(appVersion)==4)){document.MM_pgW=innerWidth;document.MM_pgH=innerHeight;onresize=MM_reloadPage;}}
else if(innerWidth!=document.MM_pgW||innerHeight!=document.MM_pgH)location.reload();}
MM_reloadPage(true);function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x;}
function MM_showHideLayers(){var i,p,v,obj,args=MM_showHideLayers.arguments;for(i=0;i<(args.length-2);i+=3)if((obj=MM_findObj(args[i]))!=null){v=args[i+2];if(obj.style){obj=obj.style;v=(v=='show')?'visible':(v=='hide')?'hidden':v;}
obj.visibility=v;}}
var hide=true;function cm_bwcheck(){this.ver=navigator.appVersion
this.agent=navigator.userAgent.toLowerCase()
this.dom=document.getElementById?1:0
this.ns4=(!this.dom&&document.layers)?1:0;this.op=window.opera
this.moz=(this.agent.indexOf("gecko")>-1||window.sidebar)
this.ie=this.agent.indexOf("msie")>-1&&!this.op
if(this.op){this.op5=(this.agent.indexOf("opera 5")>-1||this.agent.indexOf("opera/5")>-1)
this.op6=(this.agent.indexOf("opera 6")>-1||this.agent.indexOf("opera/6")>-1)
this.op7=this.dom&&!this.op5&&!this.op6}else if(this.moz)this.ns6=1
else if(this.ie){this.ie4=!this.dom&&document.all
this.ie5=(this.agent.indexOf("msie 5")>-1)
this.ie55=(this.ie5&&this.agent.indexOf("msie 5.5")>-1)
this.ie6=this.dom&&!this.ie4&&!this.ie5&&!this.ie55}
this.mac=(this.agent.indexOf("mac")>-1)
this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.op5||this.op6||this.op7)
this.usedom=this.ns6||this.op7
this.reuse=this.ie||this.op7||this.usedom
this.px=this.dom&&!this.op5?"px":""
return this}
var bw=new cm_bwcheck();function showhide(obj,lyr)
{var x=new getObj(lyr);hide=!hide;x.style.visibility=(hide)?'hidden':'visible';setLyr(obj,lyr);}
function setLyr(obj,lyr)
{var newX=findPosX(obj);var newY=findPosY(obj)+obj.clientHeight;if(bw.op){newY+=12};if(bw.op||bw.ie)
{newX++;newY++;}
if(lyr=='testP')newY-=50;var x=new getObj(lyr);x.style.top=newY+'px';x.style.left=newX+'px';x.style.width=obj.clientWidth+'px';}
function resetmenuBG(obj)
{var obj=new getObj(obj);obj.style.backgroundColor="";}
function setmenuBG(obj)
{var obj=new getObj(obj);obj.style.backgroundColor="#ffffff";}
function findPosX(obj)
{var curleft=0;if(obj.offsetParent)
{while(obj.offsetParent)
{curleft+=obj.offsetLeft
obj=obj.offsetParent;}}
else if(obj.x)
curleft+=obj.x;return curleft;}
function findPosY(obj)
{var curtop=0;if(obj.offsetParent)
{while(obj.offsetParent)
{curtop+=obj.offsetTop
obj=obj.offsetParent;}}
else if(obj.y)
curtop+=obj.y;return curtop;}
function getObj(name)
{if(document.getElementById)
{this.obj=document.getElementById(name);this.style=document.getElementById(name).style;}
else if(document.all)
{this.obj=document.all[name];this.style=document.all[name].style;}
else if(document.layers)
{if(document.layers[name])
{this.obj=document.layers[name];this.style=document.layers[name];}
else
{this.obj=document.layers.testP.layers[name];this.style=document.layers.testP.layers[name];}}}
//@Description: Compare two email addresses.
//@Parameters: email1=>"Field name of first email address", email2=>"Field name of second email address"
//@Author: Sunil Khedar
//@Identifier: Gift Certificate
//@Date: June 01, 2006
function compareTwoEmails(email1,email2) { 
	if(findObj(email1).value != findObj(email2).value)
	{
		alert('The email addresses do not match.');
		findObj(email2).value = "";	
		findObj(email2).focus();
		return false;
	} else {
		return true;
	}
}
//@Description: Assign the drop down amount to the Gift Certificate amount.
//@Author: Sunil Khedar
//@Identifier: Gift Certificate
//@Date: June 01, 2006
function selectGiftCertificatePrice() {
	findObj('gc_amount').value = findObj('gc_amount_range').options[findObj('gc_amount_range').selectedIndex].value;	
	findObj('gc_amount_range').value = "0";
}
//@Description: Check if the gift certificate is between $50 and $1000.
//@Author: Sunil Khedar
//@Identifier: Gift Certificate
//@Date: June 01, 2006
function checkGiftCertificateAmount() {
	if (findObj('gc_amount').value<50 || findObj('gc_amount').value>1000) {
		alert("Gift Certificate amount should be from $50 to $1000");
		findObj('gc_amount').value = "";
		findObj('gc_amount').focus();
		return false;
	} else {
		return true;
	}
}
//@Description: Remove gift certificate from cart.
//@Author: Sunil Khedar
//@Identifier: Gift Certificate
//@Date: June 01, 2006
function remove_gift_certificate() {
	eraseCookie("gift_certificate");
	document.forms.cartUpdate.submit();
}
//@Description: Change the payment mode on checkout page.
//@Author: Sunil Khedar
//@Identifier: Gift Certificate
//@Date: June 01, 2006
function change_payment_mode($mode) {
	if($mode=="cc") {
		findObj('cc_payment_mode_note_div').style.display='block';
		findObj('gc_payment_mode_div').style.display='none';
		findObj('gc_payment_mode_note_div').style.display='none';
		findObj('gc_use_number').value="";
		findObj('gc_use_email').value="";
	}
	if($mode=="gc") {
		findObj('cc_payment_mode_note_div').style.display='none';
		findObj('gc_payment_mode_div').style.display='block';
		findObj('gc_payment_mode_note_div').style.display='block';
		findObj('gc_use_number').value="";
		findObj('gc_use_email').value="";
	}
}
//@Description: Put all Javascript check on submit of form.
//@Author: Sunil Khedar
//@Identifier: Gift Certificate
//@Date: June 01, 2006
function gift_certificate_checks() {
	MM_validateForm('gc_your_name','','R','gc_recipient_name','','R','gc_recipient_email','','RisEmail','gc_re_recipient_email','','RisEmail','gc_amount','','RisNum');
	if (document.MM_returnValue) {
		if (checkGiftCertificateAmount()) {
			if (compareTwoEmails('gc_recipient_email','gc_re_recipient_email')) {
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	} else {
		return false;
	}
}
// @Description (Start): Let users select the product upgrade options.
// @Identifier: Product Upgrade
// @Author: Sunil Khedar
// @Date: August 21, 2006
function updateProductUpgradeRingSize(upgradeOptionValue) {
	findObj("product_upgrade_ring_size").value = upgradeOptionValue;
}
