var base_url = 'http://pwsdev.com/2008/makesellbuy2/';
var success_img = '<img src="' + base_url + 'images/check.jpg" />';
var error_img = '<img src="' + base_url + 'images/cross.jpg" />';
var submit_registration  = false;
var registration_form;
function check_alias_availability(alias){
	if(alias != ''){
		alias = alias.replace('#','!');
		alias = alias.replace('&','!');
		$.ajax({
			url: base_url + "myaccount/check_alias/"+alias,
			cache: false,
			dataType: 'html',
			success: function(html){
				var errorMsg = "";
				if(html.indexOf('is available') != -1){
					if(submit_registration == true){
						form = registration_form;
						var has_error = false;
						if(form.elements['country'].options[form.elements['country'].selectedIndex].value == ''){
							errorMsg += '<div style="color:#FFF; float: left;">All fields marked with ( * ) are required!</div>';
							has_error = true;
						}else{
							if(form.elements['companyname'].value == '' && form.elements['businesstype'][1].checked == true){
								errorMsg += '<div style="color:#FFF">All fields marked with ( * ) are required!</div>';
								has_error = true;
							}else{
								if(is_email_format(form.elements['email'].value) == false){
									errorMsg += '<div style="color:#FFF">You have entered an invalid email.</div>';
									has_error = true;
								}
								
								var email1 = form.elements['email'].value;
								var email2 = form.elements['email2'].value;
								var split1 = email1.split( "@" );
								var split2 = email2.split( "@" );
								var email_com = "";
								
								if( split1[1] == "googlemail.com" ){
									email1_com = split1[0] + "@gmail.com";
								}else{
									email1_com = email1;
								}
								if( split2[1] == "googlemail.com" ){
									email2_com = split2[0] + "@gmail.com";
								}else{
									email2_com = email2;
								}
								
								if( email1_com != email2_com ){
									errorMsg += '<div style="color:#FFF">Email doesn\'t match the confirmation email.</div>';
									has_error = true;
								}
								if(form.elements['password'].value !=  form.elements['password2'].value){
									errorMsg += '<div style="color:#FFF">Password doesn\'t match the confirmation password.</div>';
									has_error = true;
								}
								if(form.elements['useragreement'].checked == false){
									//errorMsg += '<div style="color:#FFF">You must agree to the User Agreement and Privacy Policy</div>';
									errorMsg += '<div style="color:#FFF">All fields marked with ( * ) are required!</div>';
									has_error = true;
								}
							}
						}
						if(has_error == true){
							document.getElementById( "password" ).value = "";
							document.getElementById( "password2" ).value = "";
							$("#displayMsg").html( "<div style='float: left;'>" + error_img +"</div><div style='float: left; padding-top: 4px;'>" + errorMsg + "</div><div style='clear: both;'></div>" );
							$("#displayMsg").removeAttr("class");
							$("#displayMsg").addClass("errorMsg");
							$("#displayMsg").show();
							changeCaptcha();
							window.scroll(0,0);
							return false;
						}else{
							form.submit();
						}
					}else{
						$("#aliasMsg").removeAttr("class");
						$("#aliasMsg").addClass('successMsg');
						$("#aliasMsg").html( "<div style='float: left;'>"+ success_img +"</div>" + html );
						$("#aliasMsg").show();
					}
					submit_registration = false;
				}else{
					document.getElementById( "password" ).value = "";
					document.getElementById( "password2" ).value = "";
					$("#aliasMsg").removeAttr("class");
					$("#aliasMsg").addClass('errorMsg');
					$("#aliasMsg").html( "<div style='float: left;'>"+ error_img +"</div>" + html);
					$("#aliasMsg").show();
					changeCaptcha();
					submit_registration = false;
				}
			}
		});
	}

}

function check_register_form(form){
	
	var errorMsg = '';
	var req_fields = new Array('alias','email','email2','password','password2','firstname','lastname','address1','city','state','postalcode','contactno','captcha');
	
	var has_empty = false;
	for(i = 0; i < req_fields.length; i++){
		if(form.elements[req_fields[i]].value == ''){
			has_empty = true;
		}
	}
	if(has_empty == false){
		submit_registration = true;
		registration_form = form;
		check_alias_availability(form.elements['alias'].value);
		return false;
	}else{
		document.getElementById( "password" ).value = "";
		document.getElementById( "password2" ).value = "";
		errorMsg = '<div style="float: left;">' + error_img + '</div><div style="color:#FFF; float: left; padding-top: 4px;">All fields marked with ( * ) are required!</div><div style="clear: both;"></div>';
		$("#displayMsg").html(errorMsg);
		$("#displayMsg").removeAttr("class");
		$("#displayMsg").addClass("errorMsg");
		$("#displayMsg").show();
		changeCaptcha();
		window.scroll(0,0);
		return false;
	}
	$("#displayMsg").hide();
	form.submit();
	
}

	function is_email_format(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
			return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
			return false
		 }
		 if (str.indexOf(" ")!=-1){
			return false
		 }
		 return true					
	}
