function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}

function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}

function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}

function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

function selectTag(showContent,selfObj){

	// 操作標簽

	var tag = document.getElementById("tags").getElementsByTagName("li");

	var taglength = tag.length;

	for(i=0; i<taglength; i++){

		tag[i].className = "";

	}

	selfObj.parentNode.className = "selectTag";

	// 操作內容

	for(i=0; j=document.getElementById("tagContent"+i); i++){

		j.style.display = "none";

	}

	document.getElementById(showContent).style.display = "block";	

}

function jselectTag(showContent,selfObj){

	// 操作標簽

	var tag = document.getElementById("jtags").getElementsByTagName("li");

	var taglength = tag.length;

	for(i=0; i<taglength; i++){

		tag[i].className = "";

	}

	selfObj.parentNode.className = "jselectTag";

	// 操作內容

	for(i=0; j=document.getElementById("jtagContent"+i); i++){

		j.style.display = "none";

	}

	document.getElementById(showContent).style.display = "block";	

}

function showText(date,show_div,hidden_date_value,err_div) {

	document.getElementById(err_div).innerHTML='';

	document.getElementById(show_div).innerHTML=date;

	document.getElementById(hidden_date_value).value=date;

}

function money_search(){

difference=CountIssueDays(document.getElementById('start_search_date').value,document.getElementById('end_search_date').value);

if (document.getElementById('start_search_date').value=='') {

	document.getElementById('err_start_div').innerHTML="住房日期未選擇";

	return false;

} else if(document.getElementById('end_search_date').value=='') {

	document.getElementById('err_end_div').innerHTML="退房日期未選擇";

	return false;

} else if (difference >= 7) {

	document.getElementById('show_start_Div').innerHTML='';

	document.getElementById('show_end_Div').innerHTML='';

	alert ('您選擇的日期範圍過大，請重新選擇');

	return false;

} else if ((document.getElementById('start_search_date').value)>(document.getElementById('end_search_date').value)) { 

	alert ('住房日期大於退房日期，請重新選擇');

	return false;

}else {

	url='./search/index.php?do=quick_search_room&start_search_date='+document.getElementById('start_search_date').value;

	url+='&end_search_date='+document.getElementById('end_search_date').value;

	url+='&add_a='+document.getElementById('add_a').value;

	url+='&add_b='+document.getElementById('add_b').value;

	url+='&sort='+document.getElementById('sort').value;

	url+='&room_num='+document.getElementById('room_num').value;

	window.location.href=url;

	return true;

}

}

function money_day_search(v){

		var url_go;

if (document.getElementById('day_search_date').value=='') {

	document.getElementById('err_day_div').innerHTML="搜尋日期未選擇";

	return false;

} else {

	url='/hotel/search/index.php?do=quick_search_room_day&day_search_date='+document.getElementById('day_search_date').value;

	url+='&add_a='+document.getElementById('add_a_day').value;

	//url+='&add_b='+document.getElementById('add_b_day').value;

	url+='&add_b=0';

	url+='&sort='+document.getElementById('sort_day').value;

	url+='&room_num='+document.getElementById('room_num_day').value;

	url+='&room_person='+document.getElementById('room_person').value;

        if(v)

            window.open(url,'newwin');

        else

            window.location.href=url;

	return true;

}

}

function CountIssueDays(strIssueDate,strMaturityDate) { 

var aDate;

aDate1 = [strIssueDate.substring(0,4),strIssueDate.substring(5,7),strIssueDate.substring(8,10)];

aDate2 = [strMaturityDate.substring(0,4),strMaturityDate.substring(5,7),strMaturityDate.substring(8,10)];

    var difference = Date.UTC(aDate2[0],aDate2[1],aDate2[2],0,0,0)

                   - Date.UTC(aDate1[0],aDate1[1],aDate1[2],0,0,0) 

    return difference/1000/60/60/24; 

}

function money_clear() {

	document.getElementById('show_start_Div').innerHTML='';

	document.getElementById('show_end_Div').innerHTML='';

	return true;

}

function money_day_clear() {

	document.getElementById('show_day_Div').innerHTML='';

		document.getElementById('show_day_Div').innerHTML="搜尋日期未選擇";

	document.getElementById('day_search_date').value='';

	return true;

}


