function initC1(){
	var obj = document.myform.cat1;
	var c1selectid;
	c1selectid = 0;
	
	for(var i=0; i<c1; i++){
		obj.options[i+1] = new Option(c1name[i],c1id[i]);
		if(c1selectval!="" && c1selectval==c1id[i]){
			c1selectid = i+1;
		}
	}
	if(c1selectid>0){
		obj.selectedIndex = c1selectid;
		changeSub(c1selectval);
		document.myform.cat2.selectedIndex = c2selectval;
	}
	getCount();
	document.myform.yourName.focus();
}

function changeSub(myval){
	var thei;
	
	for(var i=0; i<c1; i++){
		if(c1id[i]==myval){
			thei=i;
			break;
		}
	}
	
	var obj = document.forms['myform'].cat2;
	obj.options.length=1;
	for(var i=0; i<c2id[thei].length; i++){
		obj.options[i+1] = new Option(c2name[thei][i],c2id[thei][i]);
	}
}

function getCount(){
	var obj = document.myform;
	var myval = obj.desc.value.length;
	obj.remain.value = 250-myval;
	if(obj.remain.value<=0){
		obj.desc.value = obj.desc.value.substring(0,250);
		obj.remain.value = 0;
	}
}

function reportMsg(ss){
	document.getElementById("errorMsg").innerHTML = ss;
}

function checklist(){
	var obj = document.myform;
	if(obj.yourName.value == ""){
		reportMsg("Please enter your name.");
		obj.yourName.focus();
		return false;
	}

	if(obj.yourEmail.value == ""){
		reportMsg("Please enter your Email.");
		obj.yourEmail.focus();
		return false;
	}else{
		if(obj.yourEmail.value.indexOf("@")==-1 || obj.yourEmail.value.indexOf(".")==-1){
			reportMsg("Wrong Email Address.");
			obj.yourEmail.focus();
			return false;
		} 
	}

	if(obj.url.value == "http://" || obj.url.value == "http://"){
		reportMsg("Please enter the URL of your site.");
		obj.url.focus();
		return false;
	}else{
		if(obj.url.value.indexOf(".")==-1){
			reportMsg("Wrong URL.");
			obj.url.focus();
			return false;
		} 
	}

	if(obj.url.value.substring(0,7) != "http://"){
		reportMsg("Please enter http:// before the URL.");
		obj.url.focus();
		return false;
	}else{
		var tmp = obj.url.value.substring(7);
		if(tmp.indexOf("/")>-1){
			reportMsg("The URL is Home Page only.");
			obj.url.focus();
			return false;
		} 
	}

	if(obj.title.value == ""){
		reportMsg("Please enter the title of your site.");
		obj.title.focus();
		return false;
	}

	if(obj.desc.value == ""){
		reportMsg("Please enter the description of your site.");
		obj.desc.focus();
		return false;
	}
	
	if(obj.cat1.value == ""){
		reportMsg("Please select the catalog.");
		obj.cat1.focus();
		return false;
	}

	if(obj.cat2.value == ""){
		reportMsg("Please select the sub catalog.");
		obj.cat2.focus();
		return false;
	}

	if(obj.theCode.value == ""){
		reportMsg("Please enter the code.");
		obj.theCode.focus();
		return false;
	}

	return true;
}
