// Always the first js
var cl_fieldempty		= "#FFFF66";

function get_random() {
	ran1							= Math.random()*999999;
	ran2							= Math.random()*ran1;
	ran_number						= Math.round(ran2);	
	return ran_number;
}


function popup_text(sid, langid, errno, errstr) {
	window.open('popup_text.php?sid=' + sid + '&errno=' + errno + '&errstr=' + errstr + '&mode=err&langid=' + langid,'easyedit','left=250,top=100,width=600,height=500');
}

function editrecs(php_script, id) {
	newWindow 	= window.open("editrecs", 'editrecs', 'menubar=yes, resizable=yes, scrollbars=yes, status=yes, toolbars=yes, width=830, height=460, top=50, left=50');
	goto		= php_script + '?ssid=' + sid + "&id=" + id;
	//alert(goto);
	//newWindow.self.location = goto;
}


function gen_formpar(which) {

	str	= "";
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		str = str + "&" + tempobj.name + "=" + tempobj.value;
	}
	return str;
}


function set_div(div_id, txt_par) {
	document.getElementById(div_id).innerHTML = txt_par;
}

function get_divhtml(div_id) {
	aa		= document.getElementById(div_id).innerHTML;
	return aa;
}

// for faq


var win = null;

function NewWindow(mypage,myname,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
}

//----------------------------
function gen_GETRequest(url, str) {
	seed							= get_random();
	urlpar							= url + "?seed=" + seed + str;
	http.open("GET", urlpar, false);
	http.onreadystatechange 		= gen_getHttpResponse;
	http.send(null);
}		

function gen_getHttpResponse() {
	if (http.readyState == 4) {
		result													= http.responseText;			

		//alert("Gen Response: " + result);
		arresponse		= result.split("\n");
		postaction		= aj_response("NEXTACTION",		arresponse);
		poststatus		= aj_response("TASKSTATUS",		arresponse);
		errorstr		= aj_response("ERRORSTR",		arresponse);
		alert_result	= aj_response("ALERT_RESULT",	arresponse);
		if (alert_result == "1") {
			alert(result);
		}
		if (errorstr != "") {
			errorstr	= crs_str_replace("{newline}", "\n", errorstr)
			alert(errorstr);
		} else {
			eval(postaction);
		}

		return;
	}		
}

function getHTTPObject() {
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
	@else
	xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}

	return xmlhttp;
}


