
function checkForm(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15)
{
	var cfname, clname, cemail, cPPemail, password1, password2, checkbox;
	
	var timezoneid = document.getElementById("timezoneid");
	var d = new Date()
	var gmtHours = (d.getTimezoneOffset()/60)*-1;
	timezoneid.innerHTML = '<input type="hidden" name="timezone" value="'+ gmtHours +'" >';
	
	with(window.document.msgform1)
	{
		cfname    = first_name;
		clname    = last_name;
		cemail    = email;
		cPPemail    = PPemail;
		cpassword1 = password1;
		cpassword2 = password2;
		ccheckbox  = checkbox;
	}
	
	if(trim(cfname.value) == '')
	{
		alert(e1); //alert('Please enter your first name');
		cfname.focus();
		return false;
	}
	else if(!isLen(trim(cfname.value),50))
	{
		alert(e2); //alert('String too long');
		cfname.focus();
		return false;
	}
	if(trim(clname.value) == '')
	{
		alert(e3); //alert('Please enter your last name');
		clname.focus();
		return false;
	}
	else if(!isLen(trim(clname.value),50))
	{
		alert(e4); //alert('String too long');
		clname.focus();
		return false;
	}
	else if(trim(cemail.value) == '')
	{
		alert(e5); //alert('Please enter your email');
		cemail.focus();
		return false;
	}
	else if(!isEmail(trim(cemail.value)))
	{
		alert(e6); //alert('Email address is not valid');
		cemail.focus();
		return false;
	}
	else if(!isLen(trim(cemail.value),40))
	{
		alert(e7); //alert('String too long');
		cemail.focus();
		return false;
	}
	else if(trim(cpassword1.value) == '')
	{
		alert(e8); //alert('Please enter your password');
		cpassword1.focus();
		return false;
	}
	else if(!isAlpha(trim(cpassword1.value)))
	{
		alert(e9); //alert('Invalid password');
		cpassword1.focus();
		return false;
	}
	else if(!isLen(trim(cpassword1.value),10))
	{
		alert(e10); //alert('String too long');
		cpassword1.focus();
		return false;
	}
	else if(trim(cpassword2.value) == '')
	{
		alert(e11); //alert('Please Re-enter your password');
		cpassword2.focus();
		return false;
	}
	else if(cpassword2.value != cpassword1.value)
	{
		alert(e12); //alert('Please Re-enter your password again');
		cpassword2.focus();
		return false;
	}
	else if ( trim(cPPemail.value) != '' && !isEmail(trim(cPPemail.value)) )
	{
		alert(e13); //alert('PayPal email address is not valid');
		cPPemail.focus();
		return false;
	}
	else if(trim(cPPemail.value) != '' && !isLen(trim(cPPemail.value),40))
	{
		alert(e14); //alert('String too long');
		cPPemail.focus();
		return false;
	}
	else if(!ccheckbox.checked)
	{
		alert(e15); //alert('Please accept the terms and policies');
		ccheckbox.focus();
		return false;
	}
	else
	{
		if (window.document.msgform1.countries.value==103 && 
			!window.document.msgform1.vat.checked &&
			window.document.msgform1.checkbox1.checked) {
			alert("You must acknowledge that you shall provide receipts according to the Israeli law!");
			window.document.msgform1.vat.focus();
			return false;		
		}
		
		cfname.value    = trim(cfname.value);
		clname.value    = trim(clname.value);		
		cemail.value   = trim(cemail.value);
		cPPemail.value   = trim(cPPemail.value);
		return true;
	}
}



function emailChangeValid(e1, e2, e3)
{
	var cemail1, cemail2;
		
	with(window.document.emailchange)
	{
		cemail1    = new_email;
		cemail2    = re_new_email;
	}
	
	if (trim(cemail1.value) == '' || trim(cemail2.value) == '')
	{
		alert(e1);
		cemail1.focus();
		return false;
	}
	else if(!isEmail(trim(cemail1.value)))
	{
		alert(e2);
		cemail1.focus();
		return false;
	}
	else if(!isEmail(trim(cemail2.value)))
	{
		alert(e2);
		cemail2.focus();
		return false;
	}
	else if(!isLen(trim(cemail1.value),40) || !isLen(trim(cemail2.value),40))
	{
		alert(e3);
		cemail1.focus();
		return false;
	}
	else
	{
		cemail1.value   = trim(cemail1.value);
		cemail2.value   = trim(cemail2.value);
		return true;
	}
}



