function getProductListAjax() {
	//var url='ajax.loadshortlist.php';
	var url='index.php?module=shortlist&type=load&aff=popup&keepThis=true';
	new Ajax(url, {
	update: 'shortlistcontent',
	evalScripts: 'true'
	}).request();
}

function loginshortlist(){
		TB_show('You re not logged', 'index.php?module=shortlist&type=notlogged&aff=popup&keepThis=true&height=200&width=350', false)
		return;
}

function getshortlistitems(){
	if (getProductListSelection().indexOf("newList") == 0) {
		TB_show('New Shortlist', 'index.php?module=shortlist&type=new&aff=popup&keepThis=true&height=200&width=350', false)
		return;
	}else{
		loadmyitems();
	}
}
function loadmyitems(){
	if (getProductListSelection().indexOf("please select") != 0){
		//var url='ajax.loadshortlistitems.php?sads_shortlist_id='+getProductListSelection();
		var url='index.php?module=shortlist&type=items&aff=popup&keepThis=true&sads_shortlist_id='+getProductListSelection();
		new Ajax(url, {
		update: 'shortlistitems'
		}).request();
	}else{
		var url='index.php?module=shortlist&type=items&aff=popup&keepThis=true';
		new Ajax(url, {
		update: 'shortlistitems'
		}).request();
	}
}

function getProductListSelection() {
    return $('shortlist_list').getValue();
}

function submitnewshortlist(e) {
	new Ajax('index.php?module=shortlist&type=new&aff=popup&keepThis=true&height=200&width=350', {
	method: 'post',
	data: $('new_shortlist'),
	update: 'TB_ajaxContent'
	}).request();
}

function snsuccesss(e) {
	TB_remove();
	getProductListAjax();
	loadmyitems();
}
function additemtomyshortlist(a){
	//alert("add"+a);
		//var url='index.php?module=shortlist&type=new&aff=popup&keepThis=true';

	if (getProductListSelection().indexOf("please select") == 0){
		TB_show('New Shortlist', 'index.php?module=shortlist&type=new&aff=popup&keepThis=true&height=200&width=350', false)
		return;
	}else{
		
		var url='index.php?module=shortlist&type=items&aff=popup&keepThis=true&sads_shortlist_id='+getProductListSelection()+'&sads_ad_type_id='+a+'&add=true';
		//alert(url);
		new Ajax(url, {
		update: 'shortlistitems'
		}).request();
		
		//On cree un effet pour dire que l'annonce a ete shortlistee
		$('addshortlistbtn'+a).setHTML("Ad Successfully shortlisted");
		var fx = new Fx.Styles('addshortlistbtn'+a, {
			duration: 3500,
			wait: false,
			transition: Fx.Transitions.Quad.easeInOut
		});
		fx.start({
			'background-color': ['#4f4f4f', '#4f4f4f'],
			'opacity': [1, 0]
		})
	}
}
function removeitemtomyshortlist(a){
	//alert("add"+a);
	if (getProductListSelection().indexOf("please select") == 0){
		TB_show('New Shortlist', 'index.php?module=shortlist&type=new&aff=popup&keepThis=true&height=200&width=350', false)
		return;
	}else{
		var url='index.php?module=shortlist&type=items&aff=popup&keepThis=true&sads_shortlist_id='+getProductListSelection()+'&sads_ad_type_id='+a+'&remove=true';
		//alert(url);
		new Ajax(url, {
		update: 'shortlistitems'
		}).request();
	}
}

