
function showResponse(request){
	showClientData();
	var newData = request;		
		if(newData.indexOf('<ERROR>')>-1){		
			var y=newData.indexOf('<ERROR>');
			var z=newData.indexOf('</ERROR>');
			var length=z-(y+7);
			alert_id=newData.substr(y+7,length);		
			show_ghost(alert_id);
			refresh_wish();			
			return false;
		}
		else
		{
			window.location='index.php';	
		}
		
}

function post_form(myForm){
	showLoad();
	var url='include/ajax_requests/register.php';
	new Ajax(url,{postBody: $(myForm),  onComplete: showResponse}).request();	
}

function add_wish(prod_id){
	showLoad();
	var ajaxUrl='include/ajax_requests/add_to_wish.php?prod_id='+prod_id;
	new Ajax(ajaxUrl, { method: 'get', onComplete:showResponse}).request();
}

function showLoad () {
	document.getElementById('loader').style.display="block";
}

function refresh_wish(){
	var ajaxURL='include/ajax_requests/refresh_wish.php';
	new Ajax(ajaxURL, { method: 'get', onComplete:complete_refresh}).request();	
}

function complete_refresh(request){
	var newData = request;
	document.getElementById('wish').innerHTML=newData;
}
function show_ghost(text){
	Growl.Bezel({
	title: '',
	text: text,
	duration: 4
	});
	return false;
}



function showClientData(){
	document.getElementById('loader').style.display="none";	
}