function checkEmbedFormIframe(e1, e2, e3)
{
	var iow, ioh, iiw, iih;
	with(window.document.embed_confirm_form)
	{
		iow    = iframe_outer_width;
		ioh    = iframe_outer_height;
		iiw    = iframe_inner_width;
		iih    = iframe_inner_height;
	}
	
	if (!checkItem(iow, e1, e2, e3))
		return false;	
	if (!checkItem(ioh, e1, e2, e3))
		return false;
	if (!checkItem(iiw, e1, e2, e3))
		return false;
	if (!checkItem(iih, e1, e2, e3))
		return false;

	iow.value    = trim(iow.value);		
	ioh.value    = trim(ioh.value);		
	iiw.value    = trim(iiw.value);		
	iih.value    = trim(iih.value);		
	
	return true;
}


function checkEmbedFormSWF(e1, e2, e3, e4)
{
	var siw, sih, bgc1;
	with(window.document.embed_confirm_form)
	{
		siw    = swf_inner_width;
		sih    = swf_inner_height;
		bgc1 = bgcolor1;
	}
	//bgc1 = document.getElementById("bgcolor1");
	
	if (!checkItem(siw, e1, e2, e3))
		return false;  
	if (!checkItem(sih, e1, e2, e3))
		return false;
	if (!bgc1.value) {
		bgc1.value = '0';
		return true;
	}
	else if (trim(bgc1.value)=='0')
		bgc1.value = trim(bgc1.value);
	else if (!isColor(bgc1.value)) {
		alert(e4);
		bgc1.focus();
		return false;
	}
	bgc1.value = trim(bgc1.value);
		
	siw.value    = trim(siw.value);
	if (siw.value<200)
		siw.value=200;
	sih.value    = trim(sih.value);
	if (sih.value<50)
		sih.value=50;
	
	return true;
}

function checkBgcolor(bgc1, e1) {
	if (!isColor(bgc1)) {
		alert(e1);
		bgc1.focus();
		return false;
	}
	bgc1.value    = trim(bgc1.value);		
	return true;
}


function checkMailForm(e1, e2)
{
	var to;
	with(window.document.embed_form)
	{
		to    = mail_to;
	}
	
	if (trim(to.value) == '') {
		alert(e1);
		to.focus();
		return false;
	}
	else if(!isEmail(trim(to.value)))
	{
		alert(e2);
		to.focus();
		return false;
	}
	to.value    = trim(to.value);		
	
	return true;
}



function checkItem(itm, e1, e2, e3) {
	if (trim(itm.value) == '') {
		alert(e1); //alert('Please enter your first name');
		itm.focus();
		return false;
	}
	else if (!isNumPercent(itm.value)) {
		alert(e2);
		itm.focus();
		return false;		
	}
	return true;
}


function checkItemNum(itm, e1, e2, e3) {
	if (trim(itm.value) == '') {
		alert(e1); //alert('Please enter your first name');
		itm.focus();
		return false;
	}
	else if (itm.value != '0' && itm.value != '1') {
		alert(e3);
		itm.focus();
		return false;		
	}
	return true;
}


/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

/*
Check if a string is in valid email format. 
Returns true if valid, false otherwise.
*/
function emailOK(e, id)
{
	var itm = document.getElementById(id);
	if(!isEmail(trim(itm.value))) {
		alert(e); //alert('Email address is not valid');
		itm.focus();
		return false;
	}
	return true;
}


