// add by zheng on 20091221
document.write('<script src="js/lang.js"></'+'script>'); 

function delArtist(id){
var conf=confirm("你確定要刪除此藝術家？");
if(conf==1){
xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	   
		// org code before 20091221
        //alert ("Your browser does not support AJAX!");
        
        alert (langObj['Your browser does not support AJAX!']);// add by zheng on 20091221;        

		return;
	}
	var url="artistoperation.php";
	var param = "";
	param += "id="+id;
	param += "&op=del";
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", param.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(param);

}
}
function nnewArtist()
{
    var flagnewstitle=1;
    if(document.getElementById("artistName").value.length > 60)
    flagnewstitle=0;
    else if(document.getElementById("artistName").value.length == 0)
    flagnewstitle=2;
    
    var flagnewstitlecontent=1;
    if(document.getElementById("introductionContent").value.length == 0)
    flagnewstitlecontent=2;
    
    if(flagnewstitle == 1 && flagnewstitlecontent == 1){
    	document.getElementById("nw").value="1";
    	document.getElementById("edit").value="0";
    
    	document.artistedit.submit();
    }
    else{
    
    
    	if(flagnewstitle == 0){
    	document.getElementById("spantitle").innerHTML="<label class=\"stylelbl\">字數過長</label>";
    	}
    	else if(flagnewstitle == 2){
    	document.getElementById("spantitle").innerHTML="<label class=\"stylelbl\">請輸入藝術家名稱</label>";
    	}
    	else
    	document.getElementById("spantitle").innerHTML="";
    
    
    	 if(flagnewstitlecontent == 2){
    	document.getElementById("spantitlecontent").innerHTML="<label class=\"stylelbl\">請輸入藝術家簡介</label>";
    	}
    	else
    	document.getElementById("spantitlecontent").innerHTML="";
    }

}

function editintro(id){

    window.location='introedit.php?op=edita&id='+id;

}

function setofflineArtist(id){
xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){

		// org code before 20091221
        //alert ("Your browser does not support AJAX!");
        
        alert (langObj['Your browser does not support AJAX!']);// add by zheng on 20091221;        

		return;
	}
	var url="artistoperation.php";
	var param = "";
	param += "id="+id;
	param += "&op=off";
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", param.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(param);

}
function setonlineArtist(id){
    xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	   
		// org code before 20091221
        //alert ("Your browser does not support AJAX!");
        
        alert (langObj['Your browser does not support AJAX!']);// add by zheng on 20091221;        
        
		return;
	}
	var url="artistoperation.php";
	var param = "";
	param += "id="+id;
	param += "&op=on";
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", param.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(param);

}
function stateChanged(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState==200){
        var ss=xmlHttp.responseText;
        //alert(ss);  // org code before 20091222
        alert(langObj[ss]); // add by zheng on 20091222
        window.location="intro.php";
    }
}

function GetXmlHttpObject(){
var xmlHttp=null;
try{
    xmlHttp=new XMLHttpRequest();
    }
catch (e){
    try{
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
    catch (e){
	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
    }

return xmlHttp;
}



function newArtist(){
window.location='introedit.php?op=newa&id=';
}

function updateArtist(){

	document.getElementById("edit").value="1";
	document.getElementById("nw").value="0";
	document.getElementById("delt").value="0";

	var flagnewstitle=1;
	var flagnewstitlecontent = 1;
	if(document.getElementById("artistName").value.length > 60)
	flagnewstitle=0;
	else if(document.getElementById("artistName").value.length == 0)
	flagnewstitle=2;
	
	
	if(document.getElementById("introductionContent").value.length == 0)
	flagnewstitlecontent=2;

	if(flagnewstitle == 1 && flagnewstitlecontent == 1){
		document.artistedit.submit();
	}
	else{


		if(flagnewstitle == 0){
		document.getElementById("spantitle").innerHTML="<label class=\"stylelbl\">字數過長</label>";
		}
		else if(flagnewstitle == 2){
		document.getElementById("spantitle").innerHTML="<label class=\"stylelbl\">請輸入藝術家名稱</label>";
		}
		else
		document.getElementById("spantitle").innerHTML="";

	if(flagnewstitlecontent == 2){
		document.getElementById("spantitlecontent").innerHTML="<label class=\"stylelbl\">請輸入藝術家簡介</label>";
		}
		else
		document.getElementById("spantitlecontent").innerHTML="";
	}

}

function cancelArtist()
{
	window.location="intro.php";
}

function editArtistPriority()
{
	window.location='artistpriority.php';
}

function checkIntroductionContent()
{
	if(document.getElementById("introductionContent").value.length > 140)
	alert("簡介字數過長");
}

function checkArtistName()
{
	if(document.getElementById("artistName").value.length > 60)
	alert("藝術家名稱字數過長");
}


