//<![CDATA[
function CactusoftCounter(field,CactusoftCounterField,MaximumLimit) {
	if (field.value.length > MaximumLimit) {
		if(document.styleSheets) {
			CactusoftCounterField.style.color = '#CC0000';
			CactusoftCounterField.style.background = '#FFAAAA';
			}
		}
	else {
		if(document.styleSheets) {
			CactusoftCounterField.style.color = '#006699';
			CactusoftCounterField.style.background = '#DDE8EE';
			}
	}
	CactusoftCounterField.value = MaximumLimit - field.value.length;
	}

function CactusoftCounterPercentage(field,CactusoftCounterField,MaximumLimit) {
	if (field.value.length > MaximumLimit) {
		if(document.styleSheets) {
			CactusoftCounterField.style.color = '#CC0000';
			CactusoftCounterField.style.background = '#FFAAAA';
			}
		}
	else {
		if(document.styleSheets) {
			CactusoftCounterField.style.color = '#006699';
			CactusoftCounterField.style.background = '#DDE8EE';
			}
	}
	CactusoftCounterField.value = (100 - Math.round((field.value.length / MaximumLimit) * 100)) + "%";
	}


function PopUp(theURL,winName,features)
		{window.open(theURL,winName,features);}

function ToggleItem(myItem) {
		if (myItem.style.visibility != 'hidden') {
			HideItem(myItem);
		} else {
			ShowItem(myItem);
		}
		return false;
	}
function ShowItem(myItem) {
		myItem.style.visibility = 'visible';
		myItem.style.display = 'inline';
	}
function HideItem(myItem) {
		myItem.style.visibility = 'hidden';
		myItem.style.display = 'none';
	}
	

function CactusoftCheckAllBoxes() {
		temp = document.getElementById('form2').elements.length;
		for (i=0; i < temp; i++)
			{
			document.getElementById('form2').elements[i].checked=1;
			}
		}

function CactusoftUnCheckAllBoxes() {
		temp = document.getElementById('form2').elements.length;
		for (i=0; i < temp; i++)
			{
			document.getElementById('form2').elements[i].checked=0;
			}
		}

function CactusoftDisableSubmitOnMax(btnEnable, numMaxAllowed) {
	var numCount = 0;
	for (i = 0; i < document.getElementById('form2').elements.length; i++) {
		var tempobj = document.getElementById('form2').elements[i];
		if (tempobj.name.substring(0, 3)=='vac') {
			// Increment the counter if it's checked and it's an enabled job
			if ((tempobj.value=='n') && (tempobj.checked==1)) {
				numCount++;
			}
		}
	}
	if (numCount > numMaxAllowed) {
		btnEnable.disabled = true;
	} else {
		btnEnable.disabled = false;
	}
}

function VacSubmit()
{
    frm = document.LangForm
    
    frm.submit()
}

function printInv(id) {
	window.open('x_invoice.asp?id='+ id,'print','width=680,height=960,status=no,menubar=yes,toolbar=no')
}

function printInvAdmin(id) {
	window.open('y_invoice.asp?id='+ id,'print','width=680,height=960,status=no,menubar=yes,toolbar=no')
}

function toggleClass(id) {
	//return if browser doesnt support
	if(!document.getElementById){return;}
	
	var obj = document.getElementById(id);
	if(obj.className == 'over') {
		obj.className = 'on';
	} else {
		obj.className = 'over';
	}
}

function getFieldVal(fieldName) {
	if($('[name="' + fieldName + '"]').length > 0) {
		return $('[name="' + fieldName + '"]').attr('value');
	}
}

function clearInput(input){
	//return if browser doesnt support
	if(!document.getElementById){return;}
	
	var obj = document.getElementById(input);
	obj.value = '';
}
//]]>
