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

function setonlineProduct(){
document.getElementById("nw").value="0";
document.getElementById("edit").value="0";
document.getElementById("delt").value="0";
document.getElementById("online").value="1";
document.getElementById("offline").value="0";
document.productedit.submit();

}

function setofflineProduct(){
document.getElementById("nw").value="0";
document.getElementById("edit").value="0";
document.getElementById("delt").value="0";
document.getElementById("online").value="0";
document.getElementById("offline").value="1";
document.productedit.submit();
}
function delProduct(){
var conf=confirm("Are You Sure To Delete This Product?");
if(conf==1){
document.getElementById("nw").value="0";
document.getElementById("edit").value="0";
document.getElementById("delt").value="1";
document.getElementById("online").value="0";
document.getElementById("offline").value="0";
document.productedit.submit();
}
}
function nnewProduct()
{
	//alert(document.getElementById("newnws").value);
	//alert(document.getElementById("nw").value);
	//if(document.getElementById("newnws").value=="Save")  // org code before 20091222
	if(document.getElementById("newnws").value==langObj["Save"]) 
	{
		document.getElementById("nw").value="1";
		document.productedit.submit();
	}
	else{
		document.getElementById("nw").value="1";
		document.getElementById("newnws").value="Save";
		document.getElementById("edit").value="0";
		document.getElementById("delt").value="0";
		document.getElementById("online").value="0";
		document.getElementById("offline").value="0";
		document.getElementById("productTitle").value="";
		document.getElementById("productContent").value="";
		document.getElementById("productTitle").focus();
		//document.getElementById("newnws").value="Save";  // org code before 20091222
		document.getElementById("newnws").value=langObj["Save"];  // add by zheng on 20091222
	}
}



/* This block of code is written by Sanjib Chatterjee
 * and updated by Indranil Basu.
 */

function editproduct(id){
	var artistid = document.getElementById("artistid").value;

// 	window.location = 'artistproductedit.php?artist_id=' + artistid + '&id=' + id; //by Sanjib Chatterjee
	window.location = 'photo.php?artist_id=' + artistid + '&id=' + id;

}
/***********************************************************/





function updateProduct(){
document.getElementById("edit").value="1";
document.getElementById("nw").value="0";
document.getElementById("delt").value="0";
document.getElementById("online").value="0";
document.getElementById("offline").value="0";
document.productedit.submit();
}

function cancelProduct()
{
var id=document.getElementById("artid").value;
window.location="intropage.php?id="+id;
}


/*
 * This block of code is reposible to create the view of a particular folders' contents.
 * Author : Indranil Basu.
 */
function showGallery(This, u){
	var folderId = This.value;

	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="folderChoosing.php";
	var param = "";
	param += "id=" + folderId;
	param += "&u=" + u;
	
	xmlHttp.onreadystatechange = FolderContentsResultSet;
	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 FolderContentsResultSet(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState==200){
    		var fcrs = xmlHttp.responseText;
		
		var elem = fcrs.split("^");

		var divId1 = document.getElementById('previewPane');
		divId1.innerHTML = elem[0];

		var divId2 = document.getElementById('theImages');
		divId2.innerHTML = elem[1];

		if(document.getElementById('btnEditPhotos'))
			document.getElementById('btnEditPhotos').setAttribute('onclick',"editproduct(\"" + elem[2] + "\")");
    	}
}
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 editfolder(cmbFolderId,artistId){
	var cmbFolder = document.getElementById(cmbFolderId);
    if(cmbFolder==null) {var cmbFolder=new Object();cmbFolder.value='';} // add by zheng on 20091229
	window.location = "folder.php?folderId=" + cmbFolder.value + "&artistId=" + artistId;
}
/*
 * The code ends here.
 */