function isEmail(str)
{
	var regex = /^[-_.a-z0-9]+@(([-a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
   	//regex = /^[-_.abcdefghijklmnopqrstuvwxyz0123456789]+@(([-abcdefghijklmnopqrstuvwxyz0123456789]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
	return regex.test(str);
}

function isAlpha(str){
      var regex = /^[_0-9a-z]+$/i;
       return regex.test(str);
}

function isInt(str){
      var regex = /^[_0-9]+$/i;
       return regex.test(str);
}

function isNumPercent(str){
      var regex = /^[_0-9]+[%]?$/i;
       return regex.test(str);
}

function isColor(str){
      var regex = /^[0-9a-fA-F]{6}$/i;
       return regex.test(str);
}

function isLen(str, len){
       return (str.length < len);
}


function goTo(url){
	window.location.href = url;
}


function checkbox1(e) {
if (!window.document.msgform3.checkbox.checked)
	{
		alert(e); //('Please approve details');
		ccheckbox.focus();
		return false;
	}
return true;
}

function mhHover(tbl, idx, cls)
{
	var t = document.getElementById(tbl);
	if (t == null) return;
	var d = t.getElementsByTagName("TD");
	if (d == null) return;
	if (d.length <= idx) return;
	d[idx].className = cls;
}

// DYNAMICALLY TAKE VALUES OF ALIGN VARIABLES TO SET THEM IN THE ALIGN[] ARRAY.
function check_trans_html() {
	with(window.document.html_form) {
		for (i=0; i<idx.value; i++) {
			left = 0;
			right = 0;
			algn_0 = document.getElementById('algn0_' + i);
			algn_1 = document.getElementById('algn1_' + i);
			align = document.getElementById('align' + i);
			if (algn_0 && algn_0.checked) {
				align.value = algn_0.value;
				//alert( i );
			}
			if (algn_1 && algn_1.checked) {
				align.value = algn_1.value; 
				//alert( i );
			}
		}
	}
}


function enableField() {
	//pay_id = document.getElementById('pay_btn');
	//pay_id.disabled=false;
	//window.document.txn_pay_frm.txn_pay.disabled=false;
}

function check_confirm1(e1, e2) {
	var answer;

	with(window.document.trans_form)
	{
		// modified_price is active only when customer approves and when txn is not free
		if (!document.getElementById('modified_price')) {
			answer = confirm (e2);
			if (answer)
				checkbox.value = true;
			else
				checkbox.value = false;
			return answer;
		}	
		if (checkbox.checked) {
		
			if (trim(modified_price.value) == '') {
				alert(e1);
				modified_price.focus();
				return false;

			}	
			else if (modified_price.value != ask_price.value) {
				answer = confirm (ask_price.value + ' USD   >>   ' + modified_price.value + ' USD ?');
				if (!answer) {
					modified_price.focus();
					return false;
				}

			}	
			answer = confirm (e2);
			if (answer)
				checkbox.value = true;
			else
				checkbox.value = false;
			return answer;
		}
	}
	return answer;
}

function check_confirm(e1) {
	var answer;

	answer = confirm (e1);
	if (answer)
		return true;
	else
		return false ; 
}


function askData(txt) { 
	var agree=confirm(txt); 
	if (agree) 
		return true ; 
	else 
		return false ; 
} 



function QAform(txt, e1, e2, e3)
{
	var cfname, accuracy, level, checkbox;
	with(window.document.qa_review)
	{
		cradio1   = accuracy;
		cradio2   = level;
		ccheckbox  = lvlYN;
	}
	
	if(!ccheckbox[0].checked && !ccheckbox[1].checked && !ccheckbox[2].checked && !ccheckbox[3].checked)
	{
		alert(e1); //('Please approve or reject request');
		ccheckbox[0].focus();
		return false;
	}	
	else if(!cradio1[0].checked && !cradio1[1].checked && !cradio1[2].checked && !cradio1[3].checked && !cradio1[4].checked)
	{
		alert(e2); //('Please provide translation accuracy rating');
		cradio1[0].focus();
		return false;
	}	
	else if(!cradio2[0].checked && !cradio2[1].checked && !cradio2[2].checked && !cradio2[3].checked && !cradio2[4].checked)
	{
		alert(e3); //('Please provide translation level rating');
		cradio2[0].focus();
		return false;
	}	
	else
	{
		return askData(txt);
	}
}

// AUDIT
function QAform2(txt, e1, e2, e3)
{
	var cradio1, cradio2, ccheckbox, note;
	with(window.document.qa_rate)
	{
		cradio1   = accuracy;
		cradio2   = quality;
		ccheckbox  = lvlYN;
		note = note2customer;
	}
	
	if(!ccheckbox[0].checked && !ccheckbox[1].checked && !ccheckbox[2].checked && !ccheckbox[3].checked)
	{
		alert(e1); //('Please approve or reject request');
		ccheckbox[0].focus();
		return false;
	}	
	else if(!cradio1[0].checked && !cradio1[1].checked && !cradio1[2].checked && !cradio1[3].checked && !cradio1[4].checked)
	{
		alert(e2); //('Please provide translation accuracy rating');
		cradio1[0].focus();
		return false;
	}	
	else if(!cradio2[0].checked && !cradio2[1].checked && !cradio2[2].checked && !cradio2[3].checked && !cradio2[4].checked)
	{
		alert(e3); //('Please provide translation level rating');
		cradio2[0].focus();
		return false;
	}	
	else
	{
		return askData(txt);
	}
}

// DISPUTE
function QAform3(txt, e1, e2, e3, e4, e5)
{
	var cradio1, cradio2, cradio3, ccheckbox, note;
	with(window.document.qa_rate)
	{
		cradio1   = accuracy;
		cradio2   = quality;
		cradio3   = disputeYN;
		ccheckbox  = lvlYN;
		note = note2customer;
	}
	
	if(!ccheckbox[0].checked && !ccheckbox[1].checked && !ccheckbox[2].checked && !ccheckbox[3].checked)
	{
		alert(e1); //('Please approve or reject request');
		ccheckbox[0].focus();
		return false;
	}	
	else if(!cradio1[0].checked && !cradio1[1].checked && !cradio1[2].checked && !cradio1[3].checked && !cradio1[4].checked)
	{
		alert(e2); //('Please provide translation accuracy rating');
		cradio1[0].focus();
		return false;
	}	
	else if(!cradio2[0].checked && !cradio2[1].checked && !cradio2[2].checked && !cradio2[3].checked && !cradio2[4].checked)
	{
		alert(e3); //('Please provide translation level rating');
		cradio2[0].focus();
		return false;
	}	
	else if(!cradio3[0].checked && !cradio3[1].checked && !cradio3[2].checked)
	{
		alert(e4); 
		cradio3[0].focus();
		return false;
	}
	else if (trim(note.value)=='')
	{
		alert(e5);
		note.focus()
		return false;
	}	
	else
	{
		return askData(txt);
	}
}



function qa_price_calc() {
	if (document.msg1form.qaYN.checked) {
		document.msg1form.qa_price.value = dollar(document.msg1form.ask_price.value * 0.1);
		document.msg1form.qaYN.value = 1;
	}
	else {
		document.msg1form.qa_price.value = 0;
		document.msg1form.qaYN.value = 0;
	}
}

function dollar (amount)
{
        amount = parseInt(amount * 100);
        amount = parseFloat(amount/100);
        if (((amount) == Math.floor(amount)) && ((amount - Math.floor (amount)) == 0))
        {
                amount = amount + ".00"
                return amount;
        }
        if ( ((amount * 10) - Math.floor(amount * 10)) == 0)
        {
                amount = amount + "0";
                return amount;
        }
        if ( ((amount * 100) - Math.floor(amount * 100)) == 0)
        {
                amount = amount;
                return amount;
        }
        return amount;
}


function CloseWindow(url) {

  window.close();
  window.open(url);

  // <a href="javascript:CloseWindow()">Close This Window</a>
  
}

var newWindow;
function makeNewWindow() {
    if (!newWindow || newWindow.closed) {
        newWindow = window.open("", 'spop', 'left=20,top=20,resizable=yes,scrollbars=yes,width=610,height=620'); //window.open("","sub","status,height=200,width=300");
        if (!newWindow.opener) {
            newWindow.opener = window;
        }
        setTimeout("writeToWindow()", 500);
    } else if (newWindow.focus) {
        newWindow.focus();
    }
}
function writeToWindow() {
    var newContent = "<html><head><title>Terms & Polcies</title>";
	
	newContent += "<META http-equiv=Content-Type content='text/html; charset=UTF-8'></head>";
    newContent += "<body style=\"FONT-FAMILY: Arial, Helvetica, sans-serif\">";
    newContent += "<iframe src=\"tmp/tnc.html\"  width=\"100%\" height=\"100%\"></iframe>";
    newContent += "</body></html>";
    newWindow.document.write(newContent);
    newWindow.document.close(); // close layout stream
}


function ShowHelp(obj,field,hide)
{
	//Get help object
	var helpObj;
	//if (field==0)
	//	field="0";
	if (document.all){
	helpObj = document.all[field+"_help"];}
	else if (document.getElementById){
		helpObj = document.getElementById(field+"_help");}
	if (helpObj) {
		//if help object is shown, hide it ; if object hidden, show it
		if (hide){
		  helpObj.style.display = "none";}
		else{
		  helpObj.style.display = "";}

		//Get location of mouseover object, move help object to the left if will display off-screen
		var divWidth = 340;
		var offsetLeft = getOffsetLeft(obj);
		var screenWidth = (window.innerWidth) ? window.innerWidth - 25 : document.body.clientWidth;
		if ((offsetLeft + divWidth) > screenWidth) offsetLeft = screenWidth - divWidth;
		newX = offsetLeft;
	
		//Get location of mouseover object, move help object on top if will display off-screen
		var divHeight = helpObj.offsetHeight;
		var offsetTop = getOffsetTop(obj) + obj.offsetHeight;
		var screenHeight = (window.innerHeight) ? window.innerHeight - 25 : document.body.clientHeight;
		if ((offsetTop + divHeight) > screenHeight + getScrollY()) offsetTop = getOffsetTop(obj) - divHeight;
		newY = offsetTop;	
	
		helpObj.style.top = newY;
		helpObj.style.left = newX;

		if (!hide){
		  qh_hideElement("select",helpObj);  
		  qh_hideElement("object",helpObj);  
		  qh_hideElement("embed",helpObj);  }
		else{
		  qh_showElement("select");  
		  qh_showElement("object");  
		  qh_showElement("embed");}
	}
}

function getOffsetTop (elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while (mOffsetParent) {
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;}
	return mOffsetTop;
}

function getOffsetLeft (elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while (mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;}
	return mOffsetLeft;
}

function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape
    scrOfY = window.pageYOffset;}
  else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM
    scrOfY = document.body.scrollTop;}
  else if( document.documentElement &&
      ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6
    scrOfY = document.documentElement.scrollTop;}
  return scrOfY;
}