var base = "http://pwsdev.com/2008/makesellbuy/";
var suffix = "";

function $$(id)
{
    return document.getElementById(id);
}


/**
 * function: redirect(url)
 * parameter: string url
 *
 * description: this will redirect the page to the url specified
 **/
function redirect(url) 
{
    window.location=url;
}


/**
 * function: mytrim(str)
 * parameter: string str
 *
 * description: this will trim a string format
 **/
function mytrim(str)
{
    if(!str || typeof str != 'string')
        return null;

    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}


/**
 * function: formatMoney()
 * parameter: string num
 * 
 * description: this will format the string to money format
 **/
function formatMoney(num) 
{
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	   num = "0";
	   
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	
	if(cents<10)
	   cents = "0" + cents;
	   
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	   num = num.substring(0,num.length-(4*i+3)) + num.substring(num.length-(4*i+3));
	   
	return (((sign)?'':'-') + '' + num + '.' + cents);
}


/**
 * function: displayError()
 * parameter: string err
 * 
 * description: to display the error message instead of alert
 **/
function displayError(err) 
{
	document.getElementById("bigcontainer").className="errorbox";
	document.getElementById("bigcontainer").style.display="block";
	document.getElementById("msgcontainer").innerHTML= error_img + "<font color='red' style='12px;font-weight:boler;'>"+err+"</font>";
	
	setTimeout("clearError()",15000);
}


/**
 * function: displayInfo()
 * parameter: string msg
 * 
 * description: to display the user message info instead of alert
 **/
function displayInfo(msg)
{
	document.getElementById("bigcontainer").className="confirmbox";
	document.getElementById("bigcontainer").style.display="block";
	document.getElementById("msgcontainer").innerHTML="<font color='blue' style='12px;font-weight:boler;'>"+msg+"</font>";
	
	setTimeout("clearError()",15000);
}


/**
 * function: displayInfo()
 * parameter: string msg
 * 
 * description: to display the user message for successfully save/update
 **/
function displaySuccess(msg)
{
	document.getElementById("bigcontainer").className="notificationbox";
	document.getElementById("bigcontainer").style.display="block";
	document.getElementById("msgcontainer").innerHTML=success_img + "<font color='green' style='12px;font-weight:boler;'>"+msg+"</font>";
	
	setTimeout("clearError()",15000);
}


/**
 * function: clearError()
 * parameter: none
 * 
 * description: this will clear the msgbox
 **/
function clearError() 
{
	document.getElementById("bigcontainer").style.display="none";
}


/**
 * function: validateLength()
 * parameter:   string obj
 *              number min
 *              number max
 *              string name_display
 *              boolean required
 *      
 * description: this will validate the charater length
 **/
function validateLength(obj, min, max, name_display, required) 
{
	msg='';
	if (required==false && (document.getElementById(obj).value=='') ) 
		return msg;  // meaning, need not to check	
		
	if ( (document.getElementById(obj).value.length < min) || (document.getElementById(obj).value.length > max) ) {
		// invalid length
		msg = 'Valid entries for '+name_display+' are between '+min+' and '+max+' characters.';
	}

	return msg;
}


/**
 * function: setDefaulDate()
 * parameter:   string fld
 *              string default_value
 *      
 * description: this will set the default value of the date obj
 **/
function setDetfaultDate(fld, blank, default_date) 
{
	$(fld).value= trim($(fld).value);
	
	if ($(fld).value) {
		if (!isDate($(fld).value))
			$(fld).value=default_date;
	} else {
		if (!blank)
			$(fld).value=default_date;
		else
			$(fld).value="";
	}
}


/**
 * function: addCommas()
 * parameter:   string nStr
 *      
 * description: this will add comma to the string format
 **/
function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}


/**
 * function: encode()
 * parameter:   string Str
 *      
 * description: this will encode the unencoded string input
 **/
function encode(str) 
{
	var unencoded = str;
	return escape(unencoded);
}


/**
 * function: decode()
 * parameter:  string Str
 *      
 * description: this will decode the encoded string input
 **/
function decode(str) 
{
	var encoded = str;
	return unescape(encoded.replace(/\+/g,  " "));
}


