	
	var PageTitle ='';
	var SRESrever="http://www.sreejon.com";
	var SREHost="sreejon.com"; // change it to "eMilieu.com" and NOT 'www.eMilieu.com' or "http://..."
	var SREErrorString = '';
	var SREFormatErrorString = '';
	var SRESession ="";	
	var SRELanguage = 'EN'; /* obsolete  ?? */
	var SRELocale ='EN';
	var SREIP ='';
	var SREPath='cde';
	var SREErrorArr= new Array();
	var SRECountryName ='';
	var SRECountryCode ='';
	var SRESelectedPage="";
	var SREDomain="sreejon.com"; // change it to "eMilieu.com" and NOT 'www.eMilieu.com' or "http://..."
	SREKillPage="../../../Bye.html";
	SREKillPageShort="Bye.html";
	SREStartPage="../../../index.html";
	SREStartPageShort="index.html";
	SRESecuritRedirect="../../../Expired.html";
	SCROLLPAGE='';
SREModified=0;
SREActionFocus='';
SRETabIndxCnt=0;

//	SREPREVServeralias='';

	SREThirdparty='';
	SRELanguage='EN';
	SRECountryDB='';
	SRECountryIP='';
	SREUser='';
	SREMergeId='';
	SREDelegate='';
	SRESecuredMode='';
	SREFullname='';
	SREEmail='';
	SREUsertype='';
	SREServeralias='';
	SREMode='';
	SREPremId='';
	SREConfigured='';
	SREVertical='';
	SRETheme='';
	SREMenuType='';
	SREBackpic='';
	SREPagename='';
	SREMsgwaiting='';
	SREClockset='';
	SREVisitorrole='';
	SREContact='';
	SREContactLan='EN';
	SREContactname='';
	SREContactemail='';
	SREContactserv='';
	SREContactrole='';
	SREInsId='';
	SREVisitorrole='';
	SREVisitorId='';
	SREVisitorLan='';
	SREVisitorName='';
	SREVisitorServer='';
	SREVisitorUserType='';
        SRELongParam='';
        SREExclusive='eMilieu';
	SREPortalRole='SELF';
	SREBiztype='';
        SRELineofbiz='';
	SREPrivate='';
	SRECanRepresent='N';
SREContactroledesc='';
var sremonth = new Array();
sremonth[0] = "January";
sremonth[1] = "February";
sremonth[2] = "March";

sremonth[3] = "April";
sremonth[4] = "May";
sremonth[5] = "June";
sremonth[6] = "July";
sremonth[7] = "August";
sremonth[8] = "September";
sremonth[9] = "October";
sremonth[10] = "November";
sremonth[11] = "December";
var sreday = new Array();
sreday[0] = "Sunday";
sreday[1] = "Monday";
sreday[2] = "Tuesday";
sreday[3] = "Wednesday";
sreday[4] = "Thursday";
sreday[5] = "Friday";
sreday[6] = "Saturday";
var sredayshrt = new Array();
sredayshrt[0] = "S";
sredayshrt[1] = "M";
sredayshrt[2] = "T";
sredayshrt[3] = "W";
sredayshrt[4] = "T";
sredayshrt[5] = "F";
sredayshrt[6] = "S";

var clockTime = 60000;
var plainArray = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','.','@'];
var cipherArray = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','.','@'];

function simpleencrypt(plainText,Parray,Carray) {
   var i,j;txt='';
     for (var i = 0; i < plainText.length; i++)   {
       var plainLetter = plainText.charAt(i);
       for (j = 0; j < Parray.length; j++ ) {
	     if(Parray[j] == plainLetter){
		 txt += Carray[Parray.length - j -1];
	     }
        }
  }
  return txt;
}
function simpledecrypt(plainText,Parray,Carray) {
   var i,j;txt='';
     for (var i = 0; i < plainText.length; i++)   {
       var plainLetter = plainText.charAt(i);
       for (j = 0; j < Carray.length; j++ ) {
	     if(Carray[j] == plainLetter){
		 txt += Parray[Carray.length - j -1];
	     }
        }
  }
  return txt;
}


/* ---------------------Begin(sre_core)---------------------------------- *\
 * eMiliue v1.0 Copyright (c) 2010 Sreejon LLC 
 * Contact us at sreejon2006@msn.com
 * This copyright notice MUST stay intact for use.
 *
 * $Revision: 1.0 $

Dependency :	[Meant to work with Sreejon message structure ]
				None

Description :	All core functions that are used everywhere in the system 

\* ---------------------------------------------------------------------- */

var sre_core = {

/* ---------------------------------------------------------------------- *\
  Function    : random(min,max)
  Description : Find a javascript random number between minimum and maximum number.
  Usage       : sre_core.random(min,max)
  Arguments   : min	- The min value of random
				max	- The max value of random
  Return      : The random value between min and max	
\* ---------------------------------------------------------------------- */

random: function (min,max) {
	//return Math.floor(Math.random()*max+1)
	return Math.floor(Math.random() * (max - min + 1) + min)
},
/* ---------------------------------------------------------------------- *\
  Function    : initializeList(list)
  Description : Array is initialized.
  Usage       : sre_core.initializeList(list)
  Arguments   : list	- The list/array to be initialized
  Return      : None	
\* ---------------------------------------------------------------------- */
initializeList: function (list){
	if(!list) return;
	for (i=0;i < list.length; i++) 	{
		list[i]=null
	}
	list.length=0;
},
/* ---------------------------------------------------------------------- *\
  Function    : initializeList(list)
  Description : Array is initialized.
  Usage       : sre_core.initializeList(list)
  Arguments   : list	- The list/array to be initialized
  Return      : None	
\* ---------------------------------------------------------------------- */
getLabelDesc: function (list,code){
	if(!list) return; words = new Array(); desc='';
	for (i=0;i < list.length; i++) 	{
		ln=list[i];
		sre_core.breakWords(list[i],words);
		if(words[0] == code){
		  desc = words[2]; break;
		}
	}
	return desc;
},
/* ---------------------------------------------------------------------- *\
  Function    : breakWords(scanword,wordarray)
  Description : Breaks a word or date in arrays. [words delimited by '|'] 
  Usage       : sre_core.breakWords(scanword,wordarray,delim)
  Arguments   : scanword	- The word to break
				wordarray	- The array of words
  Return      : 1 for success, 0 for failure	
\* ---------------------------------------------------------------------- */
breakWords: function (scanword,wordarray,delim){
	if(!delim) delim ='|';
	var pos=0; var indx=0;var word="";var len;
	var done=0; var ret = 1;
	scanword += ' ';
	len = scanword.length;
	sre_core.initializeList(wordarray);
	for(i=pos; i < len && done == 0; i++)	{
		if(scanword.slice(i,i+1)==delim)		{
			word = scanword.slice(pos,i);
			pos = i + 1;
			if (word)			{
				wordarray[indx] = word;
				indx++;
			} else {
			//	ret = 0;
				wordarray[indx] ='undefined';
				indx++;
			}
			word=""; 
		}
	}
	word = scanword.slice(pos,i-1);
	wordarray[indx] = word;
	done = 1;
	return ret;
},
/* ---------------------------------------------------------------------- *\
  Function    : getIndexFromCode(code,wordarray,delim)
  Description : Breaks a word or date in arrays. [words delimited by '|'] 
  Usage       : sre_core.getIndexFromCode(code,wordarray,delim)
  Arguments   : scanword	- The word to break
				wordarray	- The array of words
  Return      : 1 for success, 0 for failure	
\* ---------------------------------------------------------------------- */
getIndexFromCode: function (code,wordarray,delim){
	len = wordarray.length;words= new Array();
	for(p=0; p < len ; p++)	{
		sre_core.breakWords(wordarray[p],words,delim);
		if(words[0]==code){
			break ;
		}
	}
	return p;
},
/* ---------------------------------------------------------------------- *\
  Function    : loadArrayFromStr(response,arrList,delim)
  Description : Breaks a response string in arrays. [words delimited by ';'] 
  Usage       : sre_core.loadArrayFromStr(response,arrList,delim)
  Arguments   : response	- The string to break
		arrList	        - The array list returned
		delin (optional)-if nothing is passed ';' is assumed
  Return      : 1 for success, 0 for failure	
\* ---------------------------------------------------------------------- */
loadArrayFromStr: function (response,arrList,delim){
	if(!delim) delim =';';
	var word="";var done=0;var pos=0;
	len = response.length;
	sre_core.initializeList(arrList);
	for(i=pos; i < len && done == 0; i++)	{
		if(response.slice(i,i+1)==delim)		{
			word = response.slice(pos,i);
			if(word !=''){	
				arrList[arrList.length] = word;
			}
			pos = i + 1;
			if (word){
			} else {
				done = 1;
			}
			word=""; 
		}
	}
	word = response.slice(pos,i-1);
	if(word !=''){	
		arrList[arrList.length] = word;
	}
	return arrList;
},
/* ---------------------------------------------------------------------- *\
  Function    : isMSIE(),isFF() ,isOpera(),isSafari(),isChrome()
  Description : Detects a browser conclusively
  Usage       : sre_core.isMSIE(),sre_core.isFF() ,sre_core.isOpera(),sre_core.isSafari(),sre_core.isChrome()
  Arguments   : NONE
  Return      : true for success, false for failure	
\* ---------------------------------------------------------------------- */
isMSIE: function (){
	if(navigator.appName == "Microsoft Internet Explorer") {
		return true;
	}
	return false;
},
isFF: function (){
	if(!document.all && document.getElementById && navigator.appName != "Opera") {
		return true;
	}
	return false;
},
isOpera: function (){
	if(navigator.appName == "Opera") {
		return true;
	}
	return false;
},
isSafari: function (){
	if(navigator.userAgent.indexOf('Safari') != -1) {
		return true;
	}
	return false;
},
isChrome: function (){
	if(navigator.userAgent.toLowerCase().indexOf('chrome') != -1) {
		return true;
	}
	return false;
},
/* ---------------------------------------------------------------------- *\
  Function    : windowSize(axis)
  Description : Return the browser window size
  Usage       : sre_core.windowSize('H') or sre_core.windowSize('V')
  Arguments   : axis - H: horizontal V: vertical
  Return      : Returns Height or width parameter depending on the flag
\* ---------------------------------------------------------------------- */

windowSize: function (axis){ //H: horizontal V: vertical
	dimval=0; 
	if (axis =='H') {
		if (window.innerWidth) {
			dimval = window.innerWidth;
		} else if (document.body && document.body.offsetWidth) {
			dimval = document.body.offsetWidth;
		}
	} else if (axis =='V') {
		if (window.innerHeight) {
			dimval = window.innerHeight;
		} else if (document.body && document.body.offsetHeight) {
			dimval = document.body.offsetHeight;
		}
	}
	return dimval;
},
/* ---------------------------------------------------------------------- *\
  Function    : lightUp(object, opacity)
  Description : Fades or lights up an object
  Usage       : sre_core.lightUp(obj,40) 
  Arguments   : object - Object ot be faded or lit up
				opacity - opacity value (0 to 100)
  Return      : none
\* ---------------------------------------------------------------------- */

lightUp: function (object, opacity){
	 obj = document.getElementById(object);
	 if (sre_core.isMSIE()) {
  			obj.style.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity=' + opacity + ')';
	 } else {
		 obj.style.opacity=opacity/100
	 }	
},
/* ---------------------------------------------------------------------- *\
  Function    : trim(str),ltrim(str) ,rtrim(str)
  Description : Different types of trim
  Usage       : sre_core.trim(str),sre_core.ltrim(str) ,sre_core.rtrim(str)
  Arguments   : str - string to be trimmed
  Return      : Returns trimmed string
\* ---------------------------------------------------------------------- */
trim: function (str) {
	return str.replace(/^\s+|\s+$/g,"");
},
ltrim: function (str) {
	return str.replace(/^\s+/,"");
},
rtrim: function (str) {
	return str.replace(/\s+$/,"");
},

