function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase();

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1);
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1);
   this.isIcab        = (ua.indexOf('icab') != -1);
   this.isAol         = (ua.indexOf('aol') != -1);
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) );
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );

   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);

   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );

   // browser version
   this.versionMinor = parseFloat(navigator.appVersion);

   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }

   this.versionMajor = parseInt(this.versionMinor);

   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);

   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);

   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);

   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);

   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetect();

function is_number(form, note)
{

	if ((isNaN(form.value)) || (form.value<=0))
	{ window.alert(note); form.select();form.focus(); return false; }
 }
function change_room(val, i) {
	if (!isNaN(document.form1.elements['RoomBL3[' + i + ']']) || document.form1.elements['RoomBL3[' + i + ']']) {
		document.form1.elements['RoomBL3[' + i + ']'].value = val;
	}
}
var str, str3,str2;



	var strISDN = '<td class="base" align="right" valign="top">MAXIMUM BANDWIDTH ISDN:&nbsp;<br></td>'+
                            '<td class="base" valign="top">'+
		                        '<input type=\'checkbox\' name=\'ISDN_Data_rate[1]\' value="56K" %%ISDN_Data_rate56K%% onclick="not_available(this)">56K<br>'+
								'<input type=\'checkbox\' name=\'ISDN_Data_rate[2]\' value="64K" %%ISDN_Data_rate64K%% onclick="not_available(this)">64K<br>'+
								'<input type=\'checkbox\' name=\'ISDN_Data_rate[3]\' value="112K" %%ISDN_Data_rate112K%% onclick="not_available(this)">112K<br>'+
								'<input type=\'checkbox\' name=\'ISDN_Data_rate[4]\' value="128K" %%ISDN_Data_rate128K%% onclick="not_available(this)">128K<br>'+
								'<input type=\'checkbox\' name=\'ISDN_Data_rate[5]\' value="256K" %%ISDN_Data_rate256K%% onclick="not_available(this)">256K<br>'+
								'<input type=\'checkbox\' name=\'ISDN_Data_rate[6]\' value="336K" %%ISDN_Data_rate336K%% onclick="not_available(this)">336K<br>'+
								'<input type=\'checkbox\' name=\'ISDN_Data_rate[7]\' value="384K" %%ISDN_Data_rate384K%% onclick="not_available(this)">384K<br>'+
								'<input type=\'checkbox\' name=\'ISDN_Data_rate[8]\' value="448K" %%ISDN_Data_rate448K%% onclick="not_available(this)">448K<br>'+
								'<input type=\'checkbox\' name=\'ISDN_Data_rate[9]\' value="512K" %%ISDN_Data_rate512K%% onclick="not_available(this)">512K<br>'+
								'<input type=\'checkbox\' name=\'ISDN_Data_rate[10]\' value="768K" %%ISDN_Data_rate768K%% onclick="not_available(this)">768K<br>'+
								'<input type=\'checkbox\' name=\'ISDN_Data_rate[11]\' value="1.544Mb" %%ISDN_Data_rate1544Mb%% onclick="not_available(this)">1.544Mb<br>'+
								'<input type=\'checkbox\' name=\'ISDN_Data_rate[12]\' value="Other" %%ISDN_Data_rateOther%% onclick="not_available(this)">Other<br>'+
		                '</td>';
	var strIP = '<td class="base" align="right" valign="top">MAXIMUM BANDWIDTH IP:&nbsp;<br></td>'+
                            '<td class="base" valign="top" >'+
		                        '<input type=\'checkbox\' name=\'Highest_IP_Data_rate[1]\' value="56K" %%Highest_IP_Data_rate56K%%>56K<br>'+
								'<input type=\'checkbox\' name=\'Highest_IP_Data_rate[2]\' value="64K" %%Highest_IP_Data_rate64K%%>64K<br>'+
								'<input type=\'checkbox\' name=\'Highest_IP_Data_rate[3]\' value="112K" %%Highest_IP_Data_rate112K%%>112K<br>'+
								'<input type=\'checkbox\' name=\'Highest_IP_Data_rate[4]\' value="128K" %%Highest_IP_Data_rate128K%%>128K<br>'+
								'<input type=\'checkbox\' name=\'Highest_IP_Data_rate[5]\' value="256K" %%Highest_IP_Data_rate256K%%>256K<br>'+
								'<input type=\'checkbox\' name=\'Highest_IP_Data_rate[6]\' value="336K" %%Highest_IP_Data_rate336K%%>336K<br>'+
								'<input type=\'checkbox\' name=\'Highest_IP_Data_rate[7]\' value="384K" %%Highest_IP_Data_rate384K%%>384K<br>'+
								'<input type=\'checkbox\' name=\'Highest_IP_Data_rate[8]\' value="448K" %%Highest_IP_Data_rate448K%%>448K<br>'+
								'<input type=\'checkbox\' name=\'Highest_IP_Data_rate[9]\' value="512K" %%Highest_IP_Data_rate512K%%>512K<br>'+
								'<input type=\'checkbox\' name=\'Highest_IP_Data_rate[10]\' value="768K" %%Highest_IP_Data_rate768K%%>768K<br>'+
								'<input type=\'checkbox\' name=\'Highest_IP_Data_rate[11]\' value="1.544Mb" %%Highest_IP_Data_rate1544Mb%%>1.544Mb'+
		                '</td>';
	var strISDN2 = '<td class="base" align="right">ISDN #\'S:</td>'+
                            '<td class="base"><input  name="Phone" value="" type=text class=base size="40" ><br><input  name="Phone" value="" type=text class=base size="40" ></td></tr>'
							;
	var strIP2 = '<td class="base" align="right">IP ADDRESS:</td>'+
                            '<td class="base"><input type=\'text\' size="3" class="base" onchange="return test_ip(this)"  maxlength="3">.<input type=text size="3" class="base" onchange="return test_ip(this)"  maxlength="3">.<input type=\'text\' size="3" class="base" onchange="return test_ip(this)"  maxlength="3">.<input type=\'text\' size="3" class="base" onchange="test_ip(this)" maxlength="3"></td>';



