<!--//
var async = true;

function getstamp()	{
	date = new Date();
	return date.getTime();
}

function loadDoc2(url, postdata, cb_func) {
	var req;
	req = false;
    if (window.XMLHttpRequest) {
    	try { req = new XMLHttpRequest(); } catch(e) { req = false; }
    } else if (window.ActiveXObject) {
       	try { req = new ActiveXObject("Msxml2.XMLHTTP"); } 
		catch(e) { 
			try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
			catch(e) { req = false; }
		}
    }
	if(req) {
		req.open("POST", url, async);
		req.onreadystatechange = function() { 
			if (req.readyState == 4 && req.status == 200 && cb_func != "") {
				eval("cb_"+cb_func+"(req.responseText);");
			}
		}
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send(postdata);
	}
}

function cb_revResult2 (txt) {
	eval(txt);
}

function ajaxPost (frm, url) {
	var e = frm.elements;
	var data = [];
	var post;
	for (i=0; i<e.length; i++) {
		if ((e[i].type == 'checkbox' && e[i].checked) || e[i].type != 'checkbox') {
			data.push(e[i].name+"="+e[i].value);
		}
	}
	post = data.join("&");
	loadDoc2(url, post, 'revResult2');
}

function pausePost (form_name, perform) {
	form = document.forms[form_name];
	ajaxPost(form, 'index.php?l=loading');
	setTimeout("ajaxPost(form, '"+perform+"', 'revResult2')", 2000);
}

function pauseGet (url) {
	loadDoc2('index.php?l=loading', '', 'revResult2');
	setTimeout("loadDoc2('"+url+"', '', 'revResult2')", 2000);
}

function reset_forms (items, form) {
	for (x in items) {
		var titem = items[x];
		var fitem = document.forms[form].elements[titem];
		if (fitem.selectedIndex != null)
			fitem.selectedIndex = 0;
		else
			fitem.value = '';
	}
}

function jsconfirm (action) {
	if (confirm("Are you sure you want to " + action + "?")) {
    	return true;
	} else {
    	return false;
    }
}

function rcertify () {
	popupWin = window.open('http://www.bbbonline.org/cks.asp?id=104032414574841121', 'Participant','location=yes,scrollbars=yes,width=450,height=300');
	window.name = 'opener';
}

function rcertify2 () {
	popupWin = window.open('http://www.controlscan.com/cgi-bin/pcir/seal/verify4.php?dom=D78D465A&id=9', 'Participant','location=yes,scrollbars=yes,width=450,height=300');
	window.name = 'opener';
}

function getCode () {
	var index = document.forms['order'].elements['orderinfo[input_country]'].selectedIndex
	var cntryCode = document.forms['order'].elements['orderinfo[input_country]'].options[index].value
	document.forms['order'].elements.phone_cc.value = cntryCode
}

function checkCode () {
	var index = document.forms['order'].elements['orderinfo[input_country]'].selectedIndex
	var cntryCode = document.forms['order'].elements['orderinfo[input_country]'].options[index].value
	document.forms['order'].elements.phone_cc.value = cntryCode
}

function show_hidden (d)	{
	e = document.getElementById('hidden'+d);
	if (e.style.display != 'block') {
		document.getElementById('hiddenshow'+d).innerHTML = 'Hide';
		e.style.display = 'block';
		e.style.visibility = 'visible';
	} else {
		document.getElementById('hiddenshow'+d).innerHTML = 'Show';
		e.style.display = 'none';
		e.style.visibility = 'hidden';
	}
}

function urlencode (str) {
	str = escape(str);
	str = str.replace('+', '%2B');
	str = str.replace('%20', '+');
	str = str.replace('*', '%2A');
	str = str.replace('/', '%2F');
	str = str.replace('@', '%40');
	return str;
}

function add_note (id, admin) {
	var note = urlencode(prompt("Please enter order note."));
	pauseGet('index.php?l=order_note&id='+id+'&admin='+admin+'&note='+note);
}

function do_select (d, e) {
	var doc = eval("document."+e+"."+d);
	doc.focus();
	doc.select();
}

function refresh () {
	if (confirm("Action has been completed sucessfully. Would you like to refresh the page now?")) {
		return true;
	} else {
		return false;
	}
}

//-->