htmlClean: function (str) {
	while (str != (str = str.replace(/&lt;/, "<")));
	while (str != (str = str.replace(/&gt;/, ">")));
	while (str != (str = str.replace(/&nbsp;/, "")));

//	htmlout = htmlout.replace(/&lt;/, "<");
//	htmlout = htmlout.replace(/&gt;/, ">");
	return str;
}, 
tagify: function (string) {
	return string.replace(/\n/g, '&lt\;br \\&gt\;');
},
/* ---------------------------------------------------------------------- *\
  Function    : urlClean(url,frmt)
  Description : Cleans all %xx values in any url given (plain text format \n \r etc.)
  Usage       : sre_core.urlClean(url,frmt)
  Arguments   : url - url to be cleaned
				frmt - format [(T: '\n') or (H: '<br>')] .  Default is H
  Return      : Returns url, replaced with actual ascii chars
\* ---------------------------------------------------------------------- */
urlClean: function (url,frmt) { //ReformatText and CleanText

	var emb = new Array();var tmp1 = new Array();	var cnt = 0;var pos=0;
	emb += url;
	if (!frmt) frmt = 'H';
	for(jj=0; jj < emb.length && pos < emb.length;jj++){
		x='';	x = emb.slice(pos,pos+3);
		if(x == "%34"){  
			tmp1[cnt]='"';cnt++;pos+= 3;
		}
		else if(x == "%47"){
			tmp1[cnt]='/';cnt++;pos+= 3;
		}
		else if(x == "%92"){
			tmp1[cnt]='\\';cnt++;pos+= 3;
		}
		else if(x == "%40"){
			tmp1[cnt]='(';cnt++;pos+= 3;
		}
		else if(x == "%41"){
			tmp1[cnt]=')';cnt++;pos+= 3;
		}
		 else if((x == "%39")|| (x == "%96")){
			tmp1[cnt]='\'';cnt++;pos+= 3;
		}else if(x == "%60"){
			tmp1[cnt]='<';cnt++;pos+= 3;
		} 
		else if(x == "%62"){
			tmp1[cnt]='>';cnt++;pos+= 3;
		}
		else if(x == "%15"){
			if(frmt == 'T') {
				tmp1[cnt]='\n';pos+= 3;cnt++;
			} else {
				tmp1[cnt]='<';cnt++;
				tmp1[cnt]='b';cnt++;
				tmp1[cnt]='r';cnt++;
				tmp1[cnt]='>';cnt++;pos+= 3;
			}
		}
		else { 
			z = emb.slice(pos,pos+1);
			tmp1[cnt]=z;cnt++;pos += 1;
		}
	}
	var y = '';
	for(kk=0; kk < tmp1.length;kk++){
		y += tmp1[kk];
	}
	return y;
},
toHexColor: function  (color) {
	color = color.replace(/^rgb/g,'');
	color = color.replace(/\(/g,'');
	color = color.replace(/\)/g,'');
	color = color.replace(/ /g,'');
	color = color.split(',');
	var r = parseFloat(color[0]).toString(16).toUpperCase();
	var g = parseFloat(color[1]).toString(16).toUpperCase();
	var b = parseFloat(color[2]).toString(16).toUpperCase();
	if (r.length<2) { r='0'+r; }
	if (g.length<2) { g='0'+g; }
	if (b.length<2) { b='0'+b; }
	return r + g + b;
},
dec_to_rgb: function (value) {  //_dec_to_rgb
	var hex_string = "";
	for (var hexpair = 0; hexpair < 3; hexpair++) {
		var myByte = value & 0xFF;            // get low byte
		value >>= 8;                          // drop low byte
		var nybble2 = myByte & 0x0F;          // get low nybble (4 bits)
		var nybble1 = (myByte >> 4) & 0x0F;   // get high nybble
		hex_string += nybble1.toString(16);   // convert nybble to hex
		hex_string += nybble2.toString(16);   // convert nybble to hex
	}
	return hex_string.toUpperCase();
},
replaceRGBWithHexColor: function  (str) {
	if(str == null) return "";
	// find all decimal color strings
	var matcher = str.match(/rgb\([0-9 ]+,[0-9 ]+,[0-9 ]+\)/gi);
	if(matcher) {
		for(var j=0; j<matcher.length;j++) {
			var regex = eval("/" + this.stringToRegex(matcher[j]) + "/gi");
			// replace the decimal color strings with hex color strings
			str = str.replace(regex, "#" + this.toHexColor(matcher[j]));
		}
	}
	return str;
},
stringToRegex: function  (string) {
	string = string.replace(/\//gi, "\\/");
	string = string.replace(/\(/gi, "\\(");
	string = string.replace(/\)/gi, "\\)");
	string = string.replace(/\[/gi, "\\[");
	string = string.replace(/\]/gi, "\\]");
	string = string.replace(/\+/gi, "\\+");
	string = string.replace(/\$/gi, "\\$");
	string = string.replace(/\*/gi, "\\*");
	string = string.replace(/\?/gi, "\\?");
	string = string.replace(/\^/gi, "\\^");
	string = string.replace(/\\b/gi, "\\\\b");
	string = string.replace(/\\B/gi, "\\\\B");
	string = string.replace(/\\d/gi, "\\\\d");
	string = string.replace(/\\B/gi, "\\\\B");
	string = string.replace(/\\D/gi, "\\\\D");
	string = string.replace(/\\f/gi, "\\\\f");
	string = string.replace(/\\n/gi, "\\\\n");
	string = string.replace(/\\r/gi, "\\\\r");
	string = string.replace(/\\t/gi, "\\\\t");
	string = string.replace(/\\v/gi, "\\\\v");
	string = string.replace(/\\s/gi, "\\\\s");
	string = string.replace(/\\S/gi, "\\\\S");
	string = string.replace(/\\w/gi, "\\\\w");
	string = string.replace(/\\W/gi, "\\\\W");
	
	return string;			
}
};
/* ---------------------------------------------------------------------- *\
  Function    : $(id)
  Description : Returns the elemtn referred by the id
  Usage       : $(id)
  Arguments   : id - id to be used to identify element
  Return      : Returns object
\* ---------------------------------------------------------------------- */
function $(id) {
	return document.getElementById(id);
}
/* ---------------------------------------------------------------------- *\
  Function    : defined(p)
  Description : Verifies if an object is defined 
  Usage       : defined(p)
  Arguments   : p - the object or variable being sought
  Return      : Returns true or false
\* ---------------------------------------------------------------------- */
function defined(p){
	return typeof p == "undefined" ? false : true;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
/*  AES implementation in JavaScript (c) Chris Veness 2005-2011                                   */
/*   - see http://csrc.nist.gov/publications/PubsFIPS.html#197                                    */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */

var Aes = {};  // Aes namespace

/**
 * AES Cipher function: encrypt 'input' state with Rijndael algorithm
 *   applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage
 *
 * @param {Number[]} input 16-byte (128-bit) input state array
 * @param {Number[][]} w   Key schedule as 2D byte-array (Nr+1 x Nb bytes)
 * @returns {Number[]}     Encrypted output state array
 */
Aes.cipher = function(input, w) {    // main Cipher function [§5.1]
  var Nb = 4;               // block size (in words): no of columns in state (fixed at 4 for AES)
  var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys

  var state = [[],[],[],[]];  // initialise 4xNb byte-array 'state' with input [§3.4]
  for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i];

  state = Aes.addRoundKey(state, w, 0, Nb);

  for (var round=1; round<Nr; round++) {
    state = Aes.subBytes(state, Nb);
    state = Aes.shiftRows(state, Nb);
    state = Aes.mixColumns(state, Nb);
    state = Aes.addRoundKey(state, w, round, Nb);
  }

  state = Aes.subBytes(state, Nb);
  state = Aes.shiftRows(state, Nb);
  state = Aes.addRoundKey(state, w, Nr, Nb);

  var output = new Array(4*Nb);  // convert state to 1-d array before returning [§3.4]
  for (var i=0; i<4*Nb; i++) output[i] = state[i%4][Math.floor(i/4)];
  return output;
}

/**
 * Perform Key Expansion to generate a Key Schedule
 *
 * @param {Number[]} key Key as 16/24/32-byte array
 * @returns {Number[][]} Expanded key schedule as 2D byte-array (Nr+1 x Nb bytes)
 */
Aes.keyExpansion = function(key) {  // generate Key Schedule (byte-array Nr+1 x Nb) from Key [§5.2]
  var Nb = 4;            // block size (in words): no of columns in state (fixed at 4 for AES)
  var Nk = key.length/4  // key length (in words): 4/6/8 for 128/192/256-bit keys
  var Nr = Nk + 6;       // no of rounds: 10/12/14 for 128/192/256-bit keys

  var w = new Array(Nb*(Nr+1));
  var temp = new Array(4);

  for (var i=0; i<Nk; i++) {
    var r = [key[4*i], key[4*i+1], key[4*i+2], key[4*i+3]];
    w[i] = r;
  }

  for (var i=Nk; i<(Nb*(Nr+1)); i++) {
    w[i] = new Array(4);
    for (var t=0; t<4; t++) temp[t] = w[i-1][t];
    if (i % Nk == 0) {
      temp = Aes.subWord(Aes.rotWord(temp));
      for (var t=0; t<4; t++) temp[t] ^= Aes.rCon[i/Nk][t];
    } else if (Nk > 6 && i%Nk == 4) {
      temp = Aes.subWord(temp);
    }
    for (var t=0; t<4; t++) w[i][t] = w[i-Nk][t] ^ temp[t];
  }

  return w;
}

/*
 * ---- remaining routines are private, not called externally ----
 */
 
Aes.subBytes = function(s, Nb) {    // apply SBox to state S [§5.1.1]
  for (var r=0; r<4; r++) {
    for (var c=0; c<Nb; c++) s[r][c] = Aes.sBox[s[r][c]];
  }
  return s;
}

Aes.shiftRows = function(s, Nb) {    // shift row r of state S left by r bytes [§5.1.2]
  var t = new Array(4);
  for (var r=1; r<4; r++) {
    for (var c=0; c<4; c++) t[c] = s[r][(c+r)%Nb];  // shift into temp copy
    for (var c=0; c<4; c++) s[r][c] = t[c];         // and copy back
  }          // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
  return s;  // see asmaes.sourceforge.net/rijndael/rijndaelImplementation.pdf
}

Aes.mixColumns = function(s, Nb) {   // combine bytes of each col of state S [§5.1.3]
  for (var c=0; c<4; c++) {
    var a = new Array(4);  // 'a' is a copy of the current column from 's'
    var b = new Array(4);  // 'b' is a•{02} in GF(2^8)
    for (var i=0; i<4; i++) {
      a[i] = s[i][c];
      b[i] = s[i][c]&0x80 ? s[i][c]<<1 ^ 0x011b : s[i][c]<<1;

    }
    // a[n] ^ b[n] is a•{03} in GF(2^8)
    s[0][c] = b[0] ^ a[1] ^ b[1] ^ a[2] ^ a[3]; // 2*a0 + 3*a1 + a2 + a3
    s[1][c] = a[0] ^ b[1] ^ a[2] ^ b[2] ^ a[3]; // a0 * 2*a1 + 3*a2 + a3
    s[2][c] = a[0] ^ a[1] ^ b[2] ^ a[3] ^ b[3]; // a0 + a1 + 2*a2 + 3*a3
    s[3][c] = a[0] ^ b[0] ^ a[1] ^ a[2] ^ b[3]; // 3*a0 + a1 + a2 + 2*a3
  }
  return s;
}

Aes.addRoundKey = function(state, w, rnd, Nb) {  // xor Round Key into state S [§5.1.4]
  for (var r=0; r<4; r++) {
    for (var c=0; c<Nb; c++) state[r][c] ^= w[rnd*4+c][r];
  }
  return state;
}

Aes.subWord = function(w) {    // apply SBox to 4-byte word w
  for (var i=0; i<4; i++) w[i] = Aes.sBox[w[i]];
  return w;
}

Aes.rotWord = function(w) {    // rotate 4-byte word w left by one byte
  var tmp = w[0];
  for (var i=0; i<3; i++) w[i] = w[i+1];
  w[3] = tmp;
  return w;
}

// sBox is pre-computed multiplicative inverse in GF(2^8) used in subBytes and keyExpansion [§5.1.1]
Aes.sBox =  [0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
             0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
             0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
             0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
             0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
             0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
             0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
             0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
             0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
             0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
             0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
             0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
             0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
             0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
             0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
             0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16];

// rCon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [§5.2]
Aes.rCon = [ [0x00, 0x00, 0x00, 0x00],
             [0x01, 0x00, 0x00, 0x00],
             [0x02, 0x00, 0x00, 0x00],
             [0x04, 0x00, 0x00, 0x00],
             [0x08, 0x00, 0x00, 0x00],
             [0x10, 0x00, 0x00, 0x00],
             [0x20, 0x00, 0x00, 0x00],
             [0x40, 0x00, 0x00, 0x00],
             [0x80, 0x00, 0x00, 0x00],
             [0x1b, 0x00, 0x00, 0x00],
             [0x36, 0x00, 0x00, 0x00] ]; 


/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
/*  AES Counter-mode implementation in JavaScript (c) Chris Veness 2005-2011                      */
/*   - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf                       */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */

Aes.Ctr = {};  // Aes.Ctr namespace: a subclass or extension of Aes

/** 
 * Encrypt a text using AES encryption in Counter mode of operation
 *
 * Unicode multi-byte character safe
 *
 * @param {String} plaintext Source text to be encrypted
 * @param {String} password  The password to use to generate a key
 * @param {Number} nBits     Number of bits to be used in the key (128, 192, or 256)
 * @returns {string}         Encrypted text
 */
