//===========================================
// Function For artist
function call_artist(mode,start,id){
	switch(mode){
		case "detail":
		   	artist_detail(id); break;
		default: 
			artist_list();break;	
	}	
}
function artist_list(){
	setbg(2);
	var j = new ajax();
	j.jaxinit();
	//j.addvar("js",1);
	j.addvar("nohf",1);
	j.addvar("mode","");
	j.addvar("cmd","artist");
	j.processajax("index.php","dcontent");	
}
function artist_detail(id){
	setbg(2);
	var j = new ajax();
	j.jaxinit();
	//j.addvar("js",1);
	j.addvar("nohf",1);
	j.addvar("id",id);
	j.addvar("mode","detail");
	j.addvar("cmd","artist");
	j.processajax("index.php","dcontent");	
}
//============================================
// Function For Product
function call_product(mode,start,id){
	switch(mode){
		case "detail":
		   	product_detail(id); break;
		default: 
			product_cate();break;	
	}	
}
function product_cate(parent){
	setbg(11);
	parent=(parent)?parent:1;
	var j = new ajax();
	j.jaxinit();
	//j.addvar("js",1);
	j.addvar("nohf",1);
	j.addvar("parent",parent)
	j.addvar("mode","");
	j.addvar("cmd","product");
	j.processajax("index.php","dcontent");
}
function product_list(start,cate){
	setbg(11);
	var j = new ajax();
	j.jaxinit();
	//j.addvar("js",1);
	j.addvar("nohf",1);
	j.addvar("start",start);
	j.addvar("cate",cate);
	j.addvar("mode","list");
	j.addvar("cmd","product");
	j.processajax("index.php","dcontent");	
}
function product_detail(id,parent){
	setbg(11);
	var j = new ajax();
	j.jaxinit();
	//j.addvar("js",1);
	j.addvar("nohf",1);
	j.addvar("id",id);
	j.addvar("parent",parent);
	j.addvar("mode","detail");
	j.addvar("cmd","product");
	j.processajax("index.php","dcontent");	
}
function product_views_cart(){
	setbg(11);
	var j = new ajax();
	j.jaxinit();
	//j.addvar("js",1);
	j.addvar("nohf",1);
	j.addvar("mode","views_cart");
	j.addvar("cmd","product");
	j.processajax("index.php","dcontent");	
}
function product_add_to_cart(id,price){
	//setbg(11);
	var j = new ajax();
	j.jaxinit();
	j.addvar("js",1);
	j.addvar("nohf",1);
	j.addvar("id",id);
	j.addvar("price",price);
	j.addvar("mode","add_to_cart");
	j.addvar("cmd","product");
	j.processOnly=true;
	j.processajax("index.php");		
	alert(j.responseText);
	showselectedlist();
}
function product_clear_cart(){
	setbg(11);
	var j = new ajax();
	j.jaxinit();
	j.addvar("js",1);
	j.addvar("nohf",1);
	j.addvar("mode","clear_cart");
	j.addvar("cmd","product");
	j.processOnly=true;
	j.processajax("index.php");		
	alert(j.responseText);
	product_views_cart();
	showselectedlist();
}
function product_del_cart(arrindex){
	setbg(11);
	var j = new ajax();
	j.jaxinit();
	j.addvar("js",1);
	j.addvar("nohf",1);
	j.addvar("arrindex",arrindex);
	j.addvar("mode","del_cart");
	j.addvar("cmd","product");
	j.processOnly=true;
	j.processajax("index.php");		
	alert(j.responseText);
	document.location.href="index.php?cmd=product&mode=views_cart";
	//product_views_cart();
	
}
function  setbg(id){
	//document.getElementById("tbg").background="images/"+LangDir+"/bg/bg"+id+".jpg";	
	document.getElementById("tbg").style.background="url(images/"+LangDir+"/bg/bg"+id+".jpg)";
}
function showselectedlist(){
	var j = new ajax();
	j.jaxinit();
	j.addvar("js",1);
	j.addvar("nohf",1);
	j.addvar("mode","jscount_cart");
	j.addvar("cmd","product");
	j.processOnly=true;
	j.processajax("index.php");	
	
	if(j.responseText>0){
	  document.getElementById("dselectedlist").style.display="block";
	  document.getElementById("spcountcart").innerHTML=j.responseText;
	}else{
	  document.getElementById("spcountcart").innerHTML=0;	
	  document.getElementById("dselectedlist").style.display="none";		
	}
}
//============================================
// Users
function verify_login(username, password){
	var j = new ajax();
	j.jaxinit();
	j.addvar("js",1);
	j.addvar("nohf",1);
	j.addvar("username",encodeURI(username));
	j.addvar("password",encodeURI(password));
	j.addvar("mode","verify_login");
	j.addvar("cmd","users");
	j.processOnly=true;
	j.processajax("index.php");		
	if(j.responseText==1){
		document.location.href="index.php";
	}else{
		alert("Sorry,Invalid Username and Password");
	}
	
}
