
  $(document).ready(function(){


         $(".tabs-block div.tabbed div").hide();
	$("div.t1").show();
     	$("div.t1 div").show();
	$(".tabbed ul li.t1 a").addClass("tab-current");
	$("div.tabbed ul li a").css("cursor", "pointer");
	$("div.tabbed a").css("cursor", "pointer");



    	 $("ul.tabs li a").click(function() {
	  var thisClass = this.className.slice(0,2);
	  $(".tabs-block div.tabbed div").hide();
	  $(".tabs-block div." + thisClass).show();
      	  $(".tabs-block div." + thisClass+" div").show();
	  $(".tabs-block div.tabbed ul.tabs li a").removeClass("tab-current");
	  $(this).addClass("tab-current");

	});





      var values= new Array();
   $(".selectdelete2").click(function() {
	var newarray=new Array();
	var id=$(this).parent().attr('id');
	$(this).parent().remove();
   });
     
    $("select#edit-filter").change(function(){
        var value=$(this).val();
	$(this).val(0);
	if (values.length<5 && value!=0){
          var inarray=findvalue(value,values);
	   if (inarray==-1){
	     values[values.length]=value;
	     var x=getinfo(value);
	     $("#"+value).remove();
	     $(this).parent().parent().append(x);
	    }

	 $(".selectdelete").click(function() {
		var newarray=new Array();
	 	var id=$(this).parent().attr('id');
                var elementid=findvalue(value,values);

	     	$(this).parent().remove();
		values.remove(elementid);
         });
      }
    });
  });

// Array Remove
   Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};






   function findvalue(item,array){
     var output=-1;
	for(i=0;i<array.length; i++){
  	if(array[i]==item){
	   output=i;
	   i=array.length;
	  }
      }

    return output;
  }


   function getinfo(id){
     result=0;
     $.ajax({
        async: false,
        type: "GET",
        url: "http://www.hipeac.net/fillselect/"+id,
        success: function(pubs) {
            result=pubs;
        }
      });
      return result;
  }
  
  
    



