function openWindow(url, name, width, height, features) {
	var ref;
	var query = '';
	
	if ((width != 0) && (height != 0))
	{
		var top = 0;
		var left = 0;

		if (screen.width > width) left = (screen.width - width) / 2;
		if (screen.height > height) top = (screen.height - height) / 2;
		query = query + 'scrollbars=yes,left='+left+',top='+top+',screenX='+left+',screenY='+top+',width='+width+',height='+ height;
	}
	if (typeof(features) != "undefined") query = query + features;
	
	if (document.all && window.print)	// ie5
		eval('window.showModelessDialog(url,window,"status:0;help:1;resizable:0;dialogWidth:'+width+'px;dialogHeight:'+height+'px")')
	else {
		ref = window.open(url, name, query);
		ref.focus();
		if (navigator.appName != 'Microsoft Internet Explorer') { if (window.focus) ref.focus(); }
	}
}

function closeWindow(reload) {
	if (reload == 'reload') 
		if (!top.opener.closed) top.opener.location.reload();
	
	top.close();
}

function disableSubmits (form) {
	for (var i = 0; i < form.elements.length; i++)
		if (form.elements[i].type.toLowerCase() == 'submit')
			form.elements[i].disabled = true;
}


function openWin(url) {
	var ref;

	ref = window.open(url,"myPopUpWin","toolbar=no,location=no,directories=no,status=no,scrollbars=auto,resizable=yes,width=400,height=200");
	ref.focus();
}

function openWinSized(url, width, height) {
	var ref;

	ref = window.open(url,'myPopUpWin','toolbar=no,location=no,directories=no,status=yes,scrollbars=auto,resizable=yes,width='+width+',height='+height);
	ref.focus();
}

function openWinSized2(url, width, height) {
	var ref;

	ref = window.open(url,'myPopUpWin','toolbar=yes,location=no,directories=no,status=yes,scrollbars=auto,resizable=yes,width='+width+',height='+height);
	ref.focus();
}

function checkAll(frmName, elmName) {
	eval('frm = document.' + frmName);
	eval('elm = document.' + frmName + '.' + elmName)
		
	for (var j=0; j< frm.elements.length; j++){			
		if (frm.elements[j].type == 'checkbox') frm.elements[j].checked = elm.checked;											
	}							
}

function calendarPopup(page) {
	wndCalendar = this.open(page, "wndCalendar", "status=no,toolbar=no,menubar=no,resizable=no,scrollbars=no,width=200,height=170");
	self.name = "wndMain";
	wndCalendar.focus();
}


function showhide(elmnt) {
	//alert(elmnt);
	var e;
	if (document.all)
		eval('e = document.all.'+elmnt);
	else
		e = document.getElementById(elmnt);

	if (e.style.display == "inline")
		e.style.display = "none";
	else
		e.style.display = "inline";
}

function show(elmnt) {
	//alert(elmnt);
	var e;
	if (document.all)
		eval('e = document.all.'+elmnt);
	else
		e = document.getElementById(elmnt);

	e.style.display = "inline";
}

function hide(elmnt) {
	//alert(elmnt);
	var e;
	if (document.all)
		eval('e = document.all.'+elmnt);
	else
		e = document.getElementById(elmnt);

	e.style.display = "none";
}

function confirmation(sMessage) {
	if (confirm(sMessage)) {
		return true;
	}else{
		return false;
	}
}

function isInteger(a){return a==parseInt(a,10)}

function disableButton(elmt) {
	if (document.all || document.getElementById)
		elmt.disabled = true ;
	return true;
}

function disableForm(theform) {
	if (document.all || document.getElementById) {
		for (i = 0; i < theform.length; i++) {
			var tempobj = theform.elements[i];
			if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
				tempobj.disabled = true;
		}
	}
	return true;
}
/***********************************************
* Copy contact address info. to billing address info.
***********************************************/  
  function  BillToContact(form) 
	{
		if (form.copy.checked)
			 {
				form.FirstName.value = form.sFirstName.value;
				form.LastName.value = form.sLastName.value;
				form.Company.value = form.sCompany.value;
				form.Phone.value = form.sPhone.value;
				form.Fax.value = form.sFax.value;
				form.Email.value = form.sEmail.value;
				form.AddressLine1.value = form.sAddressLine1.value;
				form.AddressLine2.value = form.sAddressLine2.value;
				form.City.value = form.sCity.value;
				form.State.selectedIndex = form.sState.selectedIndex;
				form.Zip.value = form.sZip.value;
				form.Country.selectedIndex = form.sCountry.selectedIndex;
			}		
	}	
/***********************************************
* Disable "Enter" key in Forms
***********************************************/                
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}
/***********************************************
* 'checkuncheckall' function for the form: 'frmArticles'
'the list  should more than one item for this script to work
***********************************************/                			
function CheckUncheckAll(theElement)
{
  var i, form; 
  form = theElement.form
  
  if (form.checkall.checked)
  {
	for(i=0; i<form.forms.length; i++)
	{  form.forms[i].checked = true;}  
  }
  else
  {
	for(i=0; i<form.forms.length; i++)
	{  form.forms[i].checked = false;}
  }
}		
	
function DoRefresh(theElement)
{
 var form; 
  form = theElement.form
  
	if (theElement.Name == "questiontypeid")
	{
		if (document.frmQuestion.questiontypeid.selectedIndex == 0) {
			alert("Please select a question type");
			return (false);
		}
	}
	form.refreshed.value="yes";
	form.submit();
	return (true);
}

function Check(theElement)
{
  var form; 
  form = theElement.form
  
  if (form.sendemail.checked)
	{ return (false); } 
  else			
  {
	  form.sendemail.checked = true;
	  return (true);
  }
}	  				



