// JavaScript Document
function checkQuickSearchForm(form) {
	if (form.freetxt.value.length < 1) {
		if ((form.id_district.selectedIndex==0) &&
			((form.id_region.selectedIndex==0) |
			(form.id_region.selectedIndex==15) |
			(form.id_region.selectedIndex==29) |
			(form.id_region.selectedIndex==41) |
			(form.id_region.selectedIndex==48)) &&
			(form.id_cuisine.selectedIndex==0)
			) {
			alert ("請選擇至少一項或輸入至少一個中文或英文字");

			return false;
		} else {
			return true;
		}
	} else {
		return true;
	}
}

function checkAndSubmitSearchForm() {
	if (checkForm()) {
		document.restsearch.submit()
	} else {
		return false;
	}
}

function checkForm() {
	if (document.restsearch.freetxt.value.length < 1) {
		if ((document.restsearch.id_district.selectedIndex==0) &&
			((document.restsearch.id_region.selectedIndex==0) |
			(document.restsearch.id_region.selectedIndex==15) |
			(document.restsearch.id_region.selectedIndex==29) |
			(document.restsearch.id_region.selectedIndex==41) |
			(document.restsearch.id_region.selectedIndex==48)) &&
			(document.restsearch.id_cuisine.selectedIndex==0) &&
			(document.restsearch.amount.selectedIndex==0) &&
			(document.restsearch.id_topic.selectedIndex==0)
//			&& (document.restsearch.delivery.selectedIndex==0)
			) {
			alert ("請選擇至少一項或輸入至少一個中文或英文字");
		
			return false;
		} else {
			return true;
		}
	} else {
		return true;
	}
}


function fbs_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),
		'sharer',
		'toolbar=0,status=0,width=626,height=436');
	return false;
}
function facebook_onlogin_ready() {
	location.reload();
}


//鼠标置顶出导航//
function showElement(elementId)
{
  document.getElementById(elementId).style.display="block";
}
function hideElement(elementId)
{
  document.getElementById(elementId).style.display="none";
}
//鼠标置顶出导航//
function openShowWeddingImagesFrom(id,type) {
	var url = "wedding-guide.php?action_type=showimages&type=" + type+"&id=" + id;
	window.open (url, "", "height=500,width=680,top=100, left=160,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}

function openWeddingDetailFrom(wedding_id) {
	var url = "wedding-guide.php?action_type=detail&openFrom=Y&wedding_id=" + wedding_id;
	window.open (url, "", "height=500,width=840,top=100, left=160,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}

function changeTab(items, selectedIndex)
{
	for (i = 0; i < items.length; i++) {
		if (i == selectedIndex) {
			document.getElementById(items[i]).style.display = "block";
			document.getElementById(items[i] + "_title").className = "selected";
		} else {
			document.getElementById(items[i]).style.display = "none";
			document.getElementById(items[i] + "_title").className = "";
		}
	}
}

function popWindow(pageURL) {
	win=window.open(pageURL,'popWindow','width=600,height=600,resizable=yes,scrollbars=yes');
	win=window.open(pageURL,'popWindow','width=390,height=380');
	if (!win.opener)win.opener=self;
	if (win.focus)win.focus();
}

function popWindowReview(pageURL) {
	win=window.open("",'popWindow','width=900,height=600,resizable=yes,scrollbars=yes');
	win=window.open(pageURL,'popWindow','width=900,height=380');
	if (!win.opener)win.opener=self;
	if (win.focus)win.focus();
}

function validateInput() {
   username = document.forgotpass.username; 
   if( username.length() == 0) { 
      alert( "Please enter a valid username" );
      username.focus();
      return false;
   } 
   email = document.forgotpass.email; 
   if( email.value.indexOf( "@" ) == -1 ) { 
      alert( "Please enter a valid e-mail address.\nYour new password will be e-mailed to you on this address." );
      email.focus();
      return false;
   } 
   return false;
}

function popVideo(pageURL) {
	win=window.open(pageURL,'popWindow','width=450,height=450,resizable=yes,scrollbars=no');
	if (!win.opener)win.opener=self;
	if (win.focus)win.focus();
}


function loadajaxpage(url, containerid) {
	var req = false;
	if (window.XMLHttpRequest) {// if Mozilla, Safari etc
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // if IE
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
			}
		}
	} else {
		return false;
	}

	req.onreadystatechange = function() {
		if (req.readyState == 4 && req.status == 200) {
			var container = document.getElementById(containerid);
			container.innerHTML = req.responseText;
		}
	}
	try {
		req.open('GET', url, true);
		req.send(null);
	} catch (e) {
	}
}




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_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_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];}
}