// JavaScript Document
function trim(str) {
	var whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000';
	for (var i = 0; i < str.length; i++) {
		if (whitespace.indexOf(str.charAt(i)) === -1) {
			str = str.substring(i);
			break;
		}
	}
	for (i = str.length - 1; i >= 0; i--) {
		if (whitespace.indexOf(str.charAt(i)) === -1) {
			str = str.substring(0, i + 1);
			break;
		}
	}
	return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}


function httprequest(sendparameters,destination,method){
	var sbar = '<span class="Ajax_loading">Loading</span>&nbsp;<img src="images/ajax-loader.gif" alt="" />';
	if(navigator.appName == "Microsoft Internet Explorer")
		http = new ActiveXObject("Microsoft.XMLHTTP");

	else
		http = new XMLHttpRequest();

		
		http.open(method, destination, true);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", sendparameters.length);
		http.setRequestHeader("Connection", "close");
		http.send(sendparameters);
		
		http.onreadystatechange=function() {
			if(http.readyState == 4) {
				var fetchedmsg = trim(http.responseText);
					$('#execution').html(fetchedmsg);
					bx.hide();
			}
		}
		return false;
}

function asciiToUnicode(str){
	var i;
	var strlen = str.length;
	var uniHex = "";
	fieldValue = str;
	for (i=0; i < strlen; i++){
		
		if(fieldValue.search(/[^0-9]/g) == -1) {
			nCode = fieldValue;
		} else {
			nCode = fieldValue.charCodeAt(i);
		}		
		 uniHex += so_asciiToUniHex(parseInt(nCode));
	}
	return uniHex;
}

function so_asciiToUniHex(asciiCode) {
	un = asciiCode.toString(16);
	while(un.length<4) un = "0" + un;
	return un;
}
