//	SWG Menu Code
//	SWG Content Mangement System 2.0
//	Copyright © 2005 Super Web Group.  All Rights Reserved.
//	info@superwebgroup.com

function pop(vURL,w,h) {
	var temp_url = vURL;
	var new_win = window.open(temp_url, "pop"+w+h, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+w+',height='+h+',left=0,top=0,alwaysRaised=yes');
	new_win.focus();
}

function external_site(vURL) {
	var temp_url = "externalsite.asp?URL="+vURL;
	var new_win = window.open(temp_url, "pop_external", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=950,height=750,left=0,top=0,alwaysRaised=yes');
	new_win.focus();
}

function logout() {
	if (confirm('Are you sure you want to Sign Out?')){
		top.location = 'logout.asp';
	}
}

function date_check(m, d, y) {
	if (isNaN(m) || isNaN(d) || isNaN(y)) return false;
	if (m < 1 || m > 12 || d < 1 || d > 31 || y < 2000) return false;
	if ((m == 4 || m == 6 || m == 9 || m == 11) && (d > 30)) return false;
	if (m == 2) {
		if (y % 4 == 0) {
			if (d > 29) return false;
		} else {
			if (d > 28) return false;
		}
	}
	return true;
}

function check_search() {
	form = document.search_form;
	if (form.SiteSearchTerm.value == '' || form.SiteSearchTerm.value == 'type keyword here') {
		alert('Please enter a search term and then try again.');
		return false;
	} else {
		return true;
	}
}

function DisplayMail(Server, Login, Subject, Display){
	if (Subject.length >= 1){Subject = "?Subject="+escape(Subject)};
	if ((Display.length == 0) || (Display.indexOf('@')+1)) {
	document.write("<A HREF=" + "'mai" + "lto:" + Login + "@" + Server + Subject + "'>" + Login + "@" + Server + "</A>"); 
	} else  {
	document.write("<A HREF=" + "'mai" + "lto:" + Login + "@" + Server + Subject + "'>" + Display + "</A>"); 
	}
}

function ViewPDF(pdfurl){
	var temp_url = pdfurl;
	var new_win = window.open(temp_url, "pdf", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=600,left=0,top=0,alwaysRaised=yes');
	new_win.focus();
}

function SwapContent(fromdiv,todiv){
	if (document.getElementById)
	{
	   document.getElementById(todiv).innerHTML = document.getElementById(fromdiv).innerHTML;
	}
	else if (document.all)
	{
	   document.all[todiv].innerHTML = document.all[fromdiv].innerHTML;
	}
	else if (document.layers)
	{
	   if (document.layers[fromdiv])
	   {
	   	document.layers[todiv].innerHTML = document.layers[fromdiv].innerHTML;
	   }
	}
 }

function PrintTips() {
window.open ('PrintTips.asp', 'newwindow', config='height=400, width=600, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')
}
 
function PrintReady(id){
	var temp_url = 'print.asp?ID='+id;
	var new_win = window.open(temp_url, 'printpage', 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=650,height=650,alwaysRaised=yes');
	new_win.focus();
}
function PrintReadyMatrix(id){
	var temp_url = 'printMatrix.asp?ID='+id;
	var new_win = window.open(temp_url, 'printpage', 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=650,height=650,alwaysRaised=yes');
	new_win.focus();
}
function PrintArticle(id){
	var temp_url = 'printarticle.asp?ID='+id;
	var new_win = window.open(temp_url, 'printpage', 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=650,height=650,alwaysRaised=yes');
	new_win.focus();
}
  
function printpage(){
 	if (is_mac && is_ie){
		alert("We are sorry, but your browser does not support this command. You must select the File menu's Print command instead.");
	} else {
	   window.print();
	}
}

function DivPosition(div,mody,modx)
{
	var x = new getObj(div);
	if (mody != ''){ 
		x.style.top = mody + 'px';
	}
	if (modx != ''){ 
		x.style.left = modx + 'px';
	}
}

function isDate(dateStr) {
    var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
    var matchArray = dateStr.match(datePat); // is the format ok?
    if (matchArray == null) {
        return false;
    }
    month = matchArray[1]; // p@rse date into variables
    day = matchArray[3];
    year = matchArray[5];
    if (month < 1 || month > 12) { // check month range
    return false;
    }
    if (day < 1 || day > 31) {
        return false;
    }
    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
        return false;
    }
    if (month == 2) { // check for february 29th
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
        return false;
    }
    }
    return true; // date is valid
}
function isNumeric(sText){
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

function isPhoneNumber(s){
     if (s.substr(s.length - 1, 1) == "."){
        s = s.substr(0, s.length - 1);
     }
     rePhoneNumber = new RegExp(/^1?[-\. ]?(\(\d{3}\)?[-\. ]?|\d{3}?[-\. ]?)?\d{3}?[-\. ]?\d{4}$/); 
     if (!rePhoneNumber.test(s)) {
          return false;
     }
    return true;
}

function isEmailAddress(s){
    return (s.indexOf(".") > 2) && (s.indexOf("@") > 0);
}