﻿function insertFlash(elm, url, w, h) {
if (!document.getElementById(elm)) return;
var str = '';
str += '<object width="'+ w +'" height="'+ h +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">';
str += '<param name="movie" value="'+ url +'">';
//str += '<param name="wmode" value="opaque">';
str += '<param name="quality" value="autohigh">';
str += '<embed width="'+ w +'" height="'+ h +'" src="'+ url +'" quality="autohigh" wmode="opaque" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
str += '<param name="wmode" value="transparent">';
str += '</object>';
document.getElementById(elm).innerHTML = str;
}


function checkAllInput(str,obj,minlen,maxlen,patnstr,ErrorNo,ErrorName,c,d) {
  if(str==""){str=obj.value}
  
  if (str == null || str=="") {alert(" "+ErrorName+"!");obj.focus();return 1;}
  var l = str.length;
  var blen = 0;
  for(i=0; i<l; i++) {
  if ((str.charCodeAt(i) & 0xff00) != 0) {
   blen ++;
   }
   blen ++;
   }
   if ( (blen > maxlen || blen < minlen) && (minlen!=0 && maxlen!=0) ) {alert(ErrorName+"长度必须是"+minlen+"至"+maxlen+"个字符!");obj.focus();return 1;}
   if(patnstr!=""){
  var patn = patnstr;
  if(!patn.test(str)){alert(ErrorNo);obj.focus();return 1;}
  }
   return 0;
}
function checkJob(){ff=document.add;
if(ff.username.value==""){alert("请填写您的姓名!");ff.username.focus();return false;}
if(ff.jobname.value==""){alert("请填写您要应聘的工作名称!");ff.jobname.focus();return false;}
if(ff.age.value==""){alert("请填写您的年龄!");ff.age.focus();return false;}
if(ff.intro.value==""){alert("请填写您的简历!");ff.intro.focus();return false;}
//if(errno>0){return false;}
}


function checkBooking(){ff=document.add;
if(ff.RealName.value==""){alert("请填写您的姓名!");ff.RealName.focus();return false;}
if(ff.Tel.value==""){alert("请填写您的联系电话!");ff.Tel.focus();return false;}
if(ff.Mail.value==""){alert("请填写您的联系邮箱!");ff.Mail.focus();return false;}
errno=checkAllInput("",ff.RoomNo,0,0,/^[0-9]+$/,"预定房数只能是数字!","请填写预定房数",0,0)
if(errno>0){return false;}
}

function checkBookingE(){ff=document.add;
if(ff.RealName.value==""){alert("Please Enter Your Name!");ff.RealName.focus();return false;}
if(ff.Tel.value==""){alert("Please Enter Tel!");ff.Tel.focus();return false;}
if(ff.Mail.value==""){alert("Please Enter Email!");ff.Mail.focus();return false;}
errno=checkAllInput("",ff.RoomNo,0,0,/^[0-9]+$/,"BOOK Housing Error!","Please Enter BOOK Housing",0,0)
if(errno>0){return false;}
}
function checkGuest(){ff=document.Guestform;
if(ff.RealName.value==""){alert("请填写您的姓名!");ff.RealName.focus();return false;}
if(ff.Tel.value==""){alert("请填写您的联系电话!");ff.Tel.focus();return false;}
if(ff.Mail.value==""){alert("请填写您的联系邮箱!");ff.Mail.focus();return false;}
}

function checkGuestE(){ff=document.Guestform;
if(ff.RealName.value==""){alert("Please Enter Your Name!");ff.RealName.focus();return false;}
if(ff.Tel.value==""){alert("Please Enter Tel!");ff.Tel.focus();return false;}
if(ff.Mail.value==""){alert("Please Enter Email!");ff.Mail.focus();return false;}
}


function show_calendar() {
	/* 
		p_month : 0-11 for Jan-Dec; 12 for All Months.
		p_year	: 4-digit year
		p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
		p_item	: Return Item.
	*/

	var ctl = arguments[0];

	var path = "";
	
	if (arguments[1] == null)
		path = "";

	else
		path = arguments[1];

	fPopUpDlg(path + 'js/calendar.htm', ctl, 'WinCalendar', 234, 261);

	//return false;
}

function show_calendarE() {
	/* 
		p_month : 0-11 for Jan-Dec; 12 for All Months.
		p_year	: 4-digit year
		p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
		p_item	: Return Item.
	*/

	var ctl = arguments[0];

	var path = "";
	
	if (arguments[1] == null)
		path = "";

	else
		path = arguments[1];

	fPopUpDlgE(path + 'js/calendare.htm', ctl, 'WinCalendar', 234, 261);

	//return false;
}

function fPopUpDlg(endtarget, ctl, WINname, WINwidth, WINheight){
	
	showx =  WINwidth + 120  ; // + deltaX;
	showy = WINheight -50 ; // + deltaY;
	

	newWINwidth = WINwidth + 4 + 18;
	var features =
		'dialogWidth:'  + newWINwidth  + 'px;' +
		'dialogHeight:' + WINheight + 'px;' +
		'dialogLeft:'   + showx     + 'px;' +
		'dialogTop:'    + showy     + 'px;' +
		'directories:no; localtion:no; menubar:no; help:no; status=no; toolbar=no;scrollbars:yes;Resizeable=no';
	
	//alert(endtarget);
	//alert(ctl.value);
	
	retval = window.showModalDialog(endtarget, ctl, features );
	if( retval != null ){
		ctl.value = retval;
	}else{
		//alert("canceled");
	}
}

function fPopUpDlgE(endtarget, ctl, WINname, WINwidth, WINheight){
	
	showx =  WINwidth + 120  ; // + deltaX;
	showy = WINheight -50 ; // + deltaY;
	

	newWINwidth = WINwidth + 4 + 18;
	var features =
		'dialogWidth:'  + newWINwidth  + 'px;' +
		'dialogHeight:' + WINheight + 'px;' +
		'dialogLeft:'   + showx     + 'px;' +
		'dialogTop:'    + showy     + 'px;' +
		'directories:no; localtion:no; menubar:no; help:no; status=no; toolbar=no;scrollbars:yes;Resizeable=no';
	
	//alert(endtarget);
	//alert(ctl.value);
	
	retval = window.showModalDialog(endtarget, ctl, features );
	if( retval != null ){
		ctl.value = retval;
	}else{
		//alert("canceled");
	}
}