function test_img(form) {
	  if (form.value.length !=0) {
            var num = form.value.lastIndexOf(".");
            var pattern1 = /gif/gi;
            var pattern2 = /jpg/gi;
            var pattern3 = /jpeg/gi;
            var pattern4 = /png/gi;
            if ( num >0) {
                var ras = form.value.substr(num+1);
               // alert (pattern1.test(ras) || pattern2.test(ras) || pattern3.test(ras) || pattern4.test(ras));
                if (!(pattern1.test(ras) || pattern2.test(ras) || pattern3.test(ras) || pattern4.test(ras))){
                    window.alert("Please specify gif, jpg or png file.")
                    form.focus()
                    form.select()
                    return false;
                }

            } else {

             window.alert("Your path is invalid!" + '\n' + "Please type in valid path.")
             form.focus()
             form.select()
             return false;
            }


           }
}

var BR = new GetBrowser();
		var TimeOut=300;

        // Get browser
        function GetBrowser() {
            this.NS4 = (document.layers) ? true : false;
        	this.IE4 = (document.all && !document.getElementById) ? true : false;
        	this.IE5 = (document.all && document.getElementById) ? true : false;
        	this.IE6 = (document.all && document.getElementById) ? true : false;
        	this.IE7 = (document.all && document.getElementById) ? true : false;
        	this.IE8 = (document.all && document.getElementById) ? true : false;
        	this.NS6 = (!document.all && document.getElementById) ? true : false;

            return this;
        }

function upword (str) {
	var first = str.substr(0,1);
	var second = str.substr(1);
	str = first.toUpperCase( )+second;
	return str;


}

