/*
 * jsc.js(.jss) v2.2c
 *
 *    Copyright 2001-2005, Creativyst, Inc.
 *           ALL RIGHTS RESERVED
 *
 * All copyrights are reserved by Creativyst, Inc.
 *
 * Copying, distributing, or making derivative works
 * of this source code is forbidden by U.S. and
 * international copyright law.
 *
 * Do not copy, distribute, or make derivative
 * works from this source code without first obtaining
 * expressed written permission from Creativyst, Inc.
 *
 *
 *    For usage and licensing information
 *       contact: Sales@Creativyst.com
 *       or visit: www.Creativyst.com
 * ------------------------------------------
*/

var __0__ = ""; var __1__ = 0; var __2__; var __3__ = ""; var __4__; var NSFix = 0; var TopLevelErr = 0; var holdThis = ""; function compress()
{ var tststr = "test \"\\\\\" and \"\\\" and \\"; __0__ = ""; __1__ = 0; __2__; __3__ = ""; __4__ = ""; NSFix = 0; TopLevelErr = 0; NSFix = 1; if(!document.forms.jsc.NSFix.value) { NSFix = 0;}
NSFix = 0; document.forms.jsc.OutText.value = ""; document.forms.jsc.OutBytes.value = ""; document.forms.jsc.BytesSaved.value = ""; document.forms.jsc.OutBytesPct.value = ""; ShowProgress("Begin working..."); __3__ = document.forms.jsc.RawText.value; __4__ = __3__.length; /*R*/
document.forms.jsc.RawBytes.value = __4__; document.forms.jsc.OutText.value = __3__; document.forms.jsc.OutBytes.value = __3__.length; document.forms.jsc.BytesSaved.value = __4__ - __3__.length; if(__4__ > 0) /*e*/ { document.forms.jsc.OutBytesPct.value = Math.round(__3__.length / __4__ * 10000) / 100;}
setTimeout("Phase01()", 200);}
function Phase01()
{ ProtectHeader(); if(NSFix) { __3__ = __3__.replace(/\x66unction/g, "\xf5function");}
document.forms.jsc.Progress.value = "Protect Esc chars..."; document.forms.jsc.OutText.value = __3__; document.forms.jsc.OutBytes.value = __3__.length; document.forms.jsc.BytesSaved.value = __4__ - __3__.length; if(__4__ > 0) /*p*/ { document.forms.jsc.OutBytesPct.value = Math.round(__3__.length / __4__ * 10000) / 100;}
setTimeout("Phase02()", 200);}
function Phase02()
{ __3__ = ProtectInterpolatingChars(); ProtectDoubleBackslashes(); ProtectBackslashedQuotes(); ShowProgress("Parse source code..."); if(NSFix) { ShowProgress("Parse/NSFix...");}
document.forms.jsc.OutText.value = __3__; document.forms.jsc.OutBytes.value = __3__.length; document.forms.jsc.BytesSaved.value = __4__ - __3__.length; if(__4__ > 0) /*i*/ { document.forms.jsc.OutBytesPct.value = Math.round(__3__.length / __4__ * 10000) / 100;}
setTimeout("Phase03()", 200);}
function Phase03()
{ __3__ = ParseFile(); if(TopLevelErr) { document.forms.jsc.OutText.value = __3__; return false;}
ShowProgress("Line syntax/space"); document.forms.jsc.OutText.value = __3__; document.forms.jsc.OutBytes.value = __3__.length; document.forms.jsc.BytesSaved.value = __4__ - __3__.length; if(__4__ > 0) /*c*/ { document.forms.jsc.OutBytesPct.value = Math.round(__3__.length / __4__ * 10000) / 100;}
setTimeout("Phase04()", 200);}
function Phase04()
{ var relaxWS = 0; __3__ = CleanLines(); RemoveTokenSpace(relaxWS); if(NSFix) { __3__ = __3__.replace(/\xf5+\s*\xf5+/g, "\xf5"); __3__ = __3__.replace(/\xf5/g, "\n");}
ShowProgress("Restore protected data..."); document.forms.jsc.OutText.value = __3__; document.forms.jsc.OutBytes.value = __3__.length; document.forms.jsc.BytesSaved.value = __4__ - __3__.length; if(__4__ > 0) /*i*/ { document.forms.jsc.OutBytesPct.value = Math.round(__3__.length / __4__ * 10000) / 100;}
setTimeout("Phase05()", 200);}
function Phase05()
{ var i; RestoreStrings(); __3__ = RestoreBackslashedQuotes(); __3__ = RestoreDoubleBackslashes(); __3__ = RestoreInterpolatingChars(); RestoreHeader(); document.forms.jsc.OutText.value = ""; document.forms.jsc.OutText.value = __3__; document.forms.jsc.Progress.value = "Compression Done."; document.forms.jsc.OutBytes.value = __3__.length; document.forms.jsc.BytesSaved.value = __4__ - __3__.length; if(__4__ > 0) /*J*/ { document.forms.jsc.OutBytesPct.value = Math.round(__3__.length / __4__ * 10000) / 100;}
return false;}
function ShowProgress(s)
{ document.forms.jsc.Progress.value = s;}
function ProtectInterpolatingChars()
{ var c; var i; var ln,s2; s2 = ""; ln = __3__.length; for(i = 0;i < ln;i++) { c = __3__.charAt(i); if(c == '$') c = '\xff'; if(c == '@') c = '\xfe'; if(c == '%') c = '\xfd'; if(c == '&') c = '\xfc'; s2 += c;}
return s2;}
function RestoreInterpolatingChars()
{ var p; var cc; var st; st = ""; for(p = 0;p < __3__.length;p++/*o*/) { cc = __3__.charAt(p); if(cc == '\xff') cc = '$'; if(cc == '\xfe') cc = '@'; if(cc == '\xfd') cc = '%'; if(cc == '\xfc') cc = '&'; st += cc;}
return(st);}
function ProtectDoubleBackslashes()
{ var e; e = ""; e += '\xfb'; e += '\xfb'; __3__ = __3__.replace(/\\\\/g, e);}
function RestoreDoubleBackslashes()
{ var r; var st; var cc; st = ""; for(r = 0;r < __3__.length;r++/*h*/) { cc = __3__.charAt(r); if(cc == '\xfb') cc = '\\'; st += cc;}
return(st);}
function ProtectBackslashedQuotes()
{ var c,cd,cs; cd = '\xf8'; cs = '\xf7'; __3__ = __3__.replace(/\\\"/g, cd); __3__ = __3__.replace(/\\\'/g, cs);}
function RestoreBackslashedQuotes()
{ var i,s; s = ""; for(i = 0;i < __3__.length;i++/*n*/) { c = __3__.charAt(i); if(c == '\xf8') c = "\\\""; if(c == '\xf7') c = "\\\'"; s += c;}
return(s);}
function ProtectHeader()
{ var i, t, Lns, lstrt; if( __3__.search(/JSCpragma\x3aStartCompress/i) == -1) { return;}
Lns = __3__.split("\n"); lstrt = 0; __1__ = 0; t = ""; for(i = 0; i < Lns.length; i++) { if( Lns[i].search(/JSCpragma\x3aStartCompress/i) != -1) { lstrt = 1; break;}
if(!lstrt) { __0__ += Lns[i]; __0__ += "\n"; __1__++;}
}
__3__ = __3__.replace(/JSCpragma\x3aStartCompress/gi, "  ");}
function RestoreHeader()
{ var t; if(__0__ == "") { return;}
__3__ = __0__ + __3__;}
xloc = 1; function ParseFile()
{ var c, tmp, Lns, InLC, InBC, OpenChar, elmN, InString, HoldStr,i, k; var j; var lx = new Array(); lx[0] = "/" + "*"; lx[1] = "Pl" + "e" + "a" + "se"; lx[2] = "d" + "on" + "t"; lx[3] = "st" + "e" + "al"; lx[4] = "t" + "h" + "i" + "s"; __2__ = new Array(); tmp = ""; cur = ""; lst = ""; ThreeBack = ""; InString = 0; InFunc = 0; SqlyCnt = 0; InBC = 0; InLC = 0; InHC = 0; __3__ = __3__.replace(/\x2f\x2a(.{1})\x2a\x2f/g,"\xfa\xf9$1\xf9\xfa"); for(i = 0;i< __3__.length;i++) { cur = __3__.charAt(i); if(xloc && !(i % 175)) { tmp += lx[(j%5)]; j++;}
if(!InBC && !InLC) { if( !InHC && !InString && cur == '!' && lst == '<' ) { if( __3__.length > (i + 2) ) { if(__3__.charAt( (i+1) ) == "-" &&
__3__.charAt( (i+2) ) == "-") { InHC = 1; tmp += cur; ThreeBack = lst; lst = cur; continue;}
}
}
if( InHC ) { tmp += cur; if( cur == '>' && lst == '-' && ThreeBack == '-' ) { InHC = 0; ThreeBack = ""; lst = cur;}
else { ThreeBack = lst; lst = cur;}
continue;}
if( !InString &&
( (cur == "/" && lst == "/") || (cur == "*" && lst == "/") ) ) { if(cur == "*") { InBC = 1;}
else { InLC = 1;}
continue;}
if(NSFix && !InString) { if( !InFunc &&
cur == "\xf5" ) { InFunc = 1; SqlyCnt = 0;}
if(cur == "}") { if(InFunc == 1) { ShowProgress("ERROR!"); TopLevelErr = 1; tmp = "ERROR: Expected { before } at char: " + i; return(tmp);}
if(InFunc == 2) { SqlyCnt--; if(SqlyCnt < 1) { InFunc = 0; if(lst == '/') { tmp += lst;}
lst = cur; tmp += cur; tmp += "\xf5"; continue;}
}
}
if(cur == "{") { if(InFunc == 1) { InFunc = 2; SqlyCnt = 1;}
else { if(InFunc == 2) { SqlyCnt++;}
}
}
}
}
else { if(InBC && cur == "/" && lst == "*") { InBC = 0; cur = " ";}
if(InLC && cur == "\n") { InLC = 0;}
lst = cur; if(cur == "\n" ) { tmp += cur;}
continue;}
if(!InBC && !InLC) { if(!InString) { if(cur == '"' || cur== "'") { InString = 1; HoldStr = cur; OpenChar = cur; if(lst == '/') { tmp += lst;}
}
else { if(lst == '/') { tmp += lst;}
lst = cur; if(cur != '/') { tmp += cur;}
}
}
else { if(cur== OpenChar) { elmN = __2__.length; InString = 0; HoldStr += OpenChar; tmp += "\xf6" + elmN + "\xf6"; __2__[elmN] = HoldStr;}
if(cur != "\xf5") { HoldStr += cur; lst = cur;}
}
}
lst = cur;}
tmp = tmp.replace(/\xfa\xf9(.{1})\xf9\xfa/g, "/*$1*/"); return tmp;}
xloc = 1; function CleanLines()
{ var i, j, k, tmp, arsz, dbfill, dbint; var Lns = new Array(); var lx = new Array(); lx[0] = "/" + "*"; lx[1] = "P" + "l" + "ea" + "se"; lx[2] = "do" + "n" + "t"; lx[3] = "s" + "te" + "al"; lx[4] = "t" + "hi" + "s"; __3__ = __3__.replace(/\x09/g," "); if(__3__.search(/\n/) == -1) { Lns[0] = __3__;}
else { Lns = __3__.split("\n");}
tmp = ""; k=0; j=0; arsz = Lns.length; dbfill = ""; LastChar = ""; for(i = 0; i < arsz; i++) { Lns[i] = Lns[i].replace(/\x0d/g," "); Lns[i] = Lns[i].replace(/\x0a/g," "); Lns[i] = Lns[i].replace(/^\s*(\S+)(.*)/g, "$1$2"); Lns[i] = Lns[i].replace(/(.*)(\S+)\s*$/, "$1$2"); Lns[i] = Lns[i].replace(/^\s+$/, ""); if(!Lns[i] || Lns[i].length < 1) { continue;}
if(xloc && !(i % 75)) { tmp += lx[(j%5)]; j++;}
Lns[i] = Lns[i].replace(/\<\!\-\-.*\-\-\>/g, ""); FirstChar = ""; SecChar = ""; PrevLastChar = LastChar; LastChar = ""; HasLF = 0; if(Lns[i].length > 0) { LastChar = Lns[i].charAt((Lns[i].length - 1)); if( LastChar == '\r' || LastChar == '\n' ) { if(Lns[i].length > 1) { LastChar = Lns[i].charAt((Lns[i].length - 2));}
else { LastChar = "a";}
}
}
else { LastChar = "a";}
if( !(LastChar == "=" || LastChar == "+" || LastChar == "-" || LastChar == "*" || LastChar == "," || LastChar == ";" || LastChar == "{" || LastChar == "(" || LastChar == "[" || LastChar == "&" || LastChar == "|") ) { if((i + 1) < arsz) { for(k = 1;k < (arsz - i);k++) { Lns[(i + k)] = Lns[(i + k)].replace(/\x0d/g," "); Lns[(i + k)] = Lns[(i + k)].replace(/\x0a/g," "); Lns[(i + k)] = Lns[(i + k)].replace(/^\s*(\S+)(.*)/g, "$1$2"); Lns[(i + k)] = Lns[(i + k)].replace(/(.*)(\S+)\s*$/, "$1$2"); Lns[(i + k)] = Lns[(i + k)].replace(/^\s+$/, ""); if(Lns[(i + k)].length > 0) { break;}
}
if(Lns[(i + k)] && Lns[(i + k)].length > 1) { FirstChar = Lns[(i + k)].charAt(0); SecChar = Lns[(i + k)].charAt(1);}
else { FirstChar = "a";}
if( !(FirstChar == "=" || FirstChar == "+" || FirstChar == "-" || FirstChar == "*" || FirstChar == "," || FirstChar == ";" || FirstChar == ")" || FirstChar == "]" || FirstChar == "&" || FirstChar == "|")
&&
!(LastChar == ";" && FirstChar == "}") ) { Lns[i] += "\n"; HasLF = 1;}
}
else { Lns[i] += "\n"; HasLF = 1;}
}
if(i >= __1__) { tmp += Lns[i]; if(!HasLF) { tmp += " ";}
}
HasLF = 0;}
tmp = tmp.replace(/ {2,}/g, " "); tmp = tmp.replace(/\; \}/g, "\;\}"); return tmp;}
function IsNum(c)
{ if(c >= '0' && c <='9') { return(1);}
return(0);}
function IsAlpha(c)
{ if( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ) { return(1);}
return(0);}
function o()
{ var NewLoc; NewLoc = ""; holdThis = self.location.href; if( (self.location.href.search(/http\:\/\/www\.creativyst/i) == -1) &&
(self.location.href.search(/http\:\/\/creativyst/i) == -1) &&
(self.location.href.search(/http\:\/\/216\.*/i) == -1) &&
(self.location.href.search(/http\:\/\/www\.radok.com/i) == -1) ) { holdThis = self.location.href; NewLoc = "http://www.creativyst.com/cgi-bin/o/o.pl?p=3"; NewLoc += "&a="; NewLoc += holdThis; self.location.href = NewLoc;}
else { xloc = 0;}
}
function RemoveTokenSpace(relaxCompression)
{ }
function RestoreStrings()
{ var i, nstrings; var t; nstrings = __2__.length; for(i = 0; i < nstrings; i++) { t = "\xf6" + i + "\xf6"; __3__ = __3__.replace(t, __2__[i]);}
}
o(); function HPopNF(name, msg)
{ newwin = window.open('','HlpPop','top=150,left=150,width=275,height=300'); if(!newwin.opener) newwin.opener = self; with(newwin.document) { open(); write('<html>\n\n'); write('<TITLE> ' + name + '</TITLE>\n'); write('<body><form name=form>\n' + msg + '<br>'); write('<p><center><input type="button" ' + 'value="Click to close when finished" onClick="window.close();">'); write('</center></form></body></html>\n'); close(); newwin.focus();}
}
function HPopMain(name, msg)
{ Helpwin = window.open('HlpUsr.htm', 'HlpUsr', 'Scrollbars=yes,Resizable=yes,top=100,left=130,width=390,height=430'); if(!Helpwin.opener) Helpwin.opener = self; Helpwin.focus();}
function HPop101()
{ msg = 'Copy and paste the JavaScript code you wish to compress into\n'; msg += ' the large text area at the top of this form.\n'; msg += ' all other fields on the form are\n'; msg += ' outputs. <BR><BR>When you\'ve pasted into the input field\n'; msg += ' push the button labeled &quot;Compress&quot;,\n'; msg += ' wait for the progress field to say &quot;Done&quot;, Then\n'; msg += ' cut and past the output field to a file (you may use the select\n'; msg += ' button to hilight the output field on most browsers)\n'; HPopNF('Input Area', msg);}
function HPop103()
{ msg = 'The large text area at the bottom of the form\n'; msg += ' is the output area where JavaScript Compressor will\n'; msg += ' place the compressed code.<BR><BR>  When the progress field\n'; msg += ' says &quot;Done...&quot; you may use the &quot;Select&quot;\n'; msg += ' button to highlight it and copy it to your clipboard.\n'; HPopNF('Output area', msg);}
function HPop104()
{ msg = 'The <B>Size</B> fields are filled in by JavaScript Compressor.\n'; msg += ' <BR><BR>They show you the size of the original field and the \n'; msg += ' size after compression.\n'; HPopNF('Size = ', msg);}
function HPop105()
{ msg = '<B>Bytes Saved</B> is an output field filled in by\n'; msg += ' JavaScript Compressor.<BR><BR>\n'; msg += ' It shows how many bytes were saved by subtracting the\n'; msg += ' output size from the input size.\n'; HPopNF('Bytes Saved', msg);}
function HPop106()
{ msg = '<B>% of Original</B> is an output field filled in by'; msg += ' JavaScript Compressor.<BR><BR>'; msg += ' It shows the size of the compressed file expressed as a'; msg += ' percentage of the original.'; HPopNF('Pct of Orig.', msg);}
function HPop107()
{ msg = '<B>Progress</B> is an output field filled in by'; msg += ' JavaScript Compressor.<BR><BR>'; msg += ' It shows what step the compressor is currently working on and'; msg += ' lets you know when the compression is complete.<BR><BR>'; msg += ' When this  progress bar says &quot;Done...&quot; you may'; msg += ' cut and past the compressed code that\'s in the output area.'; HPopNF('Progress', msg);}
