function change_color(c){
	var url = 'header.php';	
	var pars = "color="+c;
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete: ShowResponse} );
	
}

function ShowResponse(originalRequest){

	var arr=originalRequest.responseText;

	var ar=arr.split("|");	
//	alert(ar[4]);
	var divpageid = document.getElementById("background");		
	var ntt=document.getElementById("ntt");	
	var ntl=document.getElementById("ntl");
//	var logoid=document.getElementById("logeid");	
	divpageid.style.backgroundImage="url(images/"+ar[0]+")";
	ntt.src="images/"+ar[1]+"";
	ntl.src="images/"+ar[2]+"";
//	logoid.src="images/"+ar[3]+"";	
	document.getElementById("flvseltxt").innerHTML=ar[4];
	document.body.style.backgroundImage="url(images/"+ar[5]+")";


		
}

function show_state()
{	
	var url = 'ajax.php';	
	countryid=document.getElementById("country").value;	
	stateid=0;
	//var parm = "action=statelist&countryid="+countryid+"&stateid="+stateid;	
	var parm = "action=statelist&countryid="+countryid;	
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowState} );
}
function ShowState(originalRequest)
{	
	var state_list = document.getElementById("divstate");	
	var rtext = originalRequest.responseText;
	rtext="<select class='hm-midbar-whatnew' name='state'>"+rtext+"</select>" ;
	//rtext="<select class='hm-midbar-whatnew' name='state'>"+rtext+"</select>" ;
	state_list.innerHTML=rtext;			
}
/*
function check_email()
{
	var url = 'ajax.php';	
	e_mail=document.getElementById("user_e_mail").value;	
	var parm = "action=chk_email&e_mail="+e_mail;	
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: CheckEmail} );
}
function CheckEmail(originalRequest){	
	var txtResp=originalRequest.responseText;		
	var arrResp = txtResp.split("|");
	var valid = arrResp[0];
	if (valid==-1){
		var msg = document.getElementById("msg");	
		msg.innerHTML=arrResp[1];
	}else{
		msg.innerHTML="";
		}
	
}*/
//----------------------------------------------------------------------------------
//response for genarating values in tabular format
function show_products(category_id)
{	
	var url = 'ajax.php';			
	var parm = "action=show_products&category_id="+category_id;	
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowProducts} );
	
}
function ShowProducts(originalRequest)
{	
	var product= document.getElementById("divproduct");	 //for viewing product	
	var rtext = originalRequest.responseText;	
	product.innerHTML=rtext;				
	
}

//---------------------------------------------------------------------------------------
function show_recipe(category_id)
{	
	var url = 'ajax.php';		
	var parm = "action=show_recipe&category_id="+category_id;	
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowRecipe} );
}
function ShowRecipe(originalRequest)
{	
	var recipe= document.getElementById("divrecipe");	
	var rtext = originalRequest.responseText;	
	recipe.innerHTML=rtext;			
}
//-------------------------------------------------------------------------------------------------------------------------------------
//response for genarating values in combo fro customer feedback
function show_products_combo(category_id)
{	
	var url = 'ajax.php';				//for customer feedback	
	product_category=document.getElementById("product_category").value;	
	var parm = "action=show_products&display=combo&category_id="+product_category;		//	alert(parm);
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowProductsCombo} );
	
}
function ShowProductsCombo(originalRequest)
{	
	var divproducts= document.getElementById("divproducts");	
	var rtext = decodeURI(unescape(originalRequest.responseText));		
	rtext=rtext.replace(/\+/g," ");
	rtext="<select name='products' id='Products' onChange='show_product_flavour()' >"+rtext+"</select>" ;
	divproducts.innerHTML=rtext;
	show_product_flavour();
}



//---------------
function show_product_flavour()
{	
	var url = 'ajax.php';				//for customer feedback	
	product_id=document.getElementById("Products").value;		
	document.getElementById("hproducts").value=product_id;	
	var parm = "action=show_flavour&product_id="+product_id;			
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowProductsFlavour} );
	
}
function ShowProductsFlavour(originalRequest)
{	
	var divflavour= document.getElementById("divflavour");	
	var rtext = decodeURI(unescape(originalRequest.responseText));		
	rtext=rtext.replace(/\+/g," ");
		
	rtext="<select name='flavours' id='Flavours' onChange='show_product_flavour_size()'>"+rtext+"</select>" ;
	divflavour.innerHTML=rtext;		
	show_product_flavour_size();
}
//--------------
function show_product_flavour_size()
{	
	var url = 'ajax.php';				//for customer feedback	
	productflavour_id=document.getElementById("Flavours").value;		
	
	document.getElementById("hflavours").value=productflavour_id;
	
	var parm = "action=show_size&productflavour_id="+productflavour_id;			//alert(parm);
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowProductsSize} );
	
}
function ShowProductsSize(originalRequest)
{	
	var divsize= document.getElementById("divsize");	
	var rtext = decodeURI(unescape(originalRequest.responseText));		
	rtext=rtext.replace(/\+/g," ");
	rtext="<select name='size' id='Size' onChange='fill_hsize()' >"+rtext+"</select>" ;	
	divsize.innerHTML=rtext;			
}

function fill_hsize()
{
	size_id=document.getElementById("Size").value;		
	document.getElementById("hsize").value=size_id;
}

//--------------------------------------------------------------------------------------------------------------------------------------

function show_product_details(pid,fid)
{ 
	var url = 'product_details.php';				
	var parm = "pid="+pid+"&fid="+fid;			//alert(parm);
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowProductsDetails} );	
}

