// cant use id as tag: browser issues with - before length
function tagitem(cknumber){
    //alert("hh");
var wishg2;
wishg2=Cookie.read('wishg2');
	if (!wishg2){ 
	wishg2='';
	}
    if (wishg2.indexOf(cknumber) == -1){
    wishg2=wishg2+cknumber+":";
    cookie_done=Cookie.make('wishg2',wishg2,{
            expires:7,
		    path:'/'});
    update_wish_list();
   $("#fav-message").dialog('open');
   setTimeout(function(){ 
   $("#fav-message").dialog("close"); 
   }, 1500);  
    }else{
    // already added
   $("#fav-message-duplicate").dialog('open');
   setTimeout(function(){ 
   $("#fav-message-duplicate").dialog("close"); 
   }, 1500); 

    }

return;
}

function untagitem(cknumber){
var cknumber;
var wishg2=Cookie.read('wishg2');
//alert(wishg2);
if (!wishg2){ wishg2='';}
	if (wishg2.length >=3){
	var	position=wishg2.indexOf(cknumber+":");
		
			if (position!==-1){; // test if empty or cookie missing
			wishg2=wishg2.substring(0,position)+wishg2.substring(position+((cknumber+":").length),wishg2.length); // remove selected item
			
			//alert("wishg2.length "+wishg2.length);
			if (wishg2.length==0){ wishg2='@';} // cant have empty in IE or saves all cookies
			cookie_done=Cookie.make('wishg2',wishg2,{
        	expires:24,
			path:'/'});
			}
	}
    
update_wish_list();

//alert(wishg2);
//update_compare();
//var $tabs = $('#tabs_centre').tabs();
//$tabs.tabs('select', 1); // switch to 2nd tab 
$("#compare").load("compare_form.php")
}

function update_wish_list(){
wishg2=Cookie.read('wishg2');if (!wishg2){ wishg2='';}
wish_array=wishg2.split(":");
wish_number=wish_array.length-1;
//eval("document.getElementById('w1').value=wish_number");
$("#favourites_tab").html("Favourites ("+wish_number+")" );
$("#dialog_fav_count").html("<br />Total Items("+wish_number+")" );
}

function clear_fav(){
cookie_done=Cookie.make('wishg2','',{
        expires:-12,
		path:'/'});
update_wish_list();
}