Aes.Ctr.encrypt = function(plaintext, password, nBits) {
  var blockSize = 16;  // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
  if (!(nBits==128 || nBits==192 || nBits==256)) return '';  // standard allows 128/192/256 bit keys
  plaintext = Utf8.encode(plaintext);
  password = Utf8.encode(password);
  //var t = new Date();  // timer
	
  // use AES itself to encrypt password to get cipher key (using plain password as source for key 
  // expansion) - gives us well encrypted key (though hashed key might be preferred for prod'n use)
  var nBytes = nBits/8;  // no bytes in key (16/24/32)
  var pwBytes = new Array(nBytes);
  for (var i=0; i<nBytes; i++) {  // use 1st 16/24/32 chars of password for key
    pwBytes[i] = isNaN(password.charCodeAt(i)) ? 0 : password.charCodeAt(i);
  }
  var key = Aes.cipher(pwBytes, Aes.keyExpansion(pwBytes));  // gives us 16-byte key
  key = key.concat(key.slice(0, nBytes-16));  // expand key to 16/24/32 bytes long

  // initialise 1st 8 bytes of counter block with nonce (NIST SP800-38A §B.2): [0-1] = millisec, 
  // [2-3] = random, [4-7] = seconds, together giving full sub-millisec uniqueness up to Feb 2106
  var counterBlock = new Array(blockSize);
  
  var nonce = (new Date()).getTime();  // timestamp: milliseconds since 1-Jan-1970
  var nonceMs = nonce%1000;
  var nonceSec = Math.floor(nonce/1000);
  var nonceRnd = Math.floor(Math.random()*0xffff);
  
  for (var i=0; i<2; i++) counterBlock[i]   = (nonceMs  >>> i*8) & 0xff;
  for (var i=0; i<2; i++) counterBlock[i+2] = (nonceRnd >>> i*8) & 0xff;
  for (var i=0; i<4; i++) counterBlock[i+4] = (nonceSec >>> i*8) & 0xff;
  
  // and convert it to a string to go on the front of the ciphertext
  var ctrTxt = '';
  for (var i=0; i<8; i++) ctrTxt += String.fromCharCode(counterBlock[i]);

  // generate key schedule - an expansion of the key into distinct Key Rounds for each round
  var keySchedule = Aes.keyExpansion(key);
  
  var blockCount = Math.ceil(plaintext.length/blockSize);
  var ciphertxt = new Array(blockCount);  // ciphertext as array of strings
  
  for (var b=0; b<blockCount; b++) {
    // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
    // done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB)
    for (var c=0; c<4; c++) counterBlock[15-c] = (b >>> c*8) & 0xff;
    for (var c=0; c<4; c++) counterBlock[15-c-4] = (b/0x100000000 >>> c*8)

    var cipherCntr = Aes.cipher(counterBlock, keySchedule);  // -- encrypt counter block --
    
    // block size is reduced on final block
    var blockLength = b<blockCount-1 ? blockSize : (plaintext.length-1)%blockSize+1;
    var cipherChar = new Array(blockLength);
    
    for (var i=0; i<blockLength; i++) {  // -- xor plaintext with ciphered counter char-by-char --
      cipherChar[i] = cipherCntr[i] ^ plaintext.charCodeAt(b*blockSize+i);
      cipherChar[i] = String.fromCharCode(cipherChar[i]);
    }
    ciphertxt[b] = cipherChar.join(''); 
  }

  // Array.join is more efficient than repeated string concatenation in IE
  var ciphertext = ctrTxt + ciphertxt.join('');
  ciphertext = Base64.encode(ciphertext);  // encode in base64
  
  //alert((new Date()) - t);
  return ciphertext;
}

/** 
 * Decrypt a text encrypted by AES in counter mode of operation
 *
 * @param {String} ciphertext Source text to be encrypted
 * @param {String} password   The password to use to generate a key
 * @param {Number} nBits      Number of bits to be used in the key (128, 192, or 256)
 * @returns {String}          Decrypted text
 */
Aes.Ctr.decrypt = function(ciphertext, password, nBits) {
  var blockSize = 16;  // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
  if (!(nBits==128 || nBits==192 || nBits==256)) return '';  // standard allows 128/192/256 bit keys
  ciphertext = Base64.decode(ciphertext);
  password = Utf8.encode(password);
  //var t = new Date();  // timer
  
  // use AES to encrypt password (mirroring encrypt routine)
  var nBytes = nBits/8;  // no bytes in key
  var pwBytes = new Array(nBytes);
  for (var i=0; i<nBytes; i++) {
    pwBytes[i] = isNaN(password.charCodeAt(i)) ? 0 : password.charCodeAt(i);
  }
  var key = Aes.cipher(pwBytes, Aes.keyExpansion(pwBytes));
  key = key.concat(key.slice(0, nBytes-16));  // expand key to 16/24/32 bytes long

  // recover nonce from 1st 8 bytes of ciphertext
  var counterBlock = new Array(8);
  ctrTxt = ciphertext.slice(0, 8);
  for (var i=0; i<8; i++) counterBlock[i] = ctrTxt.charCodeAt(i);
  
  // generate key schedule
  var keySchedule = Aes.keyExpansion(key);

  // separate ciphertext into blocks (skipping past initial 8 bytes)
  var nBlocks = Math.ceil((ciphertext.length-8) / blockSize);
  var ct = new Array(nBlocks);
  for (var b=0; b<nBlocks; b++) ct[b] = ciphertext.slice(8+b*blockSize, 8+b*blockSize+blockSize);
  ciphertext = ct;  // ciphertext is now array of block-length strings

  // plaintext will get generated block-by-block into array of block-length strings
  var plaintxt = new Array(ciphertext.length);

  for (var b=0; b<nBlocks; b++) {
    // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
    for (var c=0; c<4; c++) counterBlock[15-c] = ((b) >>> c*8) & 0xff;
    for (var c=0; c<4; c++) counterBlock[15-c-4] = (((b+1)/0x100000000-1) >>> c*8) & 0xff;

    var cipherCntr = Aes.cipher(counterBlock, keySchedule);  // encrypt counter block

    var plaintxtByte = new Array(ciphertext[b].length);
    for (var i=0; i<ciphertext[b].length; i++) {
      // -- xor plaintxt with ciphered counter byte-by-byte --
      plaintxtByte[i] = cipherCntr[i] ^ ciphertext[b].charCodeAt(i);
      plaintxtByte[i] = String.fromCharCode(plaintxtByte[i]);
    }
    plaintxt[b] = plaintxtByte.join('');
  }

  // join array of blocks into single plaintext string
  var plaintext = plaintxt.join('');
  plaintext = Utf8.decode(plaintext);  // decode from UTF8 back to Unicode multi-byte chars
  
  //alert((new Date()) - t);
  return plaintext;
}


/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
/*  Base64 class: Base 64 encoding / decoding (c) Chris Veness 2002-2011                          */
/*    note: depends on Utf8 class                                                                 */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */

var Base64 = {};  // Base64 namespace

Base64.code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

/**
 * Encode string into Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648]
 * (instance method extending String object). As per RFC 4648, no newlines are added.
 *
 * @param {String} str The string to be encoded as base-64
 * @param {Boolean} [utf8encode=false] Flag to indicate whether str is Unicode string to be encoded 
 *   to UTF8 before conversion to base64; otherwise string is assumed to be 8-bit characters
 * @returns {String} Base64-encoded string
 */ 
Base64.encode = function(str, utf8encode) {  // http://tools.ietf.org/html/rfc4648
  utf8encode =  (typeof utf8encode == 'undefined') ? false : utf8encode;
  var o1, o2, o3, bits, h1, h2, h3, h4, e=[], pad = '', c, plain, coded;
  var b64 = Base64.code;
   
  plain = utf8encode ? str.encodeUTF8() : str;
  
  c = plain.length % 3;  // pad string to length of multiple of 3
  if (c > 0) { while (c++ < 3) { pad += '='; plain += '\0'; } }
  // note: doing padding here saves us doing special-case packing for trailing 1 or 2 chars
   
  for (c=0; c<plain.length; c+=3) {  // pack three octets into four hexets
    o1 = plain.charCodeAt(c);
    o2 = plain.charCodeAt(c+1);
    o3 = plain.charCodeAt(c+2);
      
    bits = o1<<16 | o2<<8 | o3;
      
    h1 = bits>>18 & 0x3f;
    h2 = bits>>12 & 0x3f;
    h3 = bits>>6 & 0x3f;
    h4 = bits & 0x3f;

    // use hextets to index into code string
    e[c/3] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
  }
  coded = e.join('');  // join() is far faster than repeated string concatenation in IE
  
  // replace 'A's from padded nulls with '='s
  coded = coded.slice(0, coded.length-pad.length) + pad;
   
  return coded;
}

/**
 * Decode string from Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648]
 * (instance method extending String object). As per RFC 4648, newlines are not catered for.
 *
 * @param {String} str The string to be decoded from base-64
 * @param {Boolean} [utf8decode=false] Flag to indicate whether str is Unicode string to be decoded 
 *   from UTF8 after conversion from base64
 * @returns {String} decoded string
 */ 
Base64.decode = function(str, utf8decode) {
  utf8decode =  (typeof utf8decode == 'undefined') ? false : utf8decode;
  var o1, o2, o3, h1, h2, h3, h4, bits, d=[], plain, coded;
  var b64 = Base64.code;

  coded = utf8decode ? str.decodeUTF8() : str;
  
  
  for (var c=0; c<coded.length; c+=4) {  // unpack four hexets into three octets
    h1 = b64.indexOf(coded.charAt(c));
    h2 = b64.indexOf(coded.charAt(c+1));
    h3 = b64.indexOf(coded.charAt(c+2));
    h4 = b64.indexOf(coded.charAt(c+3));
      
    bits = h1<<18 | h2<<12 | h3<<6 | h4;
      
    o1 = bits>>>16 & 0xff;
    o2 = bits>>>8 & 0xff;
    o3 = bits & 0xff;
    
    d[c/4] = String.fromCharCode(o1, o2, o3);
    // check for padding
    if (h4 == 0x40) d[c/4] = String.fromCharCode(o1, o2);
    if (h3 == 0x40) d[c/4] = String.fromCharCode(o1);
  }
  plain = d.join('');  // join() is far faster than repeated string concatenation in IE
   
  return utf8decode ? plain.decodeUTF8() : plain; 
}


/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
/*  Utf8 class: encode / decode between multi-byte Unicode characters and UTF-8 multiple          */
/*              single-byte character encoding (c) Chris Veness 2002-2011                         */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */

var Utf8 = {};  // Utf8 namespace

/**
 * Encode multi-byte Unicode string into utf-8 multiple single-byte characters 
 * (BMP / basic multilingual plane only)
 *
 * Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars
 *
 * @param {String} strUni Unicode string to be encoded as UTF-8
 * @returns {String} encoded string
 */
Utf8.encode = function(strUni) {
  // use regular expressions & String.replace callback function for better efficiency 
  // than procedural approaches
  var strUtf = strUni.replace(
      /[\u0080-\u07ff]/g,  // U+0080 - U+07FF => 2 bytes 110yyyyy, 10zzzzzz
      function(c) { 
        var cc = c.charCodeAt(0);
        return String.fromCharCode(0xc0 | cc>>6, 0x80 | cc&0x3f); }
    );
  strUtf = strUtf.replace(
      /[\u0800-\uffff]/g,  // U+0800 - U+FFFF => 3 bytes 1110xxxx, 10yyyyyy, 10zzzzzz
      function(c) { 
        var cc = c.charCodeAt(0); 
        return String.fromCharCode(0xe0 | cc>>12, 0x80 | cc>>6&0x3F, 0x80 | cc&0x3f); }
    );
  return strUtf;
}

/**
 * Decode utf-8 encoded string back into multi-byte Unicode characters
 *
 * @param {String} strUtf UTF-8 string to be decoded back to Unicode
 * @returns {String} decoded string
 */
