function openRanking(value) {
	rankingWindow = window.open('viewRanking.dll?id='+value,'rankingWindow','scrollbars=yes,menubar=no,height=550,width=500,resizable=no,toolbar=no,location=no,status=no');
}

function savePoll(obj) {
		var i;
		var pValue = "0";
		for(i=0;i<obj.elements["pollItem"].length;i++) {
			if (obj.elements["pollItem"][i].checked == true) {
					pValue = obj.elements["pollItem"][i].value;
			}
		}
		if (pValue == "0")	{
			alert("กรุณาเลือกตัวเลือกก่อนทำการคลิกปุ่มค่ะ ...");
		} else {
			window.open('viewPoll.dll?mainId='+obj.elements["mainPoll"].value+'&pollItem='+pValue,'pollWindows','scrollbars=yes,menubar=no,height=300,width=500,resizable=yes,toolbar=no,location=no,status=no');
		}
		return false;
}

function HighlightAll(theField) {
	var tempval = eval("document."+theField);
	tempval.focus();
	tempval.select();

	if (document.all && copytoclip==1){
		therange = tempval.createTextRange();
		therange.execCommand("Copy");	
	}
}

function openNews(value) {
	window.open('newsDetails.dll?id='+value,'','scrollbars=yes,menubar=no,height=400,width=600,resizable=no,toolbar=no,location=no,status=no');
}

function searchMap(id) {
	popUpMap = window.open('popUpMap.dll?Mapid='+id,'popUpMap','scrollbars=no,menubar=no,height=650,width=690,resizable=no,toolbar=no,location=no,status=no');
}

function clickTotarget(value) {
window.location="main.php?items="+value;
 //window.open('main.php?items='+value);
}

function clickTotype(value) {
window.location="listbytype.php?type_home="+value;
 //window.open('main.php?items='+value);
}

function alertDelete(part,key) {
		window.open('alertDelete.dll?part='+part+'&id='+key,'alertDelete','scrollbars=no,menubar=no,height=210,width=400,resizable=no,toolbar=no,location=no,status=no');
}

function switchDiv(obj) {

	var newitemTmp = new Array("item01","item02","item03","item04","item05","item06","item07","item08","item09","item10","item11");

	for (i =0; i < newitemTmp.length ;i++ ) {
		document.getElementById(newitemTmp[i]).innerHTML = "";
		document.getElementById(newitemTmp[i]).style.display = "none";
	}

	document.getElementById(obj).style.display = "block";
	document.getElementById(obj).innerHTML = "loading ...";
	tmpFrame.location = "includes/" + obj + ".html";

}

function displayText(obj) {
	document.getElementById(obj).innerHTML = tmpFrame.document.body.innerHTML;
	tmpFrame.document.body.innerHTML = "";
}

function regisNewsletter(obj) {
	var pValue;
	for(i=0;i<obj.elements["newsletterChoice"].length;i++) {
		if (obj.elements["newsletterChoice"][i].checked == true) {
				pValue = obj.elements["newsletterChoice"][i].value;
		}
	}
	if (obj.elements["subNewsletter"].value) {
			if (!checkMail(obj.elements["subNewsletter"].value)) {
					alert("ขออภัย, อีเมล์ของท่านไม่ถูกต้อง\r\nกรุณาระบุใหม่อีกครั้งค่ะ ...");
			} else {
					window.open('registNewsletter.dll?mail='+obj.elements["subNewsletter"].value+'&choice='+pValue,'newsletter','scrollbars=no,menubar=no,height=300,width=484,resizable=no,toolbar=no,location=no,status=no');
			}
	} else {
			alert("ขออภัย, กรุณาระบุอีเมล์ของท่านด้วยค่ะ ...");
	}
	return false;
}

function checkMail(x) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) {
		return true;
	}
	else {
		return false;
	}
}

function copyFc() {
   CopiedTxt = document.selection.createRange();
   CopiedTxt.execCommand("Copy");
   alert("คัดลอกข้อมูลเรียบร้อยแล้ว");
}

function pasteFc() {
   CopiedTxt = document.selection.createRange();
   CopiedTxt.execCommand("Paste");
   alert("วางข้อมูลเรียบร้อยแล้ว");
}

function openPoll(obj) {
		window.open('viewPoll.dll?mainId='+obj.elements["mainPoll"].value,'pollWindows','scrollbars=yes,menubar=no,height=300,width=500,resizable=yes,toolbar=no,location=no,status=no');
		return false;
}

function openradio(url, width, height)	{		
	radioChannel = window.open('radio.dll?ch='+url,'radioChannel',"top=100,left=100,toolbar=0,location=0,directories=0,status=0,statusbar=0,menuBar=0,scrollBars=0,resizable=0,width=100,height=100");
	radioChannel.resizeTo(width, height);
	radioChannel.focus();
}