
	
	function addHelight(){
		$("#selected_concierge .my_con_li").unbind("click");
		$("#selected_concierge .my_con_li").click(function() {
			$("#selected_concierge .my_con_li").attr('id', 'my_selection');
			//$(".my_per_concierge_delete").attr("checked", false);
			
			$(this).attr('id', 'hightlighted');
			//$(this).children(".my_per_concierge_delete").attr("checked", true);

		});	
		
	}
	
	function addDelete(){
		$("#selected_concierge .my_per_concierge_remove").unbind("click");
		$("#selected_concierge .my_per_concierge_remove").click(function() {
			removefromslide($(this));
		});	
		$("#my_per_concierge_tree .my_per_concierge_delete_").unbind("click");
		$("#my_per_concierge_tree .my_per_concierge_delete_").click(function() {
			removefromslide($(this));
			$(this).removeClass("my_per_concierge_delete_").addClass("my_per_concierge_add");
			myconciergesetup_();
		});	
		
		
	}
	
	function myconciergesetup_(){
		$("#my_per_concierge_tree .my_per_concierge_add").unbind("click");
		$("#my_per_concierge_tree .my_per_concierge_add").click(function() {
			var thisConid=$(this).parent().attr("conid");
			var user_clone = $(this).parent().clone(false);
			
			var clone_selected=user_clone.children(".my_per_concierge_add").remove();;
			
			user_clone.append("<div id=\"btn_remove\"><img class=\"my_per_concierge_remove\" width=\"14\" height=\"14\" src='/etc/designs/mytransport/images/img_btn_remove.png'></div>");
			user_clone.attr('id', 'my_selection');
			$('#selected_concierge').append(user_clone);
			$(this).removeClass("my_per_concierge_add").addClass("my_per_concierge_delete_");
			$(this).unbind("click");
			addDelete();
			addHelight();
			//$("#my_per_concierge_tree li[conid="+thisConid+"]").children().attr("disabled", true);
			//$(this).parent().hide("slow");
			//updateCookie();
		    
			//refreshLeftNav();
		    document.getElementById("my_person_seq").value="0";
		   // myconciergesetup_();
			
	});	
		
	}
	
	function removefromslide(element){
		
		var thisConid=element.closest('.my_con_li').attr("conid");
		var selected =$("#my_per_concierge_tree li[conid="+thisConid+"]").children();
		selected.attr("checked", false);
//		selected.attr("disabled", false);
		
		$("#selected_concierge li[conid="+thisConid+"]").remove();
		//updateCookie();
		//removeCookiesSVCByInd(thisConid);
		//refreshLeftNav();
		
		
	}
	
	function updateCookie()
	{
		var cameras='';
		$('#selected_concierge li').each(function() {
			var con_id = $(this).attr('conid');
			
			if (cameras == '') 
				cameras += con_id+',';
			else

				cameras += con_id + ',' ;
		});
		
		$('.my_con_li input:not(:checked)').each(function() {
			try {
				var con_id_ = $(this).parent().attr('conid');
				removeCookiesSVCByInd(con_id_);
			} catch(e){}
		});
		
		$.cookie('mtp_svcSeq',cameras,{ expires: 365, path: '/' });
		
		var cookieseq_new =  $.cookie("mtp_svcSeq");
		if(!(cookieseq_new!=null && cookieseq_new!=""))
	    {
			$.cookie('mtp_svcSeq',null,{ expires: 365, path: '/' });
	    }	
		
		refreshLeftNav();
	}

	function initialmyconeierge(){	

		$('#selected_concierge li').remove();
		$("#my_per_concierge_tree").find("input").removeAttr("disabled").removeAttr("checked");	   
		var cookieseq =  $.cookie("mtp_svcSeq"); 
		if(cookieseq!=null && cookieseq!="")
		{
		    document.getElementById("my_person_seq").value="0";
		    var mySplitResult = cookieseq.split(",");
		    var length = parseInt(mySplitResult.length);
	        var j = 0;
	        for(j; j < length; j++)
	        {
	        	var thisConid = mySplitResult[j];
	            if(thisConid!=null && thisConid!="")
	            {
	            	var conid='con_'+thisConid;
					var user_clone = $('#'+conid).clone(false);
					var clone_selected=user_clone.children("input").remove();
					user_clone.append("<div id=\"btn_remove\"><img class=\"my_per_concierge_remove\" width=\"14\" height=\"14\" src='/etc/designs/mytransport/images/img_btn_remove.png'></div>");
					user_clone.attr('id', 'my_selection');
					$('#selected_concierge').append(user_clone);
					$("#my_per_concierge_tree li[conid="+thisConid+"]").children().removeClass("my_per_concierge_add").addClass("my_per_concierge_delete_").attr("checked", true);
					addDelete();
					addHelight();
					//$("#my_per_concierge_tree li[conid="+thisConid+"]").children().attr("disabled", true);	      
					
					
	            }
	        }
	        

		}
		else
		{
		    document.getElementById("right_form_container_config").style.display="block";


		}
	}		
	
	function seqDown(){
		 var current = $('#hightlighted');
		 if(current.length==1){
		  current.next().after(current);
		 }
	}
	
	function seqSelectHelight(thisConid){
	    	if(thisConid!=null && thisConid!="")
 	    	{	
			    var selected =$("#selected_concierge li[conid="+thisConid+"]");			
			    selected .attr('id', 'hightlighted');
			   // selected .children(".my_per_concierge_delete").attr("checked", true);	 
 	    	}
	}
	
	function seqUp(){
		
		var current = $('#hightlighted');
		if(current.length==1){
			current.prev().before(current);
		}
		
	}
	
	function nextConciergeSetup(){
		var thisConid = "";
	    var seq = document.getElementById("my_person_seq").value;
	    var cookieseq =  $.cookie("mtp_svcSeq"); 
	    if(cookieseq!=null && cookieseq!="")
	    {
	        var index = parseInt(seq)+1;
	        var mySplitResult = cookieseq.split(",");
	        var length = parseInt(mySplitResult.length)-1;

	        thisConid = mySplitResult[seq];  
	        
	        if(length>1 && length-1 >=seq)
	        {
	            document.getElementById("my_person_seq").value=index;


	        }


	        setMyConciergeConfig(seq,thisConid);

	    }
	}

	function prevConciergeSetup(){
		var thisConid = "";
	    var seq = document.getElementById("my_person_seq").value;
	    var cookieseq =  $.cookie("mtp_svcSeq"); 
	    if(cookieseq!=null && cookieseq!="")
	    {
	        var index = parseInt(seq)-1;
	        var mySplitResult = cookieseq.split(",");
	        var length = parseInt(mySplitResult.length);
	        
	        if(index <= 0)
	        { 
		        document.getElementById("my_person_seq").value=0;
	        	index = -1;

	        }
	        else
	        {
		        document.getElementById("my_person_seq").value=index;
	            thisConid = mySplitResult[index-1];

	        }
	        setMyConciergeConfig(index,thisConid);
	    }
	}

	function setMyConciergeConfig(seq,thisConid)
	{
	    if(seq>=0)
	    {
	    	document.getElementById("config_title").innerHTML="Loading...";
	        document.getElementById("right_form_container_config").style.display="none";
	        document.getElementById("myconcierge_setup_ajax").style.display="block";
	    }
	    else
	    {
	    	document.getElementById("config_title").innerHTML="Customise MyConcierge";
	        document.getElementById("right_form_container_config").style.display="block";
	        document.getElementById("myconcierge_setup_ajax").style.display="none";
	    }


	     if('A'==thisConid)
	     {
	     	var url_ajax = document.getElementById("ajax_cof_Path_A").value;
	        $.get(url_ajax, function(data){
	        	document.getElementById("config_title").innerHTML="Customise LTA Fees and Fines Alert";
	        	document.getElementById('myconcierge_setup_ajax').innerHTML = data;
	        	intiLtafine();
	        });           
	     }

	     
	     if('B'==thisConid)
	     {
		     	var url_ajax = document.getElementById("ajax_cof_Path_B").value;
		        $.get(url_ajax, function(data){
		        	document.getElementById("config_title").innerHTML="Customise Traffic News";
		            document.getElementById('myconcierge_setup_ajax').innerHTML = data;
		            intiTrafficNewsConfig();
		        }); 
	     }

	     
	     if('C'==thisConid)
	     {
		     	var url_ajax = document.getElementById("ajax_cof_Path_C").value;
		        $.get(url_ajax, function(data){
		        	document.getElementById("config_title").innerHTML="Customise Traffic Cameras";
		            document.getElementById('myconcierge_setup_ajax').innerHTML = data;
		            initTraficCamerConfig();
		        }); 
	     }

	     if('D'==thisConid)
	     {
		     	var url_ajax = document.getElementById("ajax_cof_Path_D").value;
		        $.get(url_ajax, function(data){
		        	document.getElementById("config_title").innerHTML="Customise Bus Arrival Times";
		            document.getElementById('myconcierge_setup_ajax').innerHTML = data;
		            intiBusArrivalConfig();
		        }); 
	     }           

	     
	     if('E'==thisConid)
	     {
		     	var url_ajax = document.getElementById("ajax_cof_Path_E").value;
		        $.get(url_ajax, function(data){
		        	document.getElementById("config_title").innerHTML="Customise Parking Guidance System";
		            document.getElementById('myconcierge_setup_ajax').innerHTML = data;
		            initPGSconfig();
		        }); 
	     } 

	     if('F'==thisConid)
	     {
		     	var url_ajax = document.getElementById("ajax_cof_Path_F").value;
		        $.get(url_ajax, function(data){
		        	document.getElementById("config_title").innerHTML="Customise ERP Rates";
		            document.getElementById('myconcierge_setup_ajax').innerHTML = data;
		            intiErpRateConfig();
		        }); 
	     }   

	     
	     if('G'==thisConid)
	     {
		     	var url_ajax = document.getElementById("ajax_cof_Path_G").value;
		        $.get(url_ajax, function(data){
		        	document.getElementById("config_title").innerHTML="Customise LTA Road Tax Expiry Alert";
		            document.getElementById('myconcierge_setup_ajax').innerHTML = data;
		        }); 
	     }

	     
	     if('H'==thisConid)
	     {
		     	var url_ajax = document.getElementById("ajax_cof_Path_H").value;
		        $.get(url_ajax,
		                function(data){
		                     document.getElementById('myconcierge_setup_ajax').innerHTML = data;
		                     
		                }
		        ); 
	     }


	}
	
	function removeCookiesSVCByInd(indicator)
	{
	    if('A'==indicator)
	    {
	    	$.cookie('mtp_LTAFinesAndFeesAlert',null,{ expires: 365, path: '/' });  
		}			
	    if('B'==indicator)
	    {
	    	$.cookie('1m_trafficNews_inType',null,{ expires: 365, path: '/' });
	    	$.cookie('1m_trafficNews_kw',null,{ expires: 365, path: '/' });
		}
	    if('C'==indicator)
	    {
	    	 $.cookie('1m_trafficCamera_fvr',null,{ expires: 365, path: '/' });
		}		    
	    if('D'==indicator)
	    {
	    	$.cookie('ptp_busArrivalTime_fvr', null, { expires: 365, path: '/' });
		}
	    if('E'==indicator)
	    {
			$.cookie('1m_PGS_fvr',null,{ expires: 365, path: '/' });
		}
	    if('F'==indicator)
	    {
	    	$.cookie('1m_ERP_fvr', null, { expires: 365, path: '/' });
		}	
	    if('G'==indicator)
	    {
	    	$.cookie('mtp_LTARoadTaxAlert',null,{ expires: 365, path: '/' }); 
		}		    
	}
			
			
			
	
	
	