Utf8.decode = function(strUtf) {
  // note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char!
  var strUni = strUtf.replace(
      /[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g,  // 3-byte chars
      function(c) {  // (note parentheses for precence)
        var cc = ((c.charCodeAt(0)&0x0f)<<12) | ((c.charCodeAt(1)&0x3f)<<6) | ( c.charCodeAt(2)&0x3f); 
        return String.fromCharCode(cc); }
    );
  strUni = strUni.replace(
      /[\u00c0-\u00df][\u0080-\u00bf]/g,                 // 2-byte chars
      function(c) {  // (note parentheses for precence)
        var cc = (c.charCodeAt(0)&0x1f)<<6 | c.charCodeAt(1)&0x3f;
        return String.fromCharCode(cc); }
    );
  return strUni;
}
var SREKey='';
/*
function sre_GetKey(){
  path=	SRESrever+'/srp/srp_system/'+SREPath+'.srp';
  sre_ajax.asyncPost("124942",path,FUNC_KEY,true,"111",'N');
}
function FUNC_KEY(response,obj,id) {
  SREKey = response;
}
 */
sreEnc = function(str){
  encrstr =Aes.Ctr.encrypt(str, SREKey, 256);
  
  //encrstr =Aes.Ctr.encrypt(str, 'saas', 256);
  return encrstr;
}
sreDec = function(str){
  decrstr =Aes.Ctr.decrypt(str, SREKey, 256);
  return decrstr;
}

/* -----------------------END(sre_core)---------------------------------- */
/* ---------------------------------------------------------------------- *\
  CryptoMX Tools
  Copyright (C) 2004 - 2006 Derek Buitenhuis

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
\* ---------------------------------------------------------------------- */
/* ---------------------Begin(sre_encrypy)---------------------------------- *\
 * eMiliue v1.0 Copyright (c) 2010 Sreejon LLC 
 * Contact us at sreejon2006@msn.com
 * This copyright notice MUST stay intact for use.
 *
 * $Revision: 1.0 $

Dependency :	[Meant to work with Sreejon message structure ]
				None

Description :	All core functions to quickly encrypt and decrypt an message 
Usage:

hex to ascii:
<textarea rows="9" name="HexET" cols="50"></textarea>
<input type="button" value="HexToAscii" onClick="AsciiPT.value=DoAsciiHex(HexET.value,'H2A')">
<textarea rows="9" name="AsciiPT" cols="50"></textarea>

ascii to hex

<textarea rows="9" name="AsciiET" cols="50"></textarea><br>
<input type="button" value="AsciiToHex" onClick="HexPT.value=DoAsciiHex(AsciiET.value,'A2H')">
<textarea rows="9" name="HexPT" cols="50"></textarea>


\* ---------------------------------------------------------------------- */


var MCarr=new Array(
"*","|",".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",
".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..","-----",".----","..---","...--","....-",
".....","-....","--...","---..","----."
);
var ABC012arr="*|ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

function DoMorseDecrypt(x)
{mess="";apos=0;bpos=0;
while(bpos<x.length)
{
 bpos=x.indexOf(" ",apos);if(bpos<0){bpos=x.length};
 dits=x.substring(apos,bpos);
 apos=bpos+1;
 let="";
 for(j=0;j<MCarr.length;j++){  if(dits==MCarr[j]){let=ABC012arr.charAt(j)}  };
 if(let==""){let="*"};
 mess+=let;
};
return mess;
};

function DoMorseEncrypt(x)
{mess="";
for(i=0;i<x.length;i++)
{
let=x.charAt(i).toUpperCase();
for(j=0;j<MCarr.length;j++){  if(let==ABC012arr.charAt(j)){mess+=MCarr[j]}  };
mess+=" ";
};
mess=mess.substring(0,mess.length-1);
return mess;
};


function DoReverse(x){y="";for(i=0;i<x.length;i++){y+=x.charAt(x.length-1-i);};return y};


function DoCaeserEncrypt(x,shf)
{
abc="abcdefghijklmnopqrstuvwxyz";
ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
r1="";r2="";shf=eval(shf);
for(i=0;i<x.length;i++){let=x.charAt(i);pos=ABC.indexOf(let);if(pos>=0){r1+=ABC.charAt(  (pos+shf)%26  )}else{r1+=let};};
for(i=0;i<r1.length;i++){let=r1.charAt(i);pos=abc.indexOf(let);if(pos>=0){r2+=abc.charAt(  (pos+shf)%26  )}else{r2+=let};};
return r2;
};

function DoCaeserDecrypt(x,shf)
{return DoCaeserEncrypt(x,26-shf);};


function MakeCipherABC(abc,key1)
{
abc=abc.toUpperCase();key1=key1.toUpperCase();
cyabc=key1+abc;
for(i=0;i<abc.length;i++){let=cyabc.charAt(i);pos=cyabc.indexOf(let,i+1);
while(pos>-1){cyabc=cyabc.substring(0,pos)+cyabc.substring(pos+1,cyabc.length);pos=cyabc.indexOf(let,i+1);};};
return cyabc;
}


function DoVigenere(et,key1,key2,abc,dir,vigtype,altluabc)
{dt="";et=et.toUpperCase();key1=key1.toUpperCase();key2=key2.toUpperCase();abc=abc.toUpperCase();dir=dir.toUpperCase();
pos=et.indexOf(" ");
while(pos>-1){et=et.substring(0,pos)+et.substring(pos+1,et.length);pos=et.indexOf(" ");};
cyabc=MakeCipherABC(abc,key1);
key1=cyabc;
lu=cyabc;
if(vigtype=="N"){lu=abc};
if(vigtype=="K"){lu=cyabc};
if(vigtype=="A"){lu=altluabc};
for(i=0;i<et.length;i++)
{let=et.charAt(i);letinabc=abc.indexOf(let);
if(letinabc<0){dt+=let;et=et.substring(0,i)+et.substring(i+1,et.length);i--}
else{
if(dir=="E"){dt+=lu.charAt((key1.indexOf(let)+key1.length+key1.indexOf(key2.charAt(i%key2.length)))%key1.length);};
if(dir=="D"){dt+=lu.charAt((key1.indexOf(let)+key1.length-key1.indexOf(key2.charAt(i%key2.length)))%key1.length);};};

};
return dt;};

function DoFreqCnt(x,abc)
{var i,abc,pos,freqs;
 pos=x.indexOf(" ");while(pos>-1){x=x.substring(0,pos)+x.substring(pos+1,x.length);pos=x.indexOf(" ");};
 x=x.toUpperCase();freqs="";
 letarr=new Array("");
 for(i=0;i<abc.length;i++){letarr[i]=0;};
 for(i=0;i<x.length;i++){letarr[abc.indexOf(x.charAt(i))]++};
 for(i=0;i<abc.length;i++){freqs+=abc.charAt(i)+":"+letarr[i]+"/"+x.length+"="+letarr[i]/x.length+"\n";};
 return freqs;
}

function DoRowColumnTranspose(et,rowcol,jump,startrow)
{dt="";if((et=="")||(rowcol=="")||(jump=="")||(startrow=="")){dt="You must supply all values";return dt;}
maxrow=eval(rowcol.substring(0,rowcol.indexOf(",")));
maxcol=eval(rowcol.substring(rowcol.indexOf(",")+1,rowcol.length));
jump=eval(jump);startrow=eval(startrow);
if(startrow>maxrow){dt="Start Row must be <= Max Rows";return dt;}
lin=new Array("");
for(i=0;i<maxrow;i++){lin[i]=et.substring(maxcol*i,maxcol*(i+1))};
row=startrow-1;col=maxcol-1;//starting point
for(i=0;i<(maxrow*maxcol);i++)
{dt+=lin[row].charAt(col);
 row=row+jump;
 while(row>=maxrow){row-=maxrow;col-=1;};
 while(col<=-1){col+=maxcol;row-=1;};
 while(row<=-1){row+=maxrow;col-=1;};
 while(col>=maxcol){col-=maxcol;row-=1;};
};
return dt;};


function DoModTranspose(et,startlet,jumpinc,modulus)
{dt="";if((et=="")||(startlet=="")||(jumpinc=="")||(modulus=="")){dt="You must supply all values";return dt;}
startlet=eval(startlet)-1;jumpinc=eval(jumpinc);modulus=eval(modulus);
if(startlet>modulus){dt="startlet must be <= maxchar";return dt;}
et=escape(et);
pos=et.indexOf("%0D");
while(pos>-1){et=et.substring(0,pos)+et.substring(pos+3,et.length);pos=et.indexOf("%0D");};
pos=et.indexOf("%0A");
while(pos>-1){et=et.substring(0,pos)+et.substring(pos+3,et.length);pos=et.indexOf("%0A");};
et=unescape(et);
for(i=0;i<(modulus);i++){dt+=et.charAt((startlet+jumpinc*i)%modulus);};
return dt;};


function DoAsciiHex(x,dir)
{hex="0123456789ABCDEF";almostAscii=' !"#$%&'+"'"+'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ['+'\\'+']^_`abcdefghijklmnopqrstuvwxyz{|}';r="";
if(dir=="A2H")
{for(i=0;i<x.length;i++){let=x.charAt(i);pos=almostAscii.indexOf(let)+32;h16=Math.floor(pos/16);h1=pos%16;r+=hex.charAt(h16)+hex.charAt(h1);};};
if(dir=="H2A")
{for(i=0;i<x.length;i++){let1=x.charAt(2*i);let2=x.charAt(2*i+1);val=hex.indexOf(let1)*16+hex.indexOf(let2);r+=almostAscii.charAt(val-32);};};
return r;
};


function DoSubstitute(x,orig,sub,dir)
{
x=x.toUpperCase();r="";
if(dir=="e")
{for(i=0;i<x.length;i++){let=x.charAt(i);pos=orig.indexOf(let);if(pos>-1){r+=sub.charAt(pos)}else{r+=let}}};
if(dir=="d")
{for(i=0;i<x.length;i++){let=x.charAt(i);pos=sub.indexOf(let);if(pos>-1){r+=orig.charAt(pos)}else{r+=let}}};
return r;
};

function SwitchEm(x,a,b)
{
posA=x.indexOf(a);
posB=x.indexOf(b);
r1=x.substring(0,posA)+b+x.substring(posA+1,x.length);
r2=r1.substring(0,posB)+a+r1.substring(posB+1,r1.length);
return r2;
};





function MakePlayfairSquare(abc,key1)
{
cyabc=MakeCipherABC(abc,key1);
row = new Array();for(i=0;i<5;i++){row[i]=""};
for(i=0;i<5;i++){for(j=0;j<5;j++)row[i]+=cyabc.charAt(5*i+j);};
sqr="";for(i=0;i<5;i++){sqr+=row[i]+"\n"};
return sqr;
};


function DoPlayfair(et,abc,key1,dir,dup)
{
et=et.toUpperCase();abc=abc.toUpperCase();key1=key1.toUpperCase();
pos=et.indexOf(" ");
while(pos>-1){et=et.substring(0,pos)+et.substring(pos+1,et.length);pos=et.indexOf(" ");};

pos=et.indexOf("?");
while(pos>-1){et=et.substring(0,pos)+et.substring(pos+1,et.length);pos=et.indexOf("?");};

for(i=0;i<et.length;i=i+2)
{let1=et.charAt(i);let2=et.charAt(i+1);if(let1==let2){et=et.substring(0,i+1)+"X"+et.substring(i+1,et.length)};};
if( (et.length%2)==1 ){et+='X'}

if(dup!=""){
pos=et.indexOf(dup);
while(pos>-1){et=et.substring(0,pos)+"I"+et.substring(pos+1,et.length);pos=et.indexOf(dup);};
};

cyabc=MakeCipherABC(abc,key1)
row=new Array();for(i=0;i<5;i++){row[i]=""};
for(i=0;i<5;i++){for(j=0;j<5;j++)row[i]+=cyabc.charAt(5*i+j);};

shf=1;if(dir=="E"){shf=1};if(dir=="D"){shf=4};

dt="";
for(i=0;i<et.length;i=i+2)
{
pos1=cyabc.indexOf(et.charAt(i));pos2=cyabc.indexOf(et.charAt(i+1));
x1=pos1%5;y1=Math.floor(pos1/5);x2=pos2%5;y2=Math.floor(pos2/5);

if(y1==y2){x1=(x1+shf)%5;x2=(x2+shf)%5}
else if(x1==x2){y1=(y1+shf)%5;y2=(y2+shf)%5}
else{temp=x1;x1=x2;x2=temp};

dt+=row[y1].charAt(x1)+row[y2].charAt(x2) ;
};


return dt;
};

/* -----------------------END(sre_encrypy)---------------------------------- */

/* ---------------------Begin(sre_ajax)---------------------------------- *\
 * eMiliue v1.0 Copyright (c) 2010 Sreejon LLC 
 * Contact us at sreejon2006@msn.com
 * This copyright notice MUST stay intact for use.
 *
 * $Revision: 1.0 $

Dependency :	[Meant to work with Sreejon message structure ]
				No dependency

Description :	All Ajax rountines needed for asynchronous calls 

Sample call for Ajax Get and Post

PLEASE MAKE SURE YOU CREATE A CALLBACK FUNCTION in calling page THAT LOOKS LIKE :
function [callback function name](response,obj,id) {
}

GET looks like this :
sre_ajax.asyncGet('http://www.sreejon.com/srp/test/dataBackup.srp?q=abcdefgh','[callback function name]',true,1234);

POST call looks like this:

	var Page ='';
	Page +='<username>'+username+'</username>';
	Page +='<password>'+password+'</password>';
	var redirecturl = "/srp_ch/test.srp";
	SREPHPAsyncSubmit(Page,redirecturl,[callback function name],true,1234);
	
or 
	[automatic XML parsing of the parameters will not be available]
	var Page ='';
	Page +='<username>'+username+'</username>';
	Page +='<password>'+password+'</password>';
	var redirecturl = "/srp_ch/test.srp";
	asyncPost(Page,redirecturl,[callback function name],true,1234);

response : is the response value
obj: is the xmlhttp objec itself
id: is the randon value sent with the request returned back 

For Response to be parsed in Javascript valiable Write response in target php:
Example:
$str = sre_start_async_namevalue_response($str);
$str = sre_create_async_namevalue_response($str,'name',$username,'|');
$str = sre_create_async_namevalue_response($str,'pass',$password,'|');
echo $str;

Response looks like ["SREResponse=var1:value1|var2:value2..".]

Then call javaScript function within the callback function and pass response from callback and the variable to be retrieved;
	value = parseAsyncNameValueResponse(response,'pass','|',0);

xmlhttp.readyState:
0 - Uninitialized
1 - Loading
2 - Loaded
3 - Interactive
4 - Complete
xmlhttp.status:
200: Everything is OK
401: Unauthorized
403: Forbidden
404: Not Found
301: Moved permanently
302: Found (the request was redirected to another URL/URI)
305: Use Proxy (the request must use a proxy to access the resource requested)
\* ---------------------------------------------------------------------- */

var sre_ajax = {
	Settings: function() {
		this.reqId = '';
		this.xmlHttp;
		this.responseText='';;
	},
	config: new Array(),
	setSettings: function(n, settings) {
		if(typeof(settings) != "object") {
			this.config[n] = new this.Settings();
		}
		else {
			this.config[n] = settings;
		}
		this.config[n].reqId = n;
	},

/* ---------------------------------------------------------------------- *\
  Function    : asyncPost(xmlparam,action,funcname,asyncyn,id,procYN)
  Description : Submits an asynchronous POST request
  Usage       : sre_ajax.asyncPost(xmlparam,action,funcname,asyncyn,id)
  Arguments   : xmlparam	- The xml parameter to be sent with the POST
                action      - The form action, or the submit url
				funcname    - The callback function. This function will be called once the POST returns
                asyncyn     - Flag to identify if (true: async) or (false: sync). Default is set to true. (optional)
                id          - The id passed here will be bounced back in the callback function (optional)
				procYN      - whether to show processing flag  -'Y' to show - default is not to show. 
  Return      : None. [Calls the callback function when done.]	
\* ---------------------------------------------------------------------- */
asyncPost: function (xmlparam,action,funcname,asyncyn,id,procYN) {
	this.setSettings(id,"");
	this.getXmlHttpObject(id);
	xmlhttp	= this.config[id].xmlHttp;

	if (xmlhttp==null)	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	if(!asyncyn) asyncyn = true;
		var url = action;
		var params = 'SRE_REQUEST=';
		params = params + xmlparam;
		xmlhttp.open("POST", url, asyncyn);
		//Send the proper header information along with the request
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-length", params.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.onreadystatechange=function() {
		if ( (sre_ajax.config[id].xmlHttp.readyState==4) && (sre_ajax.config[id].reqId == id)	){
			if (sre_ajax.config[id].xmlHttp.status==200) {
				if(procYN =='Y') {
					if($("sre_proc_txt")){
						$("sre_proc_txt").style.visibility = "hidden";
					}
					if($("sre_proc_img")){
						$("sre_proc_img").style.visibility = "hidden";
					}
				}
				funcname(sre_ajax.config[id].xmlHttp.responseText,sre_ajax.config[id].xmlHttp,id);
			} 	
		}
	}
//	SREActionFocus='';
//	if($(SREActionFocus)){
//		$(SREActionFocus).onfocus = $(SREActionFocus).blur; /* VERY IMPORTANT ****************/
//	}
	xmlhttp.send(params);
},
/* ---------------------------------------------------------------------- *\
  Function    : asyncGet(qualifiedget,funcname,asyncyn,id,procYN)
  Description : Submits an asynchronous GET request
  Usage       : sre_ajax.asyncGet(qualifiedget,funcname,asyncyn,id)
  Arguments   : qualifiedget	- The qualified url querystring for GET
				funcname		- The callback function. This function will be called once the GET returns
                asyncyn			- Flag to identify if (true: async) or (false: sync). Default is set to true. (optional)
                id				- The id passed here will be bounced back in the callback function (optional)
				procYN      - whether to show processing flag  -'Y' to show - default is not to show. 
  Return      : None. [Calls the callback function when done.]	
\* ---------------------------------------------------------------------- */
asyncGet: function (qualifiedget,funcname,asyncyn,id,procYN) {
	this.setSettings(id,"");
	this.getXmlHttpObject(id);
	xmlhttp	= this.config[id].xmlHttp;
	if (xmlhttp==null)	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	if(!asyncyn) asyncyn = true;
		var url=  qualifiedget;  
		url=url+"&sid="+id;
		xmlhttp.onreadystatechange=function() {
		if ( (sre_ajax.config[id].xmlHttp.readyState==4) && (sre_ajax.config[id].reqId == id)	){
			if (sre_ajax.config[id].xmlHttp.status==200) {
				if(procYN =='Y') {
					if($("sre_proc_txt")){
						$("sre_proc_txt").style.visibility = "hidden";
					}
					if($("sre_proc_img")){
						$("sre_proc_img").style.visibility = "hidden";
					}
				}
				//alert(id +'----'+ sre_ajax.config[id].xmlHttp.responseText);
				funcname(sre_ajax.config[id].xmlHttp.responseText,sre_ajax.config[id].xmlHttp,id);
			} 	
		}
	}
	xmlhttp.open("GET",url,asyncyn);
	xmlhttp.send(null);
},
/* ---------------------------------------------------------------------- *\
  Function    : getXmlHttpObject(id)
  Description : Retrieves the XmlHttpObject (browser compatible)
  Usage       : sre_ajax.getXmlHttpObject()
  Arguments   : id : id of the request 
  Return      : Ajax XMLHttpObject if successful, else null	
\* ---------------------------------------------------------------------- */
getXmlHttpObject: function (id)	{
	if (!this.config[id].xmlHttp) {
		if (window.XMLHttpRequest)  { // code for IE7+, Firefox, Chrome, Opera, Safari
			this.config[id].xmlHttp = new XMLHttpRequest();
		}
		if (window.ActiveXObject)  { // code for IE6, IE5
			this.config[id].xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}else if (this.xmlhttpArr[id].xmlhttp.readyState != 0) {
		this.config[id].xmlHttp.abort();
	}
},
errorPresent: function (response) {
/*	word="";pos=0;done=0;len = response.length;
	for(i=pos; i < len && done == 0; i++) {
		if(response.slice(i,i+1)=='='){
			word = response.slice(0,i);
			done = 1;
		}
	}
	if(word == 'SREErrorResponse') {
		return true;
	}
	return false;
*/
var test = response;
var myRegExp = /SREErrorResponse/;
var matchPos1 = test.search(myRegExp);
if(matchPos1 != -1) {
	return true; 
} 
	return false;

},
processAsyncError: function (response) {
	//errArr = new Array();
	err='';	mm = 0;
	while  ((mm < 10) && (err !='NOT_FOUND')){	
		j = mm;	
		err = sre_ajax.parseAsyncErrorResponse(response,j);
		
		mm++;//= parseInt(parseInt(mm) + 1);
		if(err !='NOT_FOUND'){
			SREErrorString += err;
			SREErrorString +='|';
			//SREErrorArr[SREErrorArr.length] = err;
		}
	}
	ERR_Search(SRELocale,SREErrorString,SREErrorString);
	//alert(SREErrorArr.length);
	//for(j=0; j < errArr.length; j++){
	//	setDictError(errArr[j]);
	//}
	//
},
parseAsyncErrorResponse: function (response,offset) {
	var pos=0; var posi=0;var indx=0;var word="";var len;var leni;
	var done=0; var donei=0;var ret = 1;var wordi="";
	var vname='';var vval='';
	var valout='NOT_FOUND'; 
	delim ='|';
	if(offset){} else {offset = 0}
	offs = 0;
	Scanword = response;
	Scanword += ' ';
	len = Scanword.length;

var test = Scanword;
var myRegExp = /SREErrorResponse/;
var matchPos1 = test.search(myRegExp);
if(matchPos1 != -1) {
	pos = matchPos1; 
} else {
	return valout;
}
	for(i=pos; i < len && done == 0; i++) {
		if(Scanword.slice(i,i+1)=='='){
			word = Scanword.slice(i+1,len);
			done = 1;
		}
	}
	Scanword = word;done = 0;word="";pos=0;
	len = Scanword.length;
	for(k=pos; k < len && done == 0; k++)	{
		if(Scanword.slice(k,k+1)==delim)		{
			word = Scanword.slice(pos,k);
			leni = word.length;
			for(j=posi; j < leni && donei == 0; j++){
				if(word.slice(j,j+1)==':') {
					vname= word.slice(posi,j); 
					vval= word.slice(j+1,leni);//alert("---  "+vval);
					if(vname == "sre_error_code"){
						if((vname == "sre_error_code") && (offs == offset) ){
							valout = vval;
						}
						offs++;
					}
				}
			}
			pos = k + 1;
		}
	}
	//alert("---  "+j);
	return valout;
},
/* ---------------------------------------------------------------------- *\
  Function    : parseAsyncNameValueResponse(response,varname,delim,offset)
  Description : Parses delimited response from the callback function. Specific format needed ["SREResponse=....".]
				Default delimiter is '|'. If multiple values are available for the same varname offset can be used to iterate through.
  Usage       : sre_ajax.parseAsyncNameValueResponse(response,varname,delim,offset)[has to start like "SREResponse=var1:value1|var2:value2..".]
  Arguments   : response	- The response in the callback function with special formatting (  qualified url querystring for GET
				varname		- The variable whose value is sought
                delim		- Delimiter used to create the response string. Default is '|' (optional)
                offset		- The offset of the value sought when multiple value for the same variable present (optional)
  Return      : The value that machtes the varname and the offset. Otherwise 'NOT_FOUND'	
\* ---------------------------------------------------------------------- */
parseAsyncNameValueResponse: function (response,varname,delim,offset) {
	var pos=0; var posi=0;var indx=0;var word="";var len;var leni;
	var done=0; var donei=0;var ret = 1;var wordi="";
	var vname='';var vval='';
	var valout='NOT_FOUND'; 
	if(delim){} else {delim ='|'}
	if(offset){} else {offset = 0}
	offs = 0;
	Scanword = response;
	Scanword += ' ';
	len = Scanword.length;

var test = Scanword;
var myRegExp = /SREResponse/;
var matchPos1 = test.search(myRegExp);
if(matchPos1 != -1) {
	pos = matchPos1; 
} else {
	return valout;
}

	for(i=pos; i < len && done == 0; i++) {
		if(Scanword.slice(i,i+1)=='='){
		//	test = Scanword.slice(i-11,11);
		//	if(test =="SREResponse") {
				word = Scanword.slice(i+1,len);
				done = 1;
		//	}
		}
	}
	Scanword = word;done = 0;word="";pos=0;
	len = Scanword.length;
	for(k=pos; k < len && done == 0; k++)	{
		if(Scanword.slice(k,k+1)==delim)		{
			word = Scanword.slice(pos,k);
			leni = word.length;
			for(j=posi; j < leni && donei == 0; j++){
				if(word.slice(j,j+1)==':') {
					vname= word.slice(posi,j);
					//if (varname =='tmplpath') alert("aaaa : " +vname);
					vval= word.slice(j+1,leni);
					if(vname == varname){
						if((vname == varname) && (offs == offset) ){
							valout = vval;
						}
						offs++;
					}
				}
			}
			pos = k + 1;
		}
	}
	return valout;
}

};
/* -----------------------END(sre_ajax)---------------------------------- */

/* ---------------------Begin(sre_date)---------------------------------- *\
 * eMiliue v1.0 Copyright (c) 2010 Sreejon LLC 
 * Contact us at sreejon2006@msn.com
 * This copyright notice MUST stay intact for use.
 *
 * $Revision: 1.0 $

Dependency :	[Meant to work with Sreejon message structure ]
				None

Description :	All core JS Date formatting functions that are used everywhere in the system 

Usage :
var myDate = new Date();
alert(myDate.format('M jS, Y')); // May 11th, 2006 

Here are the format options that may be used (taken from php.net and modified a bit):format character	Description	Example returned values
Day
d		01 to 31
D		Mon through Sun
j		1 to 31
l		Sunday through Saturday
N		1 (for Monday) through 7 (for Sunday)
S	    English ordinal suffix for the day of the month, 2 characters	st, nd, rd or th. Works well with j 
w	    0 (for Sunday) through 6 (for Saturday)
z       (unsuported)	The day of the year (starting from 0)	0 through 365

Week
W       (unsuported)	ISO-8601 week number of year, weeks starting on Monday 

Month
F		January through December
m		01 through 12
M		Jan through Dec
n		1 through 12
t       (unsuported)	Number of days in the given month	28 through 31

Year
L	   1 if it is a leap year, 0 otherwise.
o      (unsuported)	ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0)	Examples: 1999 or 2003
Y	   1999 or 2003
y	   99 or 03

Time
a		am or pm
A		AM or PM
B      (unsuported)	Swatch Internet time	000 through 999
g	  	1 through 12
G		0 through 23
h		01 through 12
H		00 through 23
i		Minutes with leading zeros	00 to 59
s		Seconds, with leading zeros	00 through 59

Timezone
e		(unsuported)	Timezone identifier (added in PHP 5.1.0)	Examples: UTC, GMT, Atlantic/Azores
I		(unsuported)	Whether or not the date is in daylights savings time	1 if Daylight Savings Time, 0 otherwise.
O		Difference to Greenwich time (GMT) in hours	Example: +0200
P		Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3)	Example: +02:00
T		Timezone setting of this machine	Examples: EST, MDT ...
Z		Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.	-43200 through 43200

Full Date/Time
c	ISO 8601 date (added in PHP 5)	2004-02-12T15:19:21+00:00
r	RFC 2822 formatted date	Example: Thu, 21 Dec 2000 16:01:07 +0200
U	Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)	See also time()


\* ---------------------------------------------------------------------- */
Date.prototype.format = function(format) {
	var returnStr = '';
	var replace = Date.replaceChars;
	for (var i = 0; i < format.length; i++) {
		var curChar = format.charAt(i);
		if (replace[curChar]) {
			returnStr += replace[curChar].call(this);
		} else {
			returnStr += curChar;
		}
	}
	return returnStr;
};
Date.replaceChars = {
	shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
	longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
	shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
	longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
	
	// Day
	d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); },
	D: function() { return Date.replaceChars.shortDays[this.getDay()]; },
	j: function() { return this.getDate(); },
	l: function() { return Date.replaceChars.longDays[this.getDay()]; },
	N: function() { return this.getDay() + 1; },
	S: function() { return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); },
	w: function() { return this.getDay(); },
	z: function() { return "Not Yet Supported"; },
	// Week
	W: function() { return "Not Yet Supported"; },
	// Month
	F: function() { return Date.replaceChars.longMonths[this.getMonth()]; },
	m: function() { return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1); },
	M: function() { return Date.replaceChars.shortMonths[this.getMonth()]; },
	n: function() { return this.getMonth() + 1; },
	t: function() { return "Not Yet Supported"; },
	// Year
	L: function() { return (((this.getFullYear()%4==0)&&(this.getFullYear()%100 != 0)) || (this.getFullYear()%400==0)) ? '1' : '0'; },
	o: function() { return "Not Supported"; },
	Y: function() { return this.getFullYear(); },
	y: function() { return ('' + this.getFullYear()).substr(2); },
	// Time
	a: function() { return this.getHours() < 12 ? 'am' : 'pm'; },
	A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; },
	B: function() { return "Not Yet Supported"; },
	g: function() { return this.getHours() % 12 || 12; },
	G: function() { return this.getHours(); },
	h: function() { return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); },
	H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); },
	i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); },
	s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); },
	// Timezone
	e: function() { return "Not Yet Supported"; },
	I: function() { return "Not Supported"; },
	O: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00'; },
	P: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + ':' + (Math.abs(this.getTimezoneOffset() % 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() % 60)); },
	T: function() { var m = this.getMonth(); this.setMonth(0); var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1'); this.setMonth(m); return result;},
	Z: function() { return -this.getTimezoneOffset() * 60; },
	// Full Date/Time
	c: function() { return this.format("Y-m-d") + "T" + this.format("H:i:sP"); },
	r: function() { return this.toString(); },
	U: function() { return this.getTime() / 1000; }
};
/* -----------------------END(sre_date)---------------------------------- */
/* ---------------------Begin(sre_auto_iframe)---------------------------------- *\
 * eMiliue v1.0 Copyright (c) 2010 Sreejon LLC 
 * Contact us at sreejon2006@msn.com
 * This copyright notice MUST stay intact for use.
 *
 * $Revision: 1.0 $

Dependency :	[Meant to work with Sreejon message structure ]
				No dependency

Description :	Routine to auto calculate the embedded Iframe of a page to avoid double scrollbar 

Usage:


DO NOT USE - NOT TESTED  -CROSS BROWSER

<!--
<script type="text/javascript">
// If the main document is located at www.example.com
// If the IFrame'd document is located at subdomain.example.com
// You can do this is both documents! ;-)
document.domain = 'sreejon.com';
</script>
-->


<iframe width="100%" height="500"
    id="myiframe" name="myiframe"
    src="http://www.sreejon.com/bye.html"
    onload="sre_auto_iframe.resize('myiframe',domain)"
    scrolling="no"
    style="width:100%;height:500px;border:1px dotted #BEBEBE;">
Sorry, your browser doesnt seem to support IFrames!
</iframe>			

\* ---------------------------------------------------------------------- */