function TextTidy(VALUE){
var STRING = VALUE;
var strReturn_Value = "";
var iTemp = STRING.length;
if(iTemp==0){
return"";
}

var stri = " i ";
var strI = " I ";

while(STRING.indexOf(stri) > -1){
STRING = STRING.replace(stri,strI);
}

while(STRING.indexOf("  ") > -1){
STRING = STRING.replace("  "," ");
}

var UcaseNext = false;
strReturn_Value += STRING.charAt(0).toUpperCase();

for(var iCounter=1;iCounter < iTemp;iCounter++){
if(UcaseNext == true){
strReturn_Value += STRING.charAt(iCounter).toUpperCase();
}
else{
strReturn_Value += STRING.charAt(iCounter);
}
var iChar = STRING.charCodeAt(iCounter);
if(iChar == 46 || iChar == 33 || iChar == 63){
	if(STRING.charCodeAt(iCounter+1)==32){
	strReturn_Value += (STRING.substring(iCounter+1,iCounter+2)) + " ";
	iCounter+=1;
	}

	UcaseNext = true;

}
else if(iChar==13 && STRING.charCodeAt(iCounter+1)==10){
	iCounter+=1;
	//Comment out the next line if you want to stop capitalization on a new line
	UcaseNext = true;
}
else if(iChar==44 && STRING.charCodeAt(iCounter+1)!=32){
strReturn_Value += (STRING.substring(iCounter,iCounter)) + " ";
}
else{
UcaseNext = false
}
if(iChar == 99 || iChar == 67){
if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109){
UcaseNext = true;
}
}


} //End For

return strReturn_Value;
} //End Function


function PCase(STRING){
var strReturn_Value = "";
var iTemp = STRING.length;
if(iTemp==0){
return"";
}
var UcaseNext = false;
strReturn_Value += STRING.charAt(0).toUpperCase();
for(var iCounter=1;iCounter < iTemp;iCounter++){
if(UcaseNext == true){
strReturn_Value += STRING.charAt(iCounter).toUpperCase();
}
else{
strReturn_Value += STRING.charAt(iCounter).toLowerCase();
}
var iChar = STRING.charCodeAt(iCounter);
if(iChar == 32 || iChar == 45 || iChar == 46){
UcaseNext = true;
}
else{
UcaseNext = false
}
if(iChar == 99 || iChar == 67){
if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109){
UcaseNext = true;
}
}


} //End For

return strReturn_Value;
} //End Function


function upcase(form) {
	form.value=PCase(form.value);
}

function test_ip(form) {
					var flag=1;
					if (isNaN(form.value)) {
						flag = 0;
					} else {
						if ((form.value >255) || (form.value < 0)) {
							flag = 0;
						}
					}
					if (!flag) {
						window.alert("Invalid type IP ADDRESS");
						form.select();
						form.focus();
						return false;
					}
				}

function test_code(form){

    var pattern=/[^0-9 -]/;
    if (pattern.test(form.value)) {
        window.alert('Please type in valid code');
        form.focus();
        form.select();
        return false;


    }
}
var maxleng = 900;
    var fulltext='';
    function changetxt()
    {
	var form=document.form1;
     var txt = form.elements["featured"];
     var txtleng = txt.value.length;
     if (txtleng < maxleng){
      form.elements["len"].value = (maxleng - txtleng);
      txt.focus();
      if (txt.value=='') form.elements["len"].value = maxleng;
      if(fulltext){fulltext = ''}
     }else{
      if(!fulltext) fulltext = txt.value.substring(0,maxleng);
      txt.value = fulltext;
      form.elements["len"].value = '0';
     }
}

function minchar(form, num) {
	if (form.value.length<num) {
		alert("Min characters "+num);
		form.select();
		return false;
	}
}
function test_phone(form) {
	if ((form.value=='Telephone') || (form.value=='Area Code') || (form.value=='City Code')) {
		form.value='';
	}
}

function test_auto_field(form) {
	if (form.value.indexOf('Videoconference room', 0) != -1) {
		form.value='';
	}
}