/**
 * function: getFormElements()
 * parameter:  string obj (form id)
 *      
 * description: this will return all object under the form and its value as single string
 **/
function getFormElements(obj) 
{
  var poststr = "";
                
	for(i=0; i<$(obj).length; i++) {
		if (i==0)
			poststr = $(obj).elements[i].name + "=" + encode($(obj).elements[i].value);
		else
			poststr += "&" + $(obj).elements[i].name + "=" + encode($(obj).elements[i].value);
	}
	
  return poststr;
}


//Initialize combo box

/**
 * function: initializeCombo()
 * parameter:  string container (combo id)
 *      
 * description: this will Initialize combo box
 **/
function initializeCombo(container)
{
	var y=document.createElement('option');
	$(container).innerHTML = '';
	y.setAttribute('value','');
	y.text='------------------------------------';
	var x=$(container);
	//x.add(y,null); // IE only  }
	if (navigator.appName=="Microsoft Internet Explorer") {
		x.add(y); // IE only  
	} else {
		x.add(y,null);
	}
	return;
}



function html_entity_decode(str) 
{
	var ta=document.createElement("textarea");
	ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
	return ta.value;
}

function keyCtrlRestrict(e, validchars_code) {

	if (e.ctrlKey==1 || e.keyCode==45)
	{
	return false;
	}
		
	var strCheckOK = new Array();
	strCheckOK[0] = "0123456789"; // numbers only
	strCheckOK[1] = "0123456789."; // positive numbers only
	strCheckOK[2] = "0123456789.-"; // for float with negative
	strCheckOK[3] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "+ String.fromCharCode(241); // alpha only
	strCheckOK[4] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&(),:;.-'/\"\\ "+ String.fromCharCode(241); // alpha with basic esp char only
	strCheckOK[5] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "+ String.fromCharCode(241);	// alpha num only
	strCheckOK[6] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&,:;.-#/'\"\\ "+ String.fromCharCode(241);	// alpha num with basic esp char only
	strCheckOK[7] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_&,:;-./!@#$%^*()?'\"\\ "+ String.fromCharCode(241); // with special chars	
	strCheckOK[8] = "0123456789/"; // for dates
	strCheckOK[9] = "0123456789-/ "; // mobile phone
	strCheckOK[10] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789#*-/ "+ String.fromCharCode(241); // fax/telephone phone
	strCheckOK[11] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@."; // email address
	strCheckOK[12] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.- "; // name of a person
	strCheckOK[13] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"; // plate number
	strCheckOK[14] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";	//password
	strCheckOK[15] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz, "+ String.fromCharCode(241); // alpha only

	var key='', keychar='';

	key = getKeyCode(e);
	if (validchars_code==-1) {
		if (key>0) return false;
		else	   return true;
	}
	if (key == null) return true;

	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	validchars = strCheckOK[validchars_code];
	 
	validchars=validchars.toLowerCase();
	if (validchars.indexOf(keychar) != -1)
		return true;
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
		return true;

	return false;
 
 
}

function keyRestrict(e, validchars_code) {

	if (e.ctrlKey==1 || e.keyCode==45)
	{
	return false;
	}
		
	var strCheckOK = new Array();
	strCheckOK[0] = "0123456789"; // numbers only
	strCheckOK[1] = "0123456789."; // positive numbers only
	strCheckOK[2] = "0123456789.-"; // for float with negative
	strCheckOK[3] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "+ String.fromCharCode(241); // alpha only
	strCheckOK[4] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&(),:;.-'/\"\\ "+ String.fromCharCode(241); // alpha with basic esp char only
	strCheckOK[5] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "+ String.fromCharCode(241);	// alpha num only
	strCheckOK[6] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&,:;.-#/'\"\\ "+ String.fromCharCode(241);	// alpha num with basic esp char only
	strCheckOK[7] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_&,:;-./!@#$%^*()?'\"\\ "+ String.fromCharCode(241); // with special chars	
	strCheckOK[8] = "0123456789/"; // for dates
	strCheckOK[9] = "0123456789-()"; // mobile phone
	strCheckOK[10] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789#*-/ "+ String.fromCharCode(241); // fax/telephone phone
	strCheckOK[11] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@."; // email address
	strCheckOK[12] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.- "; // name of a person
	strCheckOK[13] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"; // plate number
	strCheckOK[14] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";	//password
	strCheckOK[15] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,- "+ String.fromCharCode(241); // alpha only
	strCheckOK[16] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz	? "+ String.fromCharCode(241); // question

	var key='', keychar='';

	key = getKeyCode(e);
	if (validchars_code==-1) {
		if (key>0) return false;
		else	   return true;
	}
	if (key == null) return true;

	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	validchars = strCheckOK[validchars_code];
	 
	validchars=validchars.toLowerCase();
	if (validchars.indexOf(keychar) != -1)
		return true;
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
		return true;

	return false;
 
 
}