function qh_hideElement( elmID, overDiv ) {
  if(document.all) {
    for(i = 0; i < document.all.tags( elmID ).length; i++) {
      obj = document.all.tags( elmID )[i];
      if(!obj || !obj.offsetParent) continue;

      // Find the element's offsetTop and offsetLeft relative to the BODY tag.
      objLeft   = obj.offsetLeft;
      objTop    = obj.offsetTop;
      objParent = obj.offsetParent;

      while(objParent.tagName.toUpperCase() != 'BODY') {
        objLeft  += objParent.offsetLeft;
        objTop   += objParent.offsetTop;
        objParent = objParent.offsetParent;
      }

      objHeight = obj.offsetHeight;
      objWidth  = obj.offsetWidth;

      if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft);
      else if((overDiv.offsetTop + overDiv.offsetHeight) <= objTop);
      else if(overDiv.offsetTop >= (objTop + objHeight));
      else if(overDiv.offsetLeft >= (objLeft + objWidth));
      else {
        obj.style.visibility = 'hidden';
      }
    }
  }
}
function qh_showElement(elmID) {
  if(document.all) {
    for(i = 0; i < document.all.tags( elmID ).length; i++) {
      obj = document.all.tags(elmID)[i];
      if(!obj || !obj.offsetParent) continue;
      obj.style.visibility = '';
    }
  }
}


