function confirmRedirect(pageURL) {
	var answer = confirm("Are you sure?");
	if (answer)
		window.location=pageURL;
}

function printPage() {
	if (window.print != null) {
		window.print();
	} 
	else {
		alert('Your browser does not support this feature! Please select File and Print.');
	}
}

function submitPageNo(pageNoNew) {
  document.nextPage.page.value = pageNoNew;
  document.nextPage.submit();
}

function submitSort() {
  document.sortResult.page.value = 1;
  document.sortResult.submit();
}

function popWindow(pageURL) {
//	win=window.open("",'popWindow','width=600,height=600,resizable=yes,scrollbars=yes');
	win=window.open(pageURL,'popWindow','width=750,height=600,resizable=yes,scrollbars=yes');
	if (!win.opener)win.opener=self;
	if (win.focus)win.focus();
}

function popWindowCoupon(pageURL) {
//	win=window.open("",'popWindow','width=600,height=600,resizable=yes,scrollbars=yes');
	win=window.open(pageURL,'popWindow','width=600,height=460,resizable=yes,scrollbars=yes');
	if (!win.opener)win.opener=self;
	if (win.focus)win.focus();
}

function popWindowMap(pageURL) {
//	win=window.open("",'popWindow','width=600,height=600,resizable=yes,scrollbars=yes');
	win=window.open(pageURL,'popWindow','width=800,height=650,resizable=yes,scrollbars=yes');
	if (!win.opener)win.opener=self;
	if (win.focus)win.focus();
}

function popWindowEvent(pageURL) {
//	win=window.open("",'popWindow','width=600,height=600,resizable=yes,scrollbars=yes');
	win=window.open(pageURL,'popWindow','width=590,height=350,resizable=yes,scrollbars=yes');
	if (!win.opener)win.opener=self;
	if (win.focus)win.focus();
}

function popWindowAddMap(pageURL) {
//	win=window.open("",'popWindow','width=600,height=600,resizable=yes,scrollbars=yes');
	win=window.open(pageURL,'popWindow','width=500,height=300,resizable=yes,scrollbars=yes');
	if (!win.opener)win.opener=self;
	if (win.focus)win.focus();
}

function validateEmail(emailstr) {
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(emailstr))
		return true;
	else
		return false;
}

function getFileSize (fileName) {
  if (document.layers) {
    if (navigator.javaEnabled()) {
      var file = new java.io.File(fileName);
      if (location.protocol.toLowerCase() != 'file:')
        netscape.security.PrivilegeManager.enablePrivilege(
        'UniversalFileRead'
        );
      return file.length();
    }
    else return -1;
  }
  else if (document.all) {
    window.oldOnError = window.onerror;
    window.onerror = function (err) {
      if (err.indexOf('utomation') != -1) {
        alert('file access not possible');
        return true;
      }
      else 
        return false;
    };
    var fso = new ActiveXObject('Scripting.FileSystemObject');
    var file = fso.GetFile(fileName);
    window.onerror = window.oldOnError;
    return file.Size;
  }
}

function NoneWithCheck(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].checked) { return false; }
	}
return true;
}

function NumWithSelected(ss) {
	var j = 0;
for(var i = 0; i < ss.length; i++) {
	if(ss[i].selected) { j++; }
	}
return j;
}

function TestFileType( fileName, fileTypes ) {
if (!fileName) return;

dots = fileName.split(".")
//get the part AFTER the LAST period.
fileType = "." + dots[dots.length-1];

return (fileTypes.join(".").indexOf(fileType) != -1) ?
alert('That file is OK!') : 
alert("Please only upload files that end in types: \n\n" + (fileTypes.join(" .")) + "\n\nPlease select a new file and try again.");
}

function confirm_delete(URL,msg) {
	input_box=confirm(msg);
	if (input_box==true) { 
	// Output when OK is clicked
	window.location=URL;
	}
//else {
	// Output when Cancel is clicked
	//alert ("You clicked cancel");
	//}
}