function advertiserEditPage(theform){
	var highlightcolor = "#FFCACA";
	var normalcolor = "";
	var errmsg = "";
	var classstyle = "Txt333333";
	error = "";
	is_number=true;
	
	if (isblank(theform.school_address.value)) {	
		error += "請重新輸入 地址/Address\n";
		theform.school_address.style.background = highlightcolor;
	}
	else
		theform.school_address.style.background = normalcolor;
	if (isblank(theform.contact_person.value)) {
		error += "請重新輸入 學院/機構聯絡人\n";
		theform.contact_person.style.background = highlightcolor;
	}
	else
		theform.contact_person.style.background = normalcolor;
	if (isblank(theform.contact_title.value)) {
		error += "請重新輸入 學院/機構聯絡人職位\n";
		theform.contact_title.style.background = highlightcolor;
	}
	else
		theform.contact_title.style.background = normalcolor;
	if (!isNumber(theform.phone.value)) {
		error += "請重新輸入 學院/機構聯絡電話\n";
		theform.phone.style.background = highlightcolor;
	}
	else
		theform.phone.style.background = normalcolor;
	if (!isNumber(theform.fax.value)) {
		error += "請重新輸入 學院/機構傳真\n";
		theform.fax.style.background = highlightcolor;
	}
	else
		theform.fax.style.background = normalcolor;
	if (!isEmail(theform.email.value) && !isEmail(theform.email2.value))
	{
		error += "電郵不正確，請重新輸入\n";
		theform.email.style.background = normalcolor;
		theform.email2.style.background = normalcolor;
		
		if(!isEmail(theform.email.value) && theform.email.value != "")
			theform.email.style.background = highlightcolor;
		else if(!isEmail(theform.email2.value) && theform.email2.value != "")
			theform.email2.style.background = highlightcolor;
		else
			theform.email.style.background = highlightcolor;
	}
	else
	{
		theform.email.style.background = normalcolor;
		theform.email2.style.background = normalcolor;
	}
	if((theform.website.value!="" && theform.website.value.indexOf("http://")!=0) || (theform.website2.value!="" && theform.website2.value.indexOf("http://")!=0))
	{
		error += "請重新輸入 網址/Website\n";
		if(theform.website.value!="" && theform.website.value.indexOf("http://")!=0)
			theform.website.style.background = highlightcolor;	
		else
			theform.website.style.background = normalcolor;
			
		if(theform.website2.value!="" && theform.website2.value.indexOf("http://")!=0)
		{
			theform.website2.style.background = highlightcolor;
		}
		else
			theform.website2.style.background = normalcolor;
	}
	else
	{
		theform.website.style.background = normalcolor;
		theform.website2.style.background = normalcolor;
	}
	if (isblank(theform.website.value) && isblank(theform.website2.value)) {
		error += "請重新輸入 網址/Website\n";
		theform.website.style.background = normalcolor;
		theform.website2.style.background = normalcolor;
		
		if(isblank(theform.website.value) && theform.website.value != "")
			theform.website.style.background = highlightcolor;
		else if(isblank(theform.website2.value) && theform.website2.value != "")
			theform.website2.style.background = highlightcolor;
		else
			theform.website.style.background = highlightcolor;
	}
	
	if (error!= "") {        
	   alert(error);
	   return false;               
	}
	else
	{	
		return true;
	}
}

function blogSearchCheck(theForm) {
	if(isblank(theForm.keyword.value)) {
		alert("請重新輸入搜索字句");
		return false;
	}
}

function isEmail(value)
{
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
		
	if (!(!reg1.test(value) && reg2.test(value)))
	{
		return false;
	}
	return true;
}

function isblank(s)
{
	for(var i =0; i<s.length;i++)
	{
		var c = s.charAt(i);
		if((c!=' ') && (c!='\n') && (c!='\t')) return false;
	}
	return true;
}

function isNumber(myString){
	var regExp = /^[0-9]+$/;
	var valid = regExp.test(myString);
	return valid;
}

function checkIsNumber(myString){
	var regExp =/^[0-9\-]/;
	var valid = regExp.test(myString);
	return valid;
}

function getDateByMonth(Year, Month)
{
	var monthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
	{
		monthDays[1] = 29;
	}
	return monthDays[parseInt(Month)-1];
}

function isDateValid(Year, Month, Day)
{
	var monthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
	{
		monthDays[1] = 29;
	}

	if (!isNumber(Year))
	{
		return false;
	}
	else if (!isNumber(Month))
	{
		return false;
	}
	else if (!isNumber(Day))
	{
		return false;
	}


	if (parseInt(Month) > 12 || parseInt(Month) < 1)
	{
		return false;
	}

	if (parseInt(Day) > monthDays[parseInt(Month)-1])
	{
		return false;
	}
	else 
	{
		return true;
	}

}

function isWord(myString){
	var regExp = /^[0-9a-zA-Z_\.]*$/;
	var valid = regExp.test(myString);
	return valid;
}

function isChecked (obj)
{
	for (i=0; i < obj.length; i++)
	{
		if (obj[i].checked)
			return true;
	}
	return false;
}


function errorMessage(show, errorMsg)
{
	if (show)
	{
		return errorMsg;
	}
	else
	{
		return ""
	}
}