function getKeyCode(e)
{
	 if (window.event)
		return window.event.keyCode;
	 else if (e)
		return e.which;
	 else
		return null;
}

// Function for currency format
function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + cents);
}

//Status Loading Image

function displayLoading( id, height )
	{
		$$(id).innerHTML = "<table valign=middle align=center><td height='"+height+"'><img src='"+base+"images/images/ajax-loader.gif' /></td></table>";
	}


function atreplace( x )
	{	
		return x.replace(/@/, "-");		
	}

//******************************************************//
// @param1, whole string								//
// @param2, old char									//
// @param3, new char									//
//******************************************************//

function replaceCharacters( string, inChar, outChar ) {
  var newString = string.split(inChar);
  return newString.join(outChar);
}

function limitText(limitField, countdown, limitNum) {
	if (limitField.value.length > limitNum) 
		limitField.value = mytrim(limitField.value.substring(0, limitNum));
	else
		$$(countdown).value = limitNum - limitField.value.length;
}

function limitWord( limitField, countdown, hidden, limitNum ){
	var fieldValue = limitField.value;
	var r=0;
	//a  = fieldValue.replace( /\s/g,' ' );
	words_arr = new Array();
	ctr = 0;
	word = '';
	words_arr.push('');
	for(i = 0; i < fieldValue.length; i++){
		c = fieldValue.substr(i,1);
		if(c == ','){
			if(words_arr.length >= limitNum){
				newval = fieldValue.substr(0,i);
				limitField.value = newval;
				i = fieldValue.length;
			}
			ctr++;
		}else{
			words_arr[ctr] = words_arr[ctr] + c;
		}
		
	}
	$$(countdown).value = limitNum - words_arr.length;
	/*
	a = fieldValue;
	a = a.split( ',' );
	for (z=0; z<a.length; z++) {if (a[z].length > 0) r++; }
	if( r > limitNum ){
		var val = $$(hidden).value;
		limitField.value = mytrim(val)
	}else{
		$$(countdown).value = limitNum - r;
		$$(hidden).value = fieldValue;
	}
	*/
}

/*function cnt(w,x){
var y=w.value;
var r = 0;
a=y.replace(/\s/g,' ');
a=a.split(' ');
for (z=0; z<a.length; z++) {if (a[z].length > 0) r++;}
x.value=r;
} */

function initAJAX(){
 var xmlHttp2;
	try{	
		xmlHttp2=new XMLHttpRequest();
		return xmlHttp2;
	}
	catch (e){
		try{	
			xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
			return xmlHttp2;
		}
		catch (e){
			try{	
				xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
				return xmlHttp2;
			}
			catch (e){
				 alert("Your browser does not support AJAX!");
			return false;
			}
		}
	}
		
 }
 
function show(form){
	document.getElementById(form).style.display = 'block';
}
 
function hide(form){
	document.getElementById(form).style.display = 'none';
}