function Show(Name, MenuStr, how) {
			var content='';
			var p = /~~~~/;
			var pos;
			var form = document.form1;
			var khow = Number(how)+1;
//			alert('khow'+khow);
			if (MenuStr == 'BL2') {
				for (var i=2; i<=khow; i++) {
					var t = i+2;
//					alert(i);
					content += arr_BL2[i];
				}
			} else if (MenuStr == 'BL3') {

				for (var i=2; i<=khow; i++) {
					var t = i+2
					content +=arr_BL3[i];

				}
			} else {
				for (var i=0; i<how; i++) {
					content += MenuStr;
				}
			}

           if (BR.IE4 || BR.IE5) {
                obj = document.all['lr'+ Name];

				obj.innerHTML = content;


           } else if (BR.NS4) {

				obj = document.layers['lr'+Name];
				 obj.document.open();
				 obj.document.write(content);
				 obj.document.close();

           }else if (BR.NS6) {
                   obj = document.getElementById("lr"+Name);
                   obj.innerHTML = content;
           }
         }
function wopen_exs(url, var_width, var_heigth){

	var vleft = Math.round(window.screen.width/2-var_width/2);
	var vtop = Math.round(window.screen.height/2-var_heigth/2);
	//nw=window.open('','ficha','');
	nw=window.open('','ficha','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+var_width+',height='+var_heigth+',top='+vtop+',left='+vleft);

	nw.location=url;
}

function install_element(val, type_val, name_val) {

	var gend=val;
	var obj = document.form1;
	var i = 0;
	if (gend != '') {
		while (obj.elements[i]){
           if ((obj.elements[i].type == type_val) && (obj.elements[i].name == name_val) ){
              if (obj.elements[i].value == gend) {
			  	obj.elements[i].click();
			   }
           }

           ++i;
        }
	}
}

function make_selected(box, val)
{
  for(i = 1; i < box.options.length; i++)
  {
    if(box.options[i].value == val)
      box.options[i].selected = true;
  }
}
    function fCheckAll(){
            i = 0;
            while (document.form1.elements[i]){
               if ((document.form1.elements[i].type == 'checkbox') && (document.form1.elements[i].name != 'checkall') ){
                  if (document.form1.checkall.checked != document.form1.elements[i].checked)
                  document.form1.elements[i].click();
               }

               ++i;
            }
            return true;
        }


  function Hidden(str)
	{
	 this.value=str;
	}
 function ltrim ( s )
  {
      return s.replace( /^\s*/, "" );
  }

  function rtrim ( s2 )
  {
      return s2.replace( /\s*$/, "" );
  }

  function trim ( s )
  {
      return rtrim(ltrim(s));
  }


function obj_focus(obj, message) {
	alert(message);
	obj.focus();
}


function obj_select(obj, message) {
	alert(message);
	obj.focus();
	obj.select();
}
function eval_frame_scripts(html) {
	setTimeout(function() {html.evalScripts()}, 10);
}

function is_date (val) {
    regular = new RegExp("^([0-9]){1,2}-([0-9]){1,2}-([0-9]){4}\$");
     return regular.test(trim(val));
}
function validatedate_m(m,d,y,desc)
{

    var msg = "";
    if (m<1 || m>12) {
         msg=desc+" is not a valid date";
         return msg;
    }

    var date = new Date(y, m, 0);

    var last_day = date.getDate();
    if(d>last_day)
    {
        msg=desc+" is not a valid date";
    }

    return msg;
}

function test_data (obj) {
	if (obj.value !='') {
			if (!is_date(obj.value)) {
				 obj_select(obj, "Wrong date format.");
		        return false;
			}
			var str = new String (trim(obj.value));

			var a1 = str.split("-");
			var msg = validatedate_m(a1[0],a1[1],a1[2],'Answer');
			 if (msg!='') {
		        obj_focus(obj, msg);
		        return false;
		     } else return true;
		} else return true;
}

function set_data_answer(val) {
	if (val == 'Month and year of birth') {
		Show('234', '<a href="javascript:show_calendar(\'document.form1.security_answer\', document.form1.security_answer.value);"><img src="../images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a>', 1);
	} else {
		Show('234', '', 1);
	}
}