var sre_auto_iframe = {
	// Storage for known IFrames.
	iframes: {},
	// Here we save any previously installed onresize handler.
	oldresize: null,
	// Flag that tell us if we have already installed our onresize handler.
	ready: false,
	// The document dimensions last time onresize was executed.
	dim: [-1,-1],
	// Timer ID used to defer the actual resize action.
	timerID: 0,
	// Obtain the dimensions (width,height) of the given document.
	getDim: function(d) {
		var w=200, h=200, scr_h, off_h;

		if( d.height ) { return [d.width,d.height]; }
		with( d.body ) {
			if( scrollHeight ) { h=scr_h=scrollHeight; w=scrollWidth; }
			if( offsetHeight ) { h=off_h=offsetHeight; w=offsetWidth; }
			if( scr_h && off_h ) h=Math.max(scr_h, off_h);
		}

		return [w,h];
	},
	// This is our window.onresize handler.
	onresize: function() {
		// Invoke any previously installed onresize handler.
		if( typeof this.oldresize == 'function' ) { this.oldresize(); }
		// Check if the document dimensions really changed.
		var dim = this.getDim(document);

		if( this.dim[0] == dim[0] && this.dim[1] == dim[1] ) return;
		// Defer the resize action to prevent endless loop in quirksmode.
		if( this.timerID ) return;
		this.timerID = setTimeout('sre_auto_iframe.deferred_resize();', 10);
	},
	// This is where the actual IFrame resize is invoked.
	deferred_resize: function() {
		// Walk the list of known IFrames to see if they need to be resized.
		for( var id in this.iframes ) this.resize(id);
		// Store resulting document dimensions.
		this.dim = this.getDim(document);
		// Clear the timer flag.
		this.timerID = 0;
	},
	// This is invoked when the IFrame is loaded or when the main window is resized.
	resize: function(id,domn,dv) {
		// Browser compatibility check.
		if( !window.frames || !window.frames[id] || !document.getElementById || !document.body )
			return;
		// Get references to the IFrame window and layer.
		var iframe = window.frames[id];
		var div = document.getElementById(id);
		if(domn) this.changeDomain(domn);
		if( !div ) return;
		// Save the IFrame id for later use in our onresize handler.
		if( !this.iframes[id] ) {
			this.iframes[id] = true;
		}
		// Should we inject our onresize event handler?
		if( !this.ready ) {
			this.ready = true;
			this.oldresize = window.onresize;
			window.onresize = new Function('sre_auto_iframe.onresize();');
		}
		// This appears to be necessary in MSIE to compute the height
		// when the IFrame'd document is in quirksmode.
		// OTOH, it doesn't seem to break anything in standards mode, so...
	//	if( document.all ) div.style.height = '0px';
		// Resize the IFrame container.
	//	var dim = this.getDim(iframe.document);
	//	div.style.height = "auto"; 
	//	div.style.height = (dim[1]+30) + 'px';
	}
};

