var tempValOrig = '', isEnc = false;

function hideDiv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow').style.visibility = 'hidden';
}
else {
if (document.layers) { // Netscape 4
document.hideshow.visibility = 'hidden';
}
else { // IE 4
document.all.hideshow.style.visibility = 'hidden';
}
}
}

var num = 0;


function idget(obj){
var DivGen = document.getElementById(obj);
validate(DivGen);
}

function validate(DivGen){
if(DivGen.style.display=='none'){
DivGen.style.display=''} else {
DivGen.style.display='none'
}}


function showDiv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.hideshow.visibility = 'visible';
}
else { // IE 4
document.all.hideshow.style.visibility = 'visible';
}
}
}


function inAr(oStr) {
	var opAr = new Array('+','-','*','%','=','+=','-=','&gt;','&lt;','&gt;=','&lt;=','++','--','==','!=','&lt;&lt;','&gt;&gt;','&amp;','|','^','~','!','&amp;&amp;','||','?',':');
		
for( var x = 0; x < opAr.length; x++ ) {
		if( oStr.substr(0,opAr[x].length) == opAr[x] ) { return opAr[x]; } }
	return false;
}




function hlScript(SourceCode) {




re_nlchar = /%0A%0D/g ;
//SourceCode = SourceCode.replace(/<br \/>/g, /\n/g);
SourceCode = SourceCode.replace(/<br \/>/g, "removethebr");


 //start conversion by preparing variables
	var tempVal = SourceCode, newVal = ''; tempValOrig =SourceCode; 
	var oAmp = 'a', oRand = new Array('b','c'); //start conversion to HTML entities
	while( tempVal.indexOf(oAmp) + 1 ) { oAmp += oRand[Math.round(Math.random())]; }
	var fromAr = new Array('&',oAmp,'<','>','"'), toAr = new Array(oAmp,'&amp;','&lt;','&gt;','&quot;');



for( var x = 0; x < fromAr.length; x++ ) { while(tempVal.indexOf(fromAr[x])+1) { tempVal = 

tempVal.replace(fromAr[x],toAr[x]); } }
	for( var x = 0; x < tempVal.length; x++ ) {
	  if( tempVal.substr(x,1).replace(/[\w\+\-\*\/%=&\!\|\^~\'\"\?:]/,'') ) { newVal += 

tempVal.substr(x,1); } else {
			//This must be highlighted in some way
			if( !tempVal.substr(x,1).replace(/[a-zA-Z_]/,'') ) {
				//variable or function or keyword or true/false/null
				var tempKey = tempVal.substr(x).replace(/\W[\w\W]*/,'');
				x += tempKey.length - 1; //the word is isolated and its length added
				if( tempVal.substr(x).replace(/\w*\s*/,'').substr(0,1) == '(' ) {
					//function/method or 'if' or 'for' or 'while' etc.
					if( tempKey == 'for' || tempKey == 'if' || tempKey == 'while' || tempKey == 'switch' || tempKey == 'with' || tempKey == 'typeof' || tempKey == 'void' || tempKey == 'return' || tempKey == 'function' ) {
						newVal += '<span class="oper">'+tempKey+'<\/span>';
					} else { newVal += '<span class="func">'+tempKey+'<\/span>';
				} } else { //variable or keyword or true/false/null
					if( tempKey == 'var' || tempKey == 'function' || tempKey == 

'var' || tempKey == 'new' || tempKey == 'else' || tempKey == 'return' || tempKey == 'do' || tempKey == 'break' || 

tempKey == 'continue' || tempKey == 'case' || tempKey == 'default' || tempKey == 'in' || tempKey == 'delete' || tempKey == 'typeof' ) {
						newVal += '<span class="oper">'+tempKey+'<\/span>';
					} else { if( tempKey == 'true' || tempKey == 'false' || tempKey == 'null' ) {
							newVal += '<span class="num">'+tempKey+'<\/span>';
						} else { newVal += '<span class="var">'+tempKey+'<\/span>'; } } }
			} else { if( !tempVal.substr(x,1).replace(/[\d]/,'') ) { //numbers (+ & - signs are operators)
					newVal += '<span class="num">'+tempVal.substr(x).replace(/[^0-9.xE][\w\W]*/,'')+'<\/span>';
					x += tempVal.substr(x).replace(/[^0-9.xE][\w\W]*/,'').length - 1;
				} else { //operators and comments and regexp and quotes
					if( tempVal.substr(x,2) != '\/*' && tempVal.substr(x,2) != '\/\/' ) { //ops,regexp,',"



	if( tempVal.substr(x,1) == "'" ) { var backSl = 0; 


//'string'

							for( var y = 1; ( backSl%2 || tempVal.substr(y+x,1) != "'" ) && x+y < tempVal.length - 1; y++ ) {
								if( tempVal.substr(y+x,1) == 

'\\' && ( tempVal.substr(y+x+1,1) == '\\' || tempVal.substr(y+x+1,1) == "'" ) ) {
									backSl++; } else { backSl = 0; } }


							newVal += "'<span class=\"string\">"+tempVal.substr(x+1,y-1)+"<\/span>'"; x += y;
						} else {



 if( tempVal.substr(x,6) == "&quot;" ) { var backSl = 0; //"string"
								for( var y = 1; ( backSl%2 || tempVal.substr(y+x,6) != "&quot;" ) && x+y < tempVal.length - 1; y++ ) {
									if( tempVal.substr(y+x,1) == '\\' && ( tempVal.substr(y+x+1,1) == '\\' || tempVal.substr(y+x+1,6) == "&quot;" ) ) {
										backSl++; } else { backSl = 0; } }


								newVal += '&quot;<span class="string">'+tempVal.substr(x+6,y-6)+'<\/span>&quot;'; x += y+5;
							} else {



 if (inAr(tempVal.substr(x)) ) { 

//ops, regexp
									newVal += '<span class="oper">'+inAr(tempVal.substr(x))+'<\/span>';

x += inAr(tempVal.substr(x)).length - 1;



								} else { 

//2.7

									for( var y = -1; x + y != 0 && ( tempVal.substr(x+y,1) == '\t' || tempVal.substr(x+y,1) == ' ' || tempVal.substr(x+y,1) == '\n' || tempVal.substr(x+y,1) == '\r' || tempVal.substr(x+y,1) == '\f' ); y-- ) {}
									if( !tempVal.substr(x+y,1).replace(/[\)\w\]]/,'') ) { newVal += '<span class="oper">\/<\/span>'; //divide
									} else { var 

backSl = 0; //regexp
										for( var 

y = 1; ( backSl%2 || tempVal.substr(y+x,1) != '\/' ) && x+y < tempVal.length - 1; y++ ) {
											

if( tempVal.substr(y+x,1) == '\\' && ( tempVal.substr(y+x+1,1) == '\\' || tempVal.substr(y+x+1,1) == '\/' ) ) {
											

	backSl++; } else { backSl = 0; }
										} //now I have the regexp. I must also see if there is a g or gi or i after it
										newVal += '\/<span class="reg">'+tempVal.substr(x+1,y-1)+'<\/span>\/'; x += y; y = x;
										if( tempVal.substr(x+1,1) == 'g' || tempVal.substr(x+1,1) == 'i' ) { x++; }

										if( tempVal.substr(x+1,1) == 'g' || tempVal.substr(x+1,1) == 'i' ) { x++; } if( x > y ) {
											newVal += '<span class="reg">'+tempVal.substr(y+1,x-y)+'<\/span>'; } } } } }
					} else { if( tempVal.substr(x,2) == '\/*' ) { //block comments
							newVal += '<span class="comment">'+tempVal.substr(x).replace(/\*\/[\w\W]*/,'')+'*\/<\/span>';
							x += tempVal.substr(x).replace(/\*\/[\w\W]*/,'').length + 1;
						} else { //one-line comments
							newVal += '<span class="comment">'+tempVal.substr(x).replace(/[\n\r][\w\W]*/,'')+'<\/span>';
							x += tempVal.substr(x).replace(/[\n\r][\w\W]*/,'').length - 1; } } } } } }


	SourceCode.value = newVal;

newVal = newVal.replace(/removethebr/g, "<br />");



	document.write(newVal);

	 isEnc = true;
num = num +1;

	
}