function check(yn){
  for (var i = 0; i < document.inbox.elements.length; i++) {
    var e = document.inbox.elements[i];
    if ((e.name == 'allbox') && (e.type == 'checkbox')) {
		e.checked = yn;
    }
  }
}

function makecheck(form, table, check)  {
   var options = form.elements[table];
   for (var i=0;i<options.length;i++)
	if (options[i].type == 'checkbox')
		options[i].checked = check;
}

function enableAll() {
  masterChecked = document.inbox.master.checked; 
  for(i=0; i<document.inbox.elements.length; i++) {
    if(document.inbox.elements[i].type=="checkbox") {
      document.inbox.elements[i].checked=masterChecked;
    }
  }
}

function check_uncheck_all(table, id)  {
   var options = document.filter_frm.elements[table];
   
   var e = document.getElementById(id);
   masterChecked = e.checked; 
   for (var i=0;i<options.length;i++)
	if (options[i].type == 'checkbox')
		options[i].checked = masterChecked;
}


function StartCountDown(myDiv,myTargetDate, myNowDate)
{
	var dthen	= new Date(myTargetDate);
	var dnow	= new Date(myNowDate);
//	dnow.setHours(00,00,0);
//	dthen.setHours(01,00,0);

	ddiff		= new Date(dthen-dnow);
	gsecs		= Math.floor(ddiff.valueOf()/1000);
	CountBack(myDiv,gsecs);
}

