//Regexp for testing email addy validity
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
var tld = '';

function CkContactForm(){


	 if (document.frm22.name.value.length <= 0){
	 alert('Please enter your name.');
	 document.frm22.name.focus();
	 return false;
	 }  
	 if (document.frm22.co.value.length <= 0){
	 alert('Please enter your company\'s name.');
	 document.frm22.co.focus();
	 return false;
	 }  
	 if (!re.test(document.frm22.email.value)){
	 alert('Please enter a valid email address.');
	 document.frm22.email.focus();  
	 return false;
     }
     if (document.frm22.ques.value.length <= 0) {
         alert('Please enter a request or question.');
         document.frm22.ques.focus();
         return false;
     }  
     
     if (document.frm22.code.value != document.frm22.codegen.value) {
         alert('Please enter the correct code.');
         document.frm22.code.focus();
         return false;
     }
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// Jump menu mods that open new browser window for external files/pages
function MM_jumpMenuNewWindow(targ,selObj,restore){ //v3.0
  var s = selObj.options[selObj.selectedIndex].value;
  window.open(s);
  if (restore) selObj.selectedIndex=0;
}

var dialogWin = new Object()
var Nav4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))

//args "scrollbars=yes,location=yes,menubar=yes,resizable=yes,toolbar=yes"  
function openDialog(url, width, height, returnFunc, args) {
    if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) {
        // Initialize properties of the modal dialog object.
        dialogWin.returnFunc = returnFunc
        dialogWin.returnedValue = ""
        dialogWin.args = args;
        dialogWin.url = url
        dialogWin.width = width
        dialogWin.height = height
        // Keep name unique so Navigator doesn't overwrite an existing dialog.
        dialogWin.name = (new Date()).getSeconds().toString()
        // Assemble window attributes and try to center the dialog.
        if (Nav4) {
            // Center on the main window.
            dialogWin.left = window.screenX +
			       ((window.outerWidth - dialogWin.width) / 2)
            dialogWin.top = window.screenY +
			       ((window.outerHeight - dialogWin.height) / 2)
            var attr = "screenX=" + dialogWin.left +
			       ",screenY=" + dialogWin.top + ",width=" +
			       dialogWin.width + ",height=" + dialogWin.height + "," + args;
        }
        else {
            // The best we can do is center in screen.
            dialogWin.left = (screen.width - dialogWin.width) / 2
            dialogWin.top = (screen.height - dialogWin.height) / 2
            var attr = "left=" + dialogWin.left + ",top=" +
			       dialogWin.top + ",width=" + dialogWin.width +
			       ",height=" + dialogWin.height + "," + args;
        }

        // Generate the dialog and make sure it has focus.
        dialogWin.win = window.open(dialogWin.url, dialogWin.name, attr)
        dialogWin.win.focus()
    }
    else {
        dialogWin.win.focus()
    }

}


function editHtml(page) {
    var editObj = document.getElementById('page-content');
    openDialog('Edit.aspx?page=' + page, 800, 600, 'edit', "scrollbars=yes,location=no,menubar=no,resizable=yes,toolbar=no");
}

function doSearch() {

    var objText = document.forms[1]['q'];
    if (objText == null)
        objText = document.forms[0]['q'];

    var input = objText.value;
    
    if (input != 'Enter keywords')
        document.location = 'search.aspx?q=' + escape(input);
    else
        alert('Please enter some search text.');    
}