/* -----------------------END(sre_auto_iframe)---------------------------------- */



/* ---------------------Begin(sre_inherit)---------------------------------- *\
 * eMiliue v1.0 Copyright (c) 2010 Sreejon LLC 
 * Contact us at sreejon2006@msn.com
 * This copyright notice MUST stay intact for use.
 *
 * $Revision: 1.0 $

Dependency :	[Meant to work with Sreejon message structure ]
				No dependency

Description :	Routine to simulate inheritence in JS object 

Usage:
function Person(first, last) {
    this.first = first;
    this.last = last;
}
Person.prototype.toString = function() {
    return this.first + ' ' + this.last;
};


function Employee(first, last, id) {
    Employee.superclass.call(this, first, last);
    this.id = id;
}
sre_inherit.extend(Employee, Person);
Employee.prototype.toString = function() {
    return Employee.superproto.toString.call(this) + ': ' + this.id;
};


function Manager(first, last, id, department) {
    Manager.superclass.call(this, first, last, id);
    this.department = department;
}
sre_inherit.extend(Manager, Employee);
Manager.prototype.toString = function() {
    return Manager.superproto.toString.call(this) + ': ' + this.department;
};

\* ---------------------------------------------------------------------- */

var sre_inherit = {

extend: function (subclass, superclass) {
   function Dummy() {}
   Dummy.prototype = superclass.prototype;
   subclass.prototype = new Dummy();
   subclass.prototype.constructor = subclass;
   subclass.superclass = superclass;
   subclass.superproto = superclass.prototype;
}

};

/* -----------------------END(sre_inherit)---------------------------------- */

/* ---------------------Begin(sre_shadow)---------------------------------- *\
TEST ON ALL BROWSER BEFORE USE ---

Usage:

Call sre_shadow.MakeDropShadow() only ONCE in a page (preferably towards the end of the page).

After that any object with class name of "dropshadow" (like <span class="dropshadow" > ) will have a shaowdow created.
also works for pictures, text and other objects, but use it only when absolutely necessary.


\* ---------------------------------------------------------------------- */

var sre_shadow = {


MakeDropShadow: function () {

    var node = document;
    var tag = '*';
    var wantedClass = 'dropshadow';

    // Build a regular expression that will search specically for 'wantedClass'
    var pattern = new RegExp("(^|\\s)"+wantedClass+"(\\s|$)");

    // Scan through all tag elements in the document
    var scan_elem = node.getElementsByTagName(tag);
    for (i = 0; i < scan_elem.length; i++) {

      // If element has a class of 'wantedClass'
      if (pattern.test(scan_elem[i].className) ) {

        // Get the value from the element
        var text_value = scan_elem[i].innerHTML;

        // Create Shadow Children for this element
        this.CreateShadowChildren(scan_elem[i],text_value);
      }
    } // End for loop
  },
 CreateShadowChildren: function (shadow_element,shadow_value) {

  var top_pos = .5;
  var left_pos = .5;

  // Assign starting color (in Hex notation) for the Red, Green, and Blue
  // Components (when they all have the same value you will alwys get a gray color).
  // For lighter shadows start with a "lighter" color of 66, 77, 88 99, aa, bb, etc..
  var starting_color = '44';
  var cRed = parseInt(starting_color,'16');
  var cGreen = parseInt(starting_color,'16');
  var cBlue = parseInt(starting_color,'16');

  // Set the max number of shadow elements to create.
  // This should never be set larger than the Z-Index value of dropshadow class
  var max_shadows = 10; 

  // Calculate color increament based on range of gray colors (from starting_color to
  // the lighest gray color of #fefefe) and max number of shadows you want
  var color_inc =  parseInt(( parseInt('fe','16') - parseInt(starting_color,'16') ) / max_shadows,'10');

  for (j = 1; j <= max_shadows; j++) {

    // Build full color Hex string from it's individual RGB values
    var full_color_value = cRed.toString(16) + cGreen.toString(16) + cBlue.toString(16);

    // Create a Shadow DIV
    var shadow_div = document.createElement('div');

    //  Add the shadow_value to Shadow DIV
    shadow_div.innerHTML = shadow_value;

    // Style Shadow DIV
    shadow_div.style.width=shadow_element.offsetWidth + "px";
    shadow_div.style.color = '#' + full_color_value;
    shadow_div.style.borderColor = '#' + full_color_value;
    shadow_div.style.display = "block";
    shadow_div.style.position = "absolute";
    shadow_div.style.top = top_pos + "px";
    shadow_div.style.left = left_pos + "px";
    shadow_div.style.zIndex = (-1) * j;

    // Apppend Shadow DIV to shadow element
    shadow_element.appendChild(shadow_div);

    // Increment positons and shadows individual RGB color values
    top_pos += .5;
    left_pos += .5;
    cRed += color_inc;
    cGreen += color_inc;
    cBlue += color_inc;
  }

 }
};


/* -----------------------END(sre_shadow)---------------------------------- */




/* ---------------------Begin(sre_message)---------------------------------- *\
 * eMiliue v1.0 Copyright (c) 2010 Sreejon LLC 
 * Contact us at sreejon2006@msn.com
 * This copyright notice MUST stay intact for use.
 *
 * $Revision: 1.0 $

Dependency :	[Meant to work with Sreejon message structure ]
				None

Description :	All core messaging (PHP and JS )functions that are used everywhere in the system 

\* ---------------------------------------------------------------------- */