function Calcage(secs, num1, num2)
{
	s = ((Math.floor(secs/num1))%num2).toString();
	if (s.length < 2) 
	{	
	  s = "0" + s;
	}
	return (s);
}

function CountBack(myDiv, secs)
{

	var DisplayStr;
	//var DisplayFormat = "%%D%% Days %%H%%:%%M%%:%%S%%";
	var DisplayFormat = "%%H%%:%%M%%:%%S%%";
	DisplayStr = DisplayFormat.replace(/%%D%%/g,	Calcage(secs,86400,100000));
	DisplayStr = DisplayStr.replace(/%%H%%/g,		Calcage(secs,3600,24));
	DisplayStr = DisplayStr.replace(/%%M%%/g,		Calcage(secs,60,60));
	DisplayStr = DisplayStr.replace(/%%S%%/g,		Calcage(secs,1,60));
	if(secs > 0)
	{	
	  document.getElementById(myDiv).innerHTML = DisplayStr;
	  setTimeout("CountBack('" + myDiv + "'," + (secs-1) + ");", 990);
	}
	else
	{
	  document.getElementById(myDiv).innerHTML = "00:00:00";
	  window.document.test_form.submit_test.disabled = true;
	  
	  //window.document.test_form.start_test.disabled = true;
	  //location.href="main.php";
	}
}

// test ... attempt to move to certain position after clicking txn in transaction.php - not in use.
function scroll_pos(val) {
	window.onload=function(){ 
	     var e = document.getElementById('lastLocation');
	     if(e){ 
	         top.location.href = top.location.href + "#" + e.value;
	     }
	}
}

function mw(locale) {
	window.open ('transcalc.php?locale='+locale, 'newwindow', config='height=600,width=500, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');
}

function mw1(locale) {
	window.open ('translate_filter.php?locale='+locale, 'newwindow', config='height=400,width=800, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');
}

function mw2(locale, radiobutton) {
	window.open ('lost_bids.php?locale='+locale+'&radiobutton='+radiobutton, 'newwindow', config='height=400,width=800, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, directories=no, status=no');
}

function mw3(locale) {
	window.open ('lc_hist.php?locale='+locale, 'newwindow', config='height=400,width=800, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');
}

function nw(file) {
	window.open (file, 'newwindow', config='height=400,width=800, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, directories=no, status=no');
}



function LTfindObj(n, d) {
  var p,i,x;  
  if (!d) 
	d=document; 
  if ((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if (!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
	x=d.forms[i][n];
  for (i=0;!x&&d.layers&&i<d.layers.length;i++) 
	x=LTfindObj(n,d.layers[i].document);
  if (!x && document.getElementById) 
	x=document.getElementById(n); 
  return x;
}

function LTshowHideHlp() {
  var i,p,v,obj,args=LTshowHideHlp.arguments;
  
  for (i=0; i<(args.length-2); i+=3) 
	if ((obj=LTfindObj(args[i]))!=null) { 
		v=args[i+2];
	    if (obj.style) { 
			obj=obj.style; 
			v=(v=='show')?'visible':(v='hide')?'hidden':v; 
		}
	    obj.visibility=v; 
    }
}


/////////////////////////////////////////////////////////////////////////////////////////////////////
// Menues handling

var timeout	= 500;
var timeoutDone	= 0;
var hideShowItem	= 0;

function dropDown(id) {	

	closeByTime();

	if (hideShowItem)
		hideShowItem.style.visibility = "hidden";

	hideShowItem = document.getElementById(id);
	hideShowItem.style.visibility = "visible";
}

function dropUp() {
	if (hideShowItem)
		hideShowItem.style.visibility = "hidden";
}

function dropUptime() {
	timeoutDone = window.setTimeout(dropUp, timeout);
}

function closeByTime() {
	if(timeoutDone) {
		window.clearTimeout(timeoutDone);
		timeoutDone = null;
	}
}

document.onclick = dropUp; 

/////////////////////////////////////////////////////////////////////////////////////////////////////

// Wait for load message
function wait4load() { //DOM
	if (document.getElementById){
		var loadwait = document.getElementById('loadwait');
		if (loadwait)
			document.getElementById('loadwait').style.visibility='hidden';
	}
	else{
		if (document.layers){ //NS4
			document.prepage.visibility = 'hidden';
		}
		else { //IE4
			document.all.prepage.style.visibility = 'hidden';
		}
	}
}
