//------------------------------------------------------------------------- // Copyright 2005, Infrant Technologies, Inc. // All rights reserved. //------------------------------------------------------------------------- function valid_host( value ) { if( (value == "") || (valid_ip(value)) || (valid_hostname(value)) ) { return true; } return false; } function valid_key( value ) { var re = /[a-fA-F0-9]+/g; if( value == "xxxxxxxxxxxx" ) { return true; } if( value.length == 0 ) { return false; } if( value.replace(re, "") == "" ) { return true; } return false; } function valid_hostname( name, netbios ) { var re = /[a-zA-Z0-9\-\._]/g; var re2 = /[\-\.]/g; var max_hostpart_length = 63; if( netbios ) { max_hostpart_length = 15; } if( (name.replace(re, "") == "") && (name.replace(re2, "" ) != "") ) { var parts = name.split('.'); if( parts[0].length > max_hostpart_length ) { return false; } for( var i = 1; i < parts.length; i++ ) { if( parts[i].length > 63 ) { return false; } } return true; } return false; } function valid_vlan_tag( tag ) { var re = /[0-9]/g; var max = 65535; if( (tag.replace(re, "") == "") && (tag > 0) && (tag <= max) ) { return true; } return false; } function valid_path( name ) { var re = /[a-zA-Z0-9\-_\\\/\%\.\$: ]/g; var re_dotdot = /\.\./; if( (name.replace(re, "") == "") && !re_dotdot.test(name) ) { return true; } return false; } function valid_share_name( name ) { var re = /[a-zA-Z0-9\-_]/g; var re2 = /[\-\._]/g; if( (name.replace(re, "") == "") && (name.replace(re2, "" ) != "") ) { return true; } return false; } function valid_workgroup( name ) { var re = /[a-zA-Z0-9\-_\.]/g; var re2 = /[\-\._]/g; if( (name.replace(re, "") == "") && (name.replace(re2, "" ) != "") && (name.length <= 15 ) ) { return true; } return false; } function valid_domain( name ) { var re = /[a-zA-Z0-9\-_\.\+]/g; var re2 = /[\-_]/g; if( (name.replace(re, "") == "") && (name.replace(re2, "" ) != "") ) { return true; } return false; } function valid_network( address ) { var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; if( address == "" ) { return false; } if( re.test(address) ) { var segs = address.split("."); if( parseInt(parseFloat(segs[3])) != 0 ) { return false; } for( var i = 0; i < (segs.length - 1); i++ ) { if( (parseInt(parseFloat(segs[i])) > 254) || (parseInt(parseFloat(segs[i])) < 1 ) ) { return false; } } return true; } return false; } function valid_ip( address, empty_ok ) { var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; if( (empty_ok) && (address == "") ) { return true; } if( re.test(address) ) { var segs = address.split("."); if( parseInt(parseFloat(segs[0])) == 0 ) { return false; } for( var i = 0; i < segs.length; i++ ) { if( parseInt(parseFloat(segs[i])) > 255 ) { return false; } } if(( parseInt(parseFloat(segs[0])) < 1 ) || ( parseInt(parseFloat(segs[3])) < 1 )) { return false; } return true; } return false; } function valid_netmask( address ) { var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; if( re.test(address) ) { var segs = address.split("."); if( parseInt(parseFloat(segs[0])) == 0 ) { return false; } for( var i = 0; i < segs.length; i++ ) { if( parseInt(parseFloat(segs[i])) > 255 ) { return false; } } return true; } return false; } function valid_email( address ) { 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,}))$/ return re.test(address); } function valid_quota( value ) { if( isNaN(value) || (value < 0) ) { return false; } return true; } function valid_integer( value ) { if( isNaN(value) || ((value % 1) != 0) ) { return false; } return true; } function valid_pos_integer( value ) { if( isNaN(value) || (value < 0) || ((value % 1) != 0) ) { return false; } return true; } function valid_user_group( name ) { var re = /[a-zA-Z0-9\-_\.@]/g; var re2 = /[\-_@]/g; if( (name == "") || (name == "shares") ) { return false; } else if( (name.replace(re, "") == "") && (name.replace(re2, "" ) != "") ) { return true; } return false; } function valid_cifs_path( value ) { var re = /[a-zA-Z0-9\-\._\\\/]/g; if( value == "" ) { return false; } else if( value.replace(re, "") == "" ) { return true; } return false; } function valid_http_ftp_path( value ) { var re = /[a-zA-Z0-9\-\._\/\%:]/g; if( value == "" ) { return false; } else if( (value.indexOf('ftp://') == 0) || (value.indexOf('http://') == 0) ) { if( value.replace(re, "") == "" ) { return true; } } return false; } function valid_folder( value ) { var re = /[a-zA-Z0-9\-\._\/]/g; if( value == "" ) { return false; } else if( value.replace(re, "") == "" ) { return true; } return false; } function convert_cifs_path( value ) { var re = /[\\]/g; return value.replace(re, "/"); } function GetEmailAddr( this_form, emailaddr, promptmsg, errormsg ) { emailaddr.value = prompt(promptmsg, ""); if( (emailaddr.value != "null") && (emailaddr.value != "") ) { if( !valid_email(emailaddr.value) ) { alert(errormsg); return false; } Submit(this_form); } } function ShowAlert( alertmsg ) { if( alertmsg ) { alert(alertmsg); } } function ShowHelp( title, theme, helpmsg ) { if( helpmsg ) { var HelpWindow = window.open("", "", "width=800, height=500, scrollbars"); var Content; Content = "\n"; Content += "" + title + "\n"; Content += "\n"; Content += "\n"; Content += "\n"; Content += "" + title + "

"; Content += "" + helpmsg + ""; Content += "\n"; Content += ""; HelpWindow.document.write(Content); HelpWindow.document.close(); } } function ShowPopup( title, theme, msg ) { if( msg ) { var DialogWindow = window.open("", "", "width=400, height=300, scrollbars"); var Content; Content = "\n"; Content += "" + title + "\n"; Content += "\n"; Content += "\n"; Content += "\n"; Content += "" + title + "

"; Content += msg; Content += "\n"; Content += ""; DialogWindow.document.write(Content); DialogWindow.document.close(); } } function goto_menu( this_form, menu, tab, confirm_msg ) { if( (this_form.MODIFIED.value == 0) || confirm(confirm_msg) ) { this_form.MODIFIED.value = 0; this_form.NEXTPAGE.value = menu; this_form.button.value = 'Next'; this_form.CURRENTTAB.value = tab; this_form.CURRENTINDEXPAGE.value = 0; Submit(this_form); } } function goto_tab( this_form, tab_param, tab_value, ignore_modified, confirm_msg ) { if( (this_form.MODIFIED.value == 0) || ignore_modified || confirm(confirm_msg) ) { this_form.MODIFIED.value = 0; this_form.CURRENTINDEXPAGE.value = 0; tab_param.value = tab_value; this_form.button.value = 'Current'; Submit(this_form); } } function Submit( this_form ) { for( var i = 0; i < this_form.elements.length; i++ ) { if( this_form.elements[i].type == "button" ) { this_form.elements[i].onclick = ""; } } this_form.submit(); } function auto_refresh( this_form ) { if( this_form.MODIFIED.value == 0 ) { this_form.command.value='Refresh'; this_form.button.value='Current'; Submit(this_form); } } function hideWaitMsg() { if (document.getElementById) { document.getElementById("waitPage").style.visibility = "hidden"; } else if (document.layers) { document.layers["waitPage"].visibility = "hide"; } else { document.all.waitPage.style.visibility = "hidden"; } }