/*
	var PageName ='',
	var SREEngSet="0";
	SREKillPage="../../../Bye.html";
	SREKillPageShort="Bye.html";

	SREStartPage="../../../DEVindex.html";
	SREStartPageShort="DEVindex.html";

	var SRESelectedPageMsg="";
	var SREDomain="";

	var SRESelectedAction="bizduniya.sre";
	var ParentCall ="";
	var SREConfirm = "Your current session will be released. Thanks !!!";
	var SREtimes = 0;
	var SREHeaderType="";
	var SREInternal = "interna.html"
*/

function setTabSequence(id) {
	SRETabIndxCnt = parseInt(SRETabIndxCnt) + parseInt(1);
	v = $(id);
	//if (sre_core.isMSIE()){
	//	if(v) v.setAttribute("tabIndex", SRETabIndxCnt);
	//} else {
		if(v) v.setAttribute("tabindex" , SRETabIndxCnt);
	//}
}
/*
function disableEnterKey(e)
{
alert(event);
alert("gfgfgf");
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key == 13)
          return false;
     else
          return true;
}
*/
/*
function Test(){
	alert("test");
}
*/
var sre_message = {

/* ---------------------------------------------------------------------- *\
  Function    : sreForm(cont,formname)
  Description : Creates hidden Form for post
  Usage       : sre_message.sreForm(cont) [the div 'cont has to exist']
  Arguments   : cont	- The div where the hidden form will be created.
				formname - name of form - SRE_ACTIONFORM is default
  Return      : None. 
\* ---------------------------------------------------------------------- */
/*onkeypress="javascript:noSubmitOnEnter(event)"*/
sreForm: function (cont,formname){
	var html='';
	if(!formname) formname = "SRE_ACTIONFORM";
	var v = document.getElementById(cont);
	html +='<table border="0"  cellpadding="0" cellspacing="0" <tr ><td >';
	html +='<form id="'+formname+'" name="'+formname+'" ';
	html +=' method="post" action=""';
	html +='><input type="text" size="1" style="visibility:hidden;" name="SRE_REQUEST" value="" ></input>';
//	html +='<input id="sre_submit" type="submit" style="visibility:hidden;" name="SRE_SUBMIT" value="Send" onclick="" ></input>';
	html +='</form>';
	html +='</td></tr></table>';
	//alert(html);
	v.innerHTML=html;
},
/* ---------------------------------------------------------------------- *\
  Function    : sreBuildSREMsg(msg) [internal use] - Sreejon engine submission only (not for PHP)
  Description : Build an internal Sreejon SOAP type message for POST submission
  Usage       : sre_message.sreBuildSREMsg(msg) 
  Arguments   : msg	- the message that carries parameters in xml format.
  Return      : Structured message for submission. 
\* ---------------------------------------------------------------------- */
sreBuildSREMsg: function (msg){
	var convert ='';done = 0;word = new Array();
	convert +='<SOAP-ENV:Envelop>';
	convert +='<SOAP-ENV:Body>';
	convert +='<sre_srever>'+SRESrever+'</sre_srever>';
	if(SRESelectedPage != ""){
		convert +='<sre_currentpage>'+SRESelectedPage+'</sre_currentpage>';
	}
	convert +=msg;
	if((SRESession != '') && (SRESession != undefined)) {
		for(j=0; j < SRESession.length && done == 0; j++)	{
			if(SRESession.slice(j,j+1)=='<') 		{
				word = SRESession.slice(0,j);
				done = 1;
			}
		}
		convert +='<sre_session>';
		convert +=word;
		convert +='</sre_session>';
		convert +='<sre_locale>';
		convert +=SRELocale;
		convert +='</sre_locale>';
	}
	convert +='</SOAP-ENV:Body>';
	convert +='</SOAP-ENV:Envelop>';
	return convert;
},
/* ---------------------------------------------------------------------- *\
  Function    : sreBuildPHPMsg(msg) [internal use] - Sreejon PHP submission only (not for SRE Engine)
  Description : Build an internal Sreejon SOAP type message for POST submission
  Usage       : sre_message.sreBuildPHPMsg(msg) 
  Arguments   : msg	- the message that carries parameters in xml format.
  Return      : Structured message for submission. 
\* ---------------------------------------------------------------------- */
sreBuildPHPMsg: function (msg){
	var convert ='';done = 0;word = new Array();
	convert +='<srephp>';
	convert +=msg;
	
	if((SRESession != '') && (SRESession != 'undefined')) {
		for(j=0; j < SRESession.length && done == 0; j++)	{
			if(SRESession.slice(j,j+1)=='<') 		{
				word = SRESession.slice(0,j);
				done = 1;
			}
		}
		if(done == 0) {
			word = SRESession;
		} 
		convert +='<sre_session>';
		convert +=word;
		convert +='</sre_session>';
		convert +='<sre_errorstr>';
		convert += SREErrorString;
		convert +='</sre_errorstr>';
		convert +='<sre_locale>';
		convert +=SRELocale;
		convert +='</sre_locale>';
		convert +='<sre_srever>'+SRESrever+'</sre_srever>';

		if(SRESelectedPage != ""){
			convert +='<sre_currentpage>'+SRESelectedPage+'</sre_currentpage>';
		}
	}
	convert +='</srephp>';

	return convert;
},
/* ---------------------------------------------------------------------- *\
  Function    : sreBuildAction(msg,action) [internal use] 
  Description : Build the action segment of the message for Sreejon SOAP type message for POST submission
  Usage       : sre_message.sreBuildAction(msg,action,formname) 
  Arguments   : msg	   - the message that carries parameters in xml format.
				action - the action url for submission
				flag   - [P: PHP S: SRE]
				parent - If the child frame is bouncing the message thru the Parent - the window parent (optional)
				encryyn- Encrypt message or not Default is 'N'  
  Return      : Structured message 
\* ---------------------------------------------------------------------- */

sreBuildAction: function (msg,action,flag,parent,encryyn,formname){
	var convert ='';
	if(!formname) formname = "SRE_ACTIONFORM";
	if(flag == 'P') {
		convert = this.sreBuildPHPMsg(msg);
	} else if (flag == 'S') {
		convert = this.sreBuildSREMsg(msg);
	}
	if( encryyn =='Y'){
		convert = this.encryptMessage(convert);
	}
	if((action != undefined) && (convert !='') ){
		if(parent) {
			parent.document.forms[formname].action = action;
			parent.document.forms[formname].elements["SRE_REQUEST"].value= convert;
		} else {
			if(document.forms[formname]){
				document.forms[formname].action = action;
				document.forms[formname].elements["SRE_REQUEST"].value= convert;
			}
		}
	} 
	return convert;
},
/* ---------------------------------------------------------------------- *\
  Function    : encryptMessage(str) [internal use]  ***** NOT IMPLEMENTED YET ****USE PHP MD5 SYNC call 
  Description : Build the encrypted string from the message for POST submission
  Usage       : sre_message.encryptMessage(str) 
  Arguments   : str	   - the message string that needs encrypting.
  Return      : encrypted string 
\* ---------------------------------------------------------------------- */

encryptMessage: function (str) {
	return str;
}

};


function stripslashes (str) {
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ates Goral (http://magnetiq.com)
    // +      fixed by: Mick@el
    // +   improved by: marrtins
    // +   bugfixed by: Onno Marsman
    // +   improved by: rezna
    // +   input by: Rick Waldron
    // +   reimplemented by: Brett Zamir (http://brett-zamir.me)
    // +   input by: Brant Messenger (http://www.brantmessenger.com/)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: stripslashes('Kevin\'s code');
    // *     returns 1: "Kevin's code"
    // *     example 2: stripslashes('Kevin\\\'s code');
    // *     returns 2: "Kevin\'s code"
    return (str + '').replace(/\\(.?)/g, function (s, n1) {
        switch (n1) {
        case '\\':
            return '\\';
        case '0':
            return '\u0000';
        case '':
            return '';
        default:
            return n1;
        }
    });
}
function addslashes (str) {
    // Escapes single quote, double quotes and backslash characters in a string with backslashes  
    // 
    // version: 1109.2015
    // discuss at: http://phpjs.org/functions/addslashes
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ates Goral (http://magnetiq.com)
    // +   improved by: marrtins
    // +   improved by: Nate
    // +   improved by: Onno Marsman
    // +   input by: Denny Wardhana
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   improved by: Oskar Larsson Högfeldt (http://oskar-lh.name/)
    // *     example 1: addslashes("kevin's birthday");
    // *     returns 1: 'kevin\'s birthday'
    return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
}


function sreSubmit(msg,action,formname){
	if(!formname) formname = "SRE_ACTIONFORM";
	sre_message.sreBuildAction(msg,action,'S') ;
	document.forms[formname].elements["SRE_SUBMIT"].click();
}
function sreAsyncSubmit(msg,action,funcname,asyncyn,id,procYN){
		if(procYN =='Y') {
				if($("sre_proc_txt")){
					$("sre_proc_txt").style.visibility = "visible";
				}
				if($("sre_proc_img")){
					$("sre_proc_img").style.visibility = "visible";
				}
		}
	var convert ='';
	convert = sre_message.sreBuildAction(msg,action,'S') ;
	sre_ajax.asyncPost(convert,action,funcname,asyncyn,id,procYN);
}
function sreContinue(){ /*dummy function to be overridden in page js file. */
	/***** DO NOT REMOVE *********/


}

function noSubmitOnEnter(e) { // not needed. already implemented in body element
   var ENTER_KEY = 13; var code = "";
   if (window.event) {// IE
		code = window.event.keyCode;
   } else if (e.which) {// Netscape/Firefox/Opera
        code = e.which;
   }
   if (code == ENTER_KEY) {
        return false;
   }
}
function removeFocus(){ //not used
	//if(document.all)
	alert(document.links);
	for(var i in document.links)
	document.links[i].onfocus = document.links[i].blur;
}
function srePHPSubmit(msg,action,formname){
	SREActionFocus=''; 
	//SREErrorString='';
	clearError();

	if(!formname) formname = "SRE_ACTIONFORM";
	sre_message.sreBuildAction(msg,action,'P') ;
	s= $("SRE_ACTIONFORM");
	s.submit();
//	document.forms[formname].elements["SRE_SUBMIT"].click();
}
function srePHPAsyncSubmit(msg,action,funcname,asyncyn,id,procYN){
	SREErrorString='';
	//clearError(); /* other asyn can reset error before user can see it. be careful */
		if(procYN =='Y') {
				err = document.getElementById("SRError");
				if(err) err.innerHTML=''; //clear out any message
				if($("sre_proc_txt")){
					$("sre_proc_txt").style.visibility = "visible";
				}
				if($("sre_proc_img")){
					$("sre_proc_img").style.visibility = "visible";
				}
		}
	var convert ='';
	convert = sre_message.sreBuildAction(msg,action,'P') ;
	//alert(action);
	sre_ajax.asyncPost(convert,action,funcname,asyncyn,id,procYN);
}

function srePHPChildSubmit(msg,action,parent,formname){
	if(!formname) formname = "SRE_ACTIONFORM";
	sre_message.sreBuildAction(msg,action,'P',parent) ;
	parent.document.forms[formname].elements["SRE_SUBMIT"].click();
}
function sreAsyncChildPHPSubmit(msg,action,funcname,asyncyn,parent,id){ // not tested
	var convert ='';
	convert = sre_message.sreBuildAction(msg,action,'P',parent) ;
	sre_ajax.asyncPost(convert,action,funcname,asyncyn,id);
}
/*
	   var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
						     */
function includeCSS(path) {
	var done=0;
	var script = document.createElement("link");
	script.setAttribute( "rel","stylesheet");
	script.setAttribute("type", "text/css");
	script.setAttribute( "href",path);
	
	var heads = document.getElementsByTagName("head");
	for(var i = 0;i < heads.length; i++) { 
		for(var j = 0;j < heads[i].childNodes.length; j++) { 
			if( heads[i].childNodes[j].src == path) { 
				done = 1; break;       
			}
		}
		if( done == 0){
			heads[i].appendChild(script);
		}
	}
}	
function includeJS(path) {
	var done=0;
	var script = document.createElement("script");;
	script.setAttribute("type", "text/javascript");
	script.setAttribute( "src",path);
	var heads = document.getElementsByTagName("head");
	for(var i = 0;i < heads.length; i++) { 
		for(var j = 0;j < heads[i].childNodes.length; j++) { 
			if( heads[i].childNodes[j].src == path) { 
				done = 1; break;       
			}
		}
		if( done == 0){
			heads[i].appendChild(script);
		}
	}
}
function sreConvertPxToInt(cssPxValueText) {
    var validChars = "0123456789.";
   // len =cssPxValueText.length;
   // (cssPxValueText[len]);
    var convertedValue = 0;
    for (i = 0; i < cssPxValueText.length; i++) {
	if (validChars.indexOf(cssPxValueText.charAt(i)) == -1) {
	    if (i > 0) {
		convertedValue = parseInt(cssPxValueText.substring(0, i));
		return convertedValue;
	    }
	}
    }
    return convertedValue;
}
function sreCheckCookie() {
 /* check for a cookie */
 //document.cookie = "";
  if (document.cookie == "") {
    /* if a cookie is not found - alert user -
     change cookieexists field value to false */
    //alert("COOKIES need to be enabled!");
    setDictError("102");
    /* If the user has Cookies disabled an alert will let him know 
        that cookies need to be enabled to log on.*/ 
    document.forms["sre_cc"].elements["cookieexists"].value ="false"
   // return 0;
  } else {
   /* this sets the value to true and nothing else will happen,
       the user will be able to log on*/
    document.forms["sre_cc"].elements["cookieexists"].value ="true"
   // return 1;
  }
}
//function sreNewCookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure ){
function sreNewCookie ( name, value, days, path, domain, secure ){	
  var cookie_string = name + "=" + escape ( value );
  /*
  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }
 */	 
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    cookie_string += "; expires=" + date.toGMTString();
  } 
  if ( path )
        cookie_string += "; path=" + escape ( path );
  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  if ( secure )
        cookie_string += "; secure";

  document.cookie = cookie_string;
  alert(cookie_string);	
}
/*
function sreNewCookie(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=/";
   document.cookie = name+"="+value+expires+"; path=/";
}
			*/
function readCookie(name) {
  var nameSG = name + "=";
  var nuller = '';
  if (document.cookie.indexOf(nameSG) == -1)
  return nuller;
  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(nameSG) == 0) return c.substring(nameSG.length,c.length);
  }
  return null;
}

