// JavaScript Document

function gAdd2Favorites(target,vid,pid) {
	if(vid=="") {
		$d.gform_redirect.submit();
	} else {
		var url = "gcodes/gadd2fav.php"
		var method = "post";
		var ObjAjax =  new gAjax();
		var parameters="pid="+pid+"&vid="+vid;
		target.onclick = function() {
			alert("Adding to favorites in progress...wait!");
		}		
		this.processGetPost = function(){
			var myajax=ObjAjax.ajaxpack.ajaxobj;
			var myfiletype=ObjAjax.ajaxpack.filetype;
			if (myajax.readyState == 4){ 
				if (myajax.status==200 || window.location.href.indexOf("http")==-1){ 
					alert($st(myajax.responseText));	
					target.onclick = function() {
						alert("Listing already exists on your favorites!");
					}
				}
			}
		}
		
		ObjAjax.postAjaxRequest(url, parameters, this.processGetPost, 'txt');			
		return;						
	}
}

function gRemoveFavorite(target,key) {
	var nret = confirm("Delete this item?");
	if(!nret) return;
	var url = "gcodes/gremovefav.php"
	var method = "post";
	var ObjAjax =  new gAjax();
	var parameters="key="+key;
	$e("list_prop"+key).style.display = "none";
	this.processGetPost = function(){
		var myajax=ObjAjax.ajaxpack.ajaxobj;
		var myfiletype=ObjAjax.ajaxpack.filetype;
		if (myajax.readyState == 4){ 
			if (myajax.status==200 || window.location.href.indexOf("http")==-1){ 
			}
		}
	}		
	ObjAjax.postAjaxRequest(url, parameters, this.processGetPost, 'txt');			
	return;						
}