function ShowProductsDetails(originalRequest)
{		
	var st = originalRequest.responseText;
	var productdetails= document.getElementById("divproductdetails");	 
	var	arrResponse=st.split("|");
	productdetails.innerHTML=arrResponse[1];
	if(arrResponse[0]==0){
	openbox("filter","box","boxtitle","View Flavour & Nutrients ",1);
	}
	else
	{
		if (arrResponse[1]==""){
		closebox("filter","box");
		}
	}
		
}

function refresh_whatsnew()
{
	var url = 'ajax.php';		
	var parm = "action=whats_new";	
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowWhatsnew} );
}
function ShowWhatsnew(originalRequest)
{		
	var arr=originalRequest.responseText;

	var ar=arr.split("|");	
	//alert(ar[0]);
	
	document.getElementById("new_product").innerHTML=ar[0];
	document.getElementById("ppurl").href="products-"+ar[1];	
	document.getElementById("new_recipe").innerHTML=ar[2];
	document.getElementById("rpurl").href="recipes-"+ar[3];		
}


function save_recipe_favorites(recipe_id)
{ 
	var url = 'recipe_search.php';		
	var parm = "mode=save&recipe_id="+recipe_id;	
	//alert(parm);
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowSaveRecipeRseponse} );
}
function ShowSaveRecipeRseponse(originalRequest)
{
	var resp=originalRequest.responseText;
	
	//alert(resp);
	if(resp==0){
	 alert("Already Saved");	
	}else if(resp==1){
	 alert("Saved to your favorites");
	}else if(resp==2){	  	
		 chklightboxlogin();
	}	
}
function chklightboxlogin(rpgurl){	
	var url = 'registration.php';		
	//var parm = "mode=ajax";	
	var parm = "mode=ajax&rpgurl="+encodeURIComponent(rpgurl);		
	//alert(parm);
	var myAjax = new Ajax.Request( url, {method: 'post', parameters: parm, onComplete: ShowLightboxLogin} );
	
}
function ShowLightboxLogin(originalRequest)
{
	var resp_arr=originalRequest.responseText;	
	var arr=resp_arr.split("|");	
	if(arr[0] == 0){		
	//alert (arr[1]);
		document.getElementById("rpgurl").value=arr[1];
	 	openboxwhite("filterwhite","boxwhite","boxtitlewhite","Login ",1);		
		return false;
	}else{
		window.location=arr[1];
	}
}

function show_taf_lb()
{
	openboxwhite("filterwhite","boxwhite","boxtitlewhite","Login ",1);				
}

function lb_taf(pid)
{	
	var url = 'ajax.php';	
	var parm = "action=product_sendtofriend&pid="+pid;	
	//alert(parm);
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowLightBoxTafProduct} );	
		
}
function ShowLightBoxTafProduct(originalRequest)
{	
	var rt = originalRequest.responseText;	
	var divproduct_taf = document.getElementById("product_taf");		
	divproduct_taf.innerHTML=rt;		
	openboxwhite("filterwhite","boxwhite","boxtitlewhite","TAF ",1);		
}


function lb_taf_news()
{
	openboxwhite("filterwhite","boxwhite","boxtitlewhite","TAF ",1);				
}


function refresh_rightColumn()
{
	var url = 'ajax.php';		
	var parm = "action=rightColumnRefresh";	
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowRightColumn} );
}
function ShowRightColumn(originalRequest)
{		
	var arr=originalRequest.responseText;
	
	var ar=arr.split("|");	
	
	//alert(ar[0]);alert(ar[1]);alert(ar[2]);
	
	document.getElementById("new_subscription_right").innerHTML=ar[0];	
	document.getElementById("new_product_right").innerHTML=ar[1];	
	document.getElementById("new_recipe_right").innerHTML=ar[2];
	
}

function show_store_city()
{	
	var url = 'ajax.php';	
	store_stateid=document.getElementById("store_stateid").value;		
	var parm = "action=storecitylist&store_stateid="+store_stateid;		
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowStoreCity} );
}
function ShowStoreCity(originalRequest)
{	
	var store_city_list = document.getElementById("divstorecity");	
	//var store = document.getElementById("divstore");	
	var rtext = originalRequest.responseText;
	//alert(rtext);
	rtext="<select name='store_cityid'  id='store_cityid' onchange='show_store()'>"+rtext+"</select>" ;	
	store_city_list.innerHTML=rtext;			
	show_store();
	//store.innerHTML="<select class='hm-midbar-whatnew' name='store_nameid' id='store_nameid'>Pleas </select>" ;	
}


function show_store()
{	//alert("aa");
	var url = 'ajax.php';	
	store_cityid=document.getElementById("store_cityid").value;		
	//alert(store_cityid);
	document.getElementById("hstore_cityid").value=store_cityid;	
	var parm = "action=storelist&store_cityid="+store_cityid;		
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: parm, onComplete: ShowStore} );
}
function ShowStore(originalRequest)
{	
	var store = document.getElementById("divstore");	
	var rtext = originalRequest.responseText;
	//alert(rtext);
	rtext="<select name='store_id' id='store_id' onchange='set_hstore_id()'>"+rtext+"</select>" ;	
	store.innerHTML=rtext;
	set_hstore_id();
}
function set_hstore_id()
{	
	store_id=document.getElementById("store_id").value;		
	//alert(store_id);
	document.getElementById("hstore_id").value=store_id;	
}

