// JavaScript Document

//居中視窗
function centerWindow(theURL,winName,width,height) {
    var window_width = width;
    var window_height = height;
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
    newWindow=window.open(theURL,winName,'width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',scrollbars=yes');
    newWindow.focus();
}

//下拉式選單
function gotoSelect(theUrl){
			
	var a = document.getElementById('theSelect');
	window.location = theUrl + '?' + a.options[a.selectedIndex].value + '&thePage=' + a.options[a.selectedIndex].text;
			
}
		
//確認與我聯絡
function checkContactCht(){

	var a = document.getElementById('c_name');
	var b = document.getElementById('c_tel');
	var c = document.getElementById('c_email');
	var d = document.getElementById('c_contents');
	
	if(a.value=='' || a.value.match(/[^\n^\s]/)==null){
		alert('聯絡人姓名不能空白喔')
		a.focus();
		return false;
	}
	
	if(b.value=='' || b.value.match(/[^\n^\s]/)==null){
		alert('聯絡電話不能空白喔');
		b.focus();
		return false;
	}

	if(c.value==''){
		alert('Email不能空白喔');
		c.focus();
		return false;
	}
	
	if(c.value.indexOf('@')==-1 || c.value.indexOf('.')==-1){
		alert('Email格式錯誤');	
		c.focus();
		return false;
	}
	
	if(d.value=='' || d.value.match(/[^\n^\s]/)==null){
		alert('內容不能空白喔');
		d.focus();
		return false;
	}


	
	return confirm('確定內容無誤嗎?');		
}

//確認與我聯絡英文版
function checkContactEng(){

	var a = document.getElementById('c_name');
	var b = document.getElementById('c_tel');
	var c = document.getElementById('c_email');
	var d = document.getElementById('c_contents');
	
	if(a.value=='' || a.value.match(/[^\n^\s]/)==null){
		alert('Name is valid')
		a.focus();
		return false;
	}
	
	if(b.value=='' || b.value.match(/[^\n^\s]/)==null){
		alert('Telephone is valid');
		b.focus();
		return false;
	}

	if(c.value==''){
		alert('Email is valid');
		c.focus();
		return false;
	}
	
	if(c.value.indexOf('@')==-1 || c.value.indexOf('.')==-1){
		alert('Email format error');	
		c.focus();
		return false;
	}
	
	if(d.value=='' || d.value.match(/[^\n^\s]/)==null){
		alert('Message is valid');
		d.focus();
		return false;
	}


	
	return confirm('Are you sure?');		
}