function stripslashes(str) 
{
    str = str.replace(/\\'/g,'\'');
    str = str.replace(/\\"/g,'"');
    str = str.replace(/\\\\/g,'\\');
    str = str.replace(/\\0/g,'\0');
    return str;
}

function get_html_translation_table(table, quote_style) {
    var entities = {}, histogram = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    useTable      = (table ? table.toUpperCase() : 'HTML_SPECIALCHARS');
    useQuoteStyle = (quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT');
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';
    
    // Map numbers to strings for compatibilty with PHP constants
    if (!isNaN(useTable)) {
        useTable = constMappingTable[useTable];
    }
    if (!isNaN(useQuoteStyle)) {
        useQuoteStyle = constMappingQuoteStyle[useQuoteStyle];
    }
 
    if (useTable == 'HTML_SPECIALCHARS') {
		// ascii decimals for better compatibility
        entities['38'] = '&amp;';
        if (useQuoteStyle != 'ENT_NOQUOTES') {
            entities['34'] = '&quot;';
        }
        if (useQuoteStyle == 'ENT_QUOTES') {
            entities['39'] = '&#039;';
        }
        entities['60'] = '&lt;';
        entities['62'] = '&gt;';
    } else if (useTable == 'HTML_ENTITIES') {
        // ascii decimals for better compatibility
		entities['38']  = '&amp;';
        if (useQuoteStyle != 'ENT_NOQUOTES') {
            entities['34'] = '&quot;';
        }
        if (useQuoteStyle == 'ENT_QUOTES') {
            entities['39'] = '&#039;';
        }
		entities['60']  = '&lt;';
		entities['62']  = '&gt;';
		entities['160'] = '&nbsp;';
		entities['161'] = '&iexcl;';
		entities['162'] = '&cent;';
		entities['163'] = '&pound;';
		entities['164'] = '&curren;';
		entities['165'] = '&yen;';
		entities['166'] = '&brvbar;';
		entities['167'] = '&sect;';
		entities['168'] = '&uml;';
		entities['169'] = '&copy;';
		entities['170'] = '&ordf;';
		entities['171'] = '&laquo;';
		entities['172'] = '&not;';
		entities['173'] = '&shy;';
		entities['174'] = '&reg;';
		entities['175'] = '&macr;';
		entities['176'] = '&deg;';
		entities['177'] = '&plusmn;';
		entities['178'] = '&sup2;';
		entities['179'] = '&sup3;';
		entities['180'] = '&acute;';
		entities['181'] = '&micro;';
		entities['182'] = '&para;';
		entities['183'] = '&middot;';
		entities['184'] = '&cedil;';
		entities['185'] = '&sup1;';
		entities['186'] = '&ordm;';
		entities['187'] = '&raquo;';
		entities['188'] = '&frac14;';
		entities['189'] = '&frac12;';
		entities['190'] = '&frac34;';
		entities['191'] = '&iquest;';
		entities['192'] = '&Agrave;';
		entities['193'] = '&Aacute;';
		entities['194'] = '&Acirc;';
		entities['195'] = '&Atilde;';
		entities['196'] = '&Auml;';
		entities['197'] = '&Aring;';
		entities['198'] = '&AElig;';
		entities['199'] = '&Ccedil;';
		entities['200'] = '&Egrave;';
		entities['201'] = '&Eacute;';
		entities['202'] = '&Ecirc;';
		entities['203'] = '&Euml;';
		entities['204'] = '&Igrave;';
		entities['205'] = '&Iacute;';
		entities['206'] = '&Icirc;';
		entities['207'] = '&Iuml;';
		entities['208'] = '&ETH;';
		entities['209'] = '&Ntilde;';
		entities['210'] = '&Ograve;';
		entities['211'] = '&Oacute;';
		entities['212'] = '&Ocirc;';
		entities['213'] = '&Otilde;';
		entities['214'] = '&Ouml;';
		entities['215'] = '&times;';
		entities['216'] = '&Oslash;';
		entities['217'] = '&Ugrave;';
		entities['218'] = '&Uacute;';
		entities['219'] = '&Ucirc;';
		entities['220'] = '&Uuml;';
		entities['221'] = '&Yacute;';
		entities['222'] = '&THORN;';
		entities['223'] = '&szlig;';
		entities['224'] = '&agrave;';
		entities['225'] = '&aacute;';
		entities['226'] = '&acirc;';
		entities['227'] = '&atilde;';
		entities['228'] = '&auml;';
		entities['229'] = '&aring;';
		entities['230'] = '&aelig;';
		entities['231'] = '&ccedil;';
		entities['232'] = '&egrave;';
		entities['233'] = '&eacute;';
		entities['234'] = '&ecirc;';
		entities['235'] = '&euml;';
		entities['236'] = '&igrave;';
		entities['237'] = '&iacute;';
		entities['238'] = '&icirc;';
		entities['239'] = '&iuml;';
		entities['240'] = '&eth;';
		entities['241'] = '&ntilde;';
		entities['242'] = '&ograve;';
		entities['243'] = '&oacute;';
		entities['244'] = '&ocirc;';
		entities['245'] = '&otilde;';
		entities['246'] = '&ouml;';
		entities['247'] = '&divide;';
		entities['248'] = '&oslash;';
		entities['249'] = '&ugrave;';
		entities['250'] = '&uacute;';
		entities['251'] = '&ucirc;';
		entities['252'] = '&uuml;';
		entities['253'] = '&yacute;';
		entities['254'] = '&thorn;';
		entities['255'] = '&yuml;';
    } else {
        throw Error("Table: "+useTable+' not supported');
        return false;
    }
    
    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal);
        histogram[symbol] = entities[decimal];
    }
    
    return histogram;
}

function htmlspecialchars (string, quote_style) {
	var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
        return false;
    }
    
    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
    
    return tmp_str;
}

 
 	
/************************************ end utils.js ***********************************/



