//document.write("121231");
function Inint_AJAX() {
     try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
     try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
     try { return new XMLHttpRequest();} catch(e) {}
	alert("XMLHttpRequest not supported");
     return null;
}

function ajax(id,url,ver,function_name){
	xmlhttp = Inint_AJAX();
	if(!url){ url = "ajax.php?"+ver;}
	else { url = url+"?"+ver; }
	xmlhttp.open("GET", url, true);
	if(id){document.getElementById(id).innerHTML ="<div style='padding:5px;text-align:center;'>Looding...</div>";}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState == 4) {
			if (xmlhttp.status == 200) {
				if(!function_name){
					var result = xmlhttp.responseText; 
					document.getElementById(id).innerHTML = result;
				}else{
					eval(function_name);
				}
			}
		}
	}
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
	xmlhttp.send(null);
}

function changetab(tab){
	$("tab1").className="";
	$("tab2").className="";
	$(tab).className="current";
	if(tab == "tab1"){  $("minitab").style.display="none"; changeminitab("minitab1","template");}
	else{ $("minitab").style.display="block"; changeminitab("minitab1","clubbanner");}
}

function changeminitab(id,link){
	$("minitab1").className="";
	$("minitab2").className="";
	$("minitab3").className="";
	$("minitab4").className="";
	$(id).className="current";

	$("template").style.display="none";
	$("clubbannertext").style.display="none";
	$("clubbannerpattern").style.display="none";
	$("clubbannerphoto").style.display="none";
	$("clubbanner").style.display="none";
	$("clubcolor").style.display="none";
	$("clubcontentphoto").style.display="none";
	$("background").style.display="none";
	$("menustyle").style.display="none";
	$(link).style.display="block";
}

function changehead(styleid){
	$("bannerid").value = styleid;
	$("head").innerHTML = "<div style='width:900px;height:150px;'>	<div style='float:left;width:400px;border:0px solid #000000;text-align:left;'><div style='margin-left:30px;margin-top:40px;width:330px;border:0px solid #000000;text-align:center'><h3><b>Club Name ( ชื่อคลับภาษาไทย )</b></h3> <br />xxx xx xxx xxxxxx xx xxxx xxxx xx</div></div>";
	$("head").style.backgroundImage="url('template/banner/"+styleid+".png')";
	$("head").style.backgroundColor="#FFFFFF";
	$("head").style.height="150px";
}

function changeheadtext(styleid){
	$("bannertextid").value = styleid;
	$("head").innerHTML = "<div style='line-height:100px;'><font size='4'><b>xxx xx xxx xxxxxx xx xxxx xxxx xx</b></font></div>";
	$("head").style.backgroundImage="url('template/head/"+styleid+".jpg')";
	$("head").style.backgroundColor="#FFFFFF";
	$("head").style.height="100px";
}

function changecontentcolor(color){
	$("contentcolorcode").value=color;
	$("content").style.backgroundImage="url('image/blank.gif')";
	$("content").style.backgroundColor="#"+color;
}

var clubid;
function changecontentstyle(id,style){
	this.clubid = id;
	$("contentcolorstyle").value = style;
	var color = $("contentcolorcode").value;
	ajax("","","mode=createclubcolor&id="+id+"&color="+color+"&style="+style,"changecontentstyledo()");
}
function changecontentstyledo(){
	$("content").style.backgroundImage="url('template/temp/contentbg_"+clubid+".jpg?"+Math.random()+"')";
	$("content").style.backgroundRepeat="repeat";
	$("content").style.backgroundPosition="";
	//$("clubstyle").innerHTML = "";
}

function changebg(id,color){
	document.body.style.backgroundColor="#"+color;
	document.body.style.backgroundImage="url('template/background/"+id+".gif')";
	$("backgroundid").value = id;
	$("backgroundcolor").value = color;
}

function changemenu(id){
	$("menutopdata").className = "menutop"+id;
	$("menuprofiledata").className = "menuprofile"+id;
	$("menubottomdata").className = "menubottom"+id;
	$("menutopmenu").className = "menutop"+id;
	$("menucentermenu").className = "menucenter"+id;
	$("menubottommenu").className = "menubottom"+id;
	$("menutopmem").className = "menutop"+id;
	$("menucentermem").className = "menucenter"+id;
	$("menubottommem").className = "menubottom"+id;
	$("menuid").value = id;
}


/* ####### MEM STYLE #########*/


function changememtab(id){
	$("membannertext").style.display="none";
	$("memtopbg").style.display="none";

	$("membottombg").style.display="none";

	/*
	$("memlogomg").style.display="none";
	$("memprofilebg").style.display="none";
	$("memmessagebg").style.display="none";
	$("memdetailbg").style.display="none";
	$("membg").style.display="none";
	*/


	$(id).style.display="block";
	/*
	$("template").style.display="none";
	$("clubbannertext").style.display="none";
	$("clubbannerpattern").style.display="none";
	$("clubbannerphoto").style.display="none";
	$("clubbanner").style.display="none";
	$("clubcolor").style.display="none";
	$("clubcontentphoto").style.display="none";
	$("background").style.display="none";
	$("menustyle").style.display="none";
	$(link).style.display="block";
	*/
}

var memid;
function changememcontentstyle(id,style){
	this.memid = id;
	$("contentcolorstyle").value = style;
	var color = $("contentcolorcode").value;
	ajax("","","mode=creatememcolor&id="+id+"&color="+color+"&style="+style,"changememcontentstyledo()");
}
function changememcontentstyledo(){
	$("content").style.backgroundImage="url('template/temp/memcontentbg_"+memid+".jpg?"+Math.random()+"')";
	$("content").style.backgroundRepeat="repeat";
	$("content").style.backgroundPosition="";
	$("clubstyle").innerHTML = "";
}












/* ================================================================================*/

function clubsetstylechangemode(id){
	if(id == "clubbannertext" || id == "clubbannerphoto"){
		$("clubbannertext").style.display="none";
		$("clubbannerphoto").style.display="none";
	}
	if(id == "clubtemplate" || id == "clubadvance"){
		$("clubtemplate").style.display="none";
		$("clubadvance").style.display="none";
	}
	if(id == "clubbgcolor" || id == "clubbgimage" || id == "clubbgupload"){
		$("clubbgcolor").style.display="none";
		$("clubbgimage").style.display="none";
		$("clubbgupload").style.display="none";
	}
	$(id).style.display="block";
}

function clubtemplateselect(id){
	$("template1").style.borderColor="#E1E1E1";
	$("template2").style.borderColor="#E1E1E1";
	$("template3").style.borderColor="#E1E1E1";
	$("template4").style.borderColor="#E1E1E1";
	$("template5").style.borderColor="#E1E1E1";
	$("template6").style.borderColor="#E1E1E1";
	$("template"+id).style.borderColor="#990000";
	$("template").value = id ;
}

function clubbgcolorelect(color){
	$("clubbgcolorcode").style.borderColor="#"+color;
	$("colorshow").style.backgroundColor="#"+color;
	$("clubbgcolorcode").value=color;
}