function sreEraseCookie(name) {
  sreNewCookie(name,"",-1);
}
function srewindowClosed(){
	alert("closing");
}
function sredisableBackButton(){
	window.history.forward();
}

function goIndex(){
	SREKillPage=SRESrever + '/' + SREStartPageShort;
	document.location = SREKillPage;
}
function goIndexInt(){
	SREKillPage=SRESrever + '/' + "internal.html";
	document.location = SREKillPage;
}
function goSignOut()
{
	SREKillPage=SRESrever +'/' + SREStartPageShort;
	document.location = SREKillPage;
}

function goPortal(){
Page='';
	var Page ='';
	Page += '<thirdparty>'+SREThirdparty+'</thirdparty>';
	Page += '<language>'+SRELanguage+'</language>';
	Page += '<country>'+SRECountryIP+'</country>';
	Page += '<mode>'+SREMode+'</mode>';
	Page += '<premid>'+SREPremId+'</premid>';	
//	Page += '<canrepresent></canrepresent>';
//	Page += '<vertical>'+SREVertical+'</vertical>';	
	Page += '<theme>'+SRETheme+'</theme>';
	Page += '<menutype>'+SREMenuType+'</menutype>';
	Page += '<msgwait>'+SREMsgwaiting+'</msgwait>';
	Page += '<clockset>'+SREClockset+'</clockset>';
	Page += '<signedlan>'+SRELanguage+'</signedlan>';
	Page += '<signedserver>'+SREServeralias+'</signedserver>';
	Page += '<signedusertype>'+SREUsertype+'</signedusertype>';	
	Page += '<securedmode>'+SRESecuredMode+'</securedmode>';
	Page += '<longparam>'+SRELongParam+'</longparam>';
	Page += '<lineofbiz></lineofbiz>';	
	Page += '<sre_session>'+SRESession+'</sre_session>';

	if(SRESecuredMode =='G'){ //guest
		fullname= SREContactname +' [ Guest of ' + SREFullname +']';
		Page += '<user>'+SREContact+'</user>';
		Page += '<mergeid>'+SREContact+'</mergeid>';
		Page += '<fullname>'+fullname+'</fullname>';
		Page += '<usertype>'+SREUsertype+'</usertype>';
		Page += '<serveralias>'+SREServeralias+'</serveralias>';
		Page += '<exclusive>'+SREUser+'</exclusive>';
		Page += '<exclusiverole>'+SREContactrole+'</exclusiverole>';
		Page += '<signed>'+SREContact+'</signed>';
		Page += '<signedname>'+fullname+'</signedname>';
		//SREExclusive = SREUser;
	} else if(SRESecuredMode =='E'){ //exclusive
		fullname= SREContactname +' [' + SREFullname +']';
		Page += '<user>'+SREContact+'</user>';
		Page += '<mergeid>'+SREContact+'</mergeid>';
		Page += '<fullname>'+fullname+'</fullname>';
		Page += '<usertype>'+SREUsertype+'</usertype>';
		Page += '<serveralias>'+SREServeralias+'</serveralias>';
		Page += '<exclusive>'+SREUser+'</exclusive>';
		Page += '<exclusiverole>'+SREContactrole+'</exclusiverole>';
		Page += '<signed>'+SREContact+'</signed>';
		Page += '<signedname>'+fullname+'</signedname>';			
	} else if(SRESecuredMode ==''){ //general
		Page += '<user>'+SREUser+'</user>';
		Page += '<mergeid>'+SREMergeId+'</mergeid>';
		Page += '<fullname>'+SREFullname+'</fullname>';
		Page += '<usertype>'+SREUsertype+'</usertype>';
		Page += '<serveralias>'+SREServeralias+'</serveralias>';
		Page += '<exclusive></exclusive>';
		Page += '<exclusiverole>SELF</exclusiverole>';
		Page += '<signed>'+SREUser+'</signed>';
		Page += '<signedname>'+SREMode+'</signedname>';			
	}
	    redirecturl= "/srp/srp_usr/sre_soc.srp";
	//var redirecturl = '/srp/srp_usr/portal.srp';
	srePHPSubmit(Page,redirecturl);
}

/* ********* TO DO -- USE php async mail (NO MAILTO ) *******

function sendPHPLink() {
	var lnkhtml='';
	lnkhtml += 'mailto:?Subject=Link from '+SRESrever;
	if(SRESelectedPageMsg !=''){
	+' (';
		lnkhtml += SRESelectedPageMsg;
		lnkhtml += ')';
	}
	lnkhtml += '&Body=';
	lnkhtml += SRESrever;
	lnkhtml += '/srp/';
	lnkhtml += SREDomain;
	lnkhtml +=SRESelectedPage;
	lnkhtml += '.srp';
	document.location = lnkhtml;
}
*****************************************************************/
function SendSyncAlert(chan,chans){
	words = new Array();
		sre_core.breakWords(chans,words);
		for (i = 0 ; i < words.length -1; i++) {
			Page='';	 

			if(words[i] !='') { //some times the last one 
				Page +='<channel>'+chan+'</channel>';
				var redirecturl =''; redirecturl +='http://';
				redirecturl += words[i];
				redirecturl += '.';
				redirecturl += SREHost;
				redirecturl +='/srp/srp_system/sub/sub_sync_download.srp';
				srePHPSubmit(Page,redirecturl);
			}
		}
}
function SendSyncAlertReturned(response,obj,id){
	alert(response);
}
/* -----------------------END(sre_message)---------------------------------- */
function sre_setJs(path){
	var done=0;
	var script1 = document.createElement("script");
	script1.setAttribute("type", "text/javascript");
	script1.setAttribute( "src",path);
	var heads = document.getElementsByTagName("head");
	for(var i = 0;i < heads.length; i++) {
		for(var j = 0;j < heads[i].childNodes.length; j++) {
			if( heads[i].childNodes[j].src == path) {
				heads[i].removeChild(heads[i].childNodes[j]);
				done = 1;
				break;
			}
		}
		if( done == 0){
			heads[i].appendChild(script1);
			
		}
	}
}


function sre_win_refresh(){
window.location.reload(true);	
}
   sre_Sleep = function ZZzzzZZzzzzzzZZZz(naptime){
        naptime = naptime * 1000;
        var sleeping = true;
        var now = new Date();
        var alarm;
        var startingMSeconds = now.getTime();
      //  alert("starting nap at timestamp: " + startingMSeconds + "\nWill sleep for: " + naptime + " ms");
        while(sleeping){
            alarm = new Date();
            alarmMSeconds = alarm.getTime();
            if(alarmMSeconds - startingMSeconds > naptime){ sleeping = false; }
        }        
        //alert("Wakeup!");
   }
   
 function switch_style ()
{
    var head=document.getElementsByTagName('head')[0];

    for (i = 0, link_tag = document.getElementsByTagName("link"); i < link_tag.length ; i++ ) 
    {
            if ((link_tag[i].rel.indexOf( "stylesheet" ) != -1) && link_tag[i].title) 
            {
                if (link_tag[i].title == "normal")
                {
                    head.removeChild(link_tag[i]);          
                }
            }
    }
    var cssNode = document.createElement('link');
    cssNode.type = 'text/css';
    cssNode.rel = 'stylesheet';
    cssNode.href = '/templates/rhuk_milkyway/css/template_contrast.css';
    head.appendChild(cssNode);
    set_cookie( style_cookie_name, "contrast", style_cookie_duration ); 
}

/* Event Functions */

// Add an event to the obj given
// event_name refers to the event trigger, without the "on", like click or mouseover
// func_name refers to the function callback when event is triggered
function addEvent(obj,event_name,func_name){
	if (obj.attachEvent){
		obj.attachEvent("on"+event_name, func_name);
	}else if(obj.addEventListener){
		obj.addEventListener(event_name,func_name,true);
	}else{
		obj["on"+event_name] = func_name;
	}
}

// Removes an event from the object
function removeEvent(obj,event_name,func_name){
	if (obj.detachEvent){
		obj.detachEvent("on"+event_name,func_name);
	}else if(obj.removeEventListener){
		obj.removeEventListener(event_name,func_name,true);
	}else{
		obj["on"+event_name] = null;
	}
}

// Stop an event from bubbling up the event DOM
function stopEvent(evt){
	evt || window.event;
	if (evt.stopPropagation){
		evt.stopPropagation();
		evt.preventDefault();
	}else if(typeof evt.cancelBubble != "undefined"){
		evt.cancelBubble = true;
		evt.returnValue = false;
	}
	return false;
}

// Get the obj that starts the event
function getElement(evt){
	if (window.event){
		return window.event.srcElement;
	}else{
		return evt.currentTarget;
	}
}
// Get the obj that triggers off the event
function getTargetElement(evt){
	if (window.event){
		return window.event.srcElement;
	}else{
		return evt.target;
	}
}
// For IE only, stops the obj from being selected
function stopSelect(obj){
	if (typeof obj.onselectstart != 'undefined'){
		addEvent(obj,"selectstart",function(){ return false;});
	}
}

/*    Caret Functions     */

// Get the end position of the caret in the object. Note that the obj needs to be in focus first
function getCaretEnd(obj){
	if(typeof obj.selectionEnd != "undefined"){
		return obj.selectionEnd;
	}else if(document.selection&&document.selection.createRange){
		var M=document.selection.createRange();
		try{
			var Lp = M.duplicate();
			Lp.moveToElementText(obj);
		}catch(e){
			var Lp=obj.createTextRange();
		}
		Lp.setEndPoint("EndToEnd",M);
		var rb=Lp.text.length;
		if(rb>obj.value.length){
			return -1;
		}
		return rb;
	}
}
// Get the start position of the caret in the object
function getCaretStart(obj){
	if(typeof obj.selectionStart != "undefined"){
		return obj.selectionStart;
	}else if(document.selection&&document.selection.createRange){
		var M=document.selection.createRange();
		try{
			var Lp = M.duplicate();
			Lp.moveToElementText(obj);
		}catch(e){
			var Lp=obj.createTextRange();
		}
		Lp.setEndPoint("EndToStart",M);
		var rb=Lp.text.length;
		if(rb>obj.value.length){
			return -1;
		}
		return rb;
	}
}
// sets the caret position to l in the object
function setCaret(obj,l){
	obj.focus();
	if (obj.setSelectionRange){
		obj.setSelectionRange(l,l);
	}else if(obj.createTextRange){
		m = obj.createTextRange();		
		m.moveStart('character',l);
		m.collapse();
		m.select();
	}
}
// sets the caret selection from s to e in the object
function setSelection(obj,s,e){
	obj.focus();
	if (obj.setSelectionRange){
		obj.setSelectionRange(s,e);
	}else if(obj.createTextRange){
		m = obj.createTextRange();		
		m.moveStart('character',s);
		m.moveEnd('character',e);
		m.select();
	}
}

/*    Escape function   */
String.prototype.addslashes = function(){
	return this.replace(/(["\\\.\|\[\]\^\*\+\?\$\(\)])/g, '\\$1');
}
String.prototype.trim = function () {
    return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};
/* --- Escape --- */

/* Offset position from top of the screen */
function curTop(obj){
	toreturn = 0;
	while(obj){
		toreturn += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return toreturn;
}
function curLeft(obj){
	toreturn = 0;
	while(obj){
		toreturn += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return toreturn;
}
/* ------ End of Offset function ------- */

/* Types Function */

// is a given input a number?
function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}

/* Object Functions */

function replaceHTML(obj,text){
	while(el = obj.childNodes[0]){
		obj.removeChild(el);
	};
	obj.appendChild(document.createTextNode(text));
}
