﻿function addItme(even,sel)
{
    var qs=$(sel+' q');
    var itme=$(even).html();
    exit=false;
    $.each(qs, function(i, n){
        if($(n).html()==itme)
            exit=true;
    });
    if(exit)return;
    $.each(qs, function(i, n){
        if($(n).html()=="&nbsp;"){ 
            $(n).html(itme);
            return false;
        }
    });
}
function delItem(e){
    $(e).html("&nbsp;");
}

function findJob(){
    var qs=$(".findCity q");
    var citys=[],pros=[];
    $.each(qs, function(i, n){
        if($(n).html()!="&nbsp;"){
                citys[citys.length]=$(n).html();
        }
    });
    qs=$(".findPro q");
    $.each(qs, function(i, n){
        if($(n).html()!="&nbsp;"){
                pros[pros.length]=$(n).html();
        }
    });
   if(citys.length==0){return alert('请选择城市');}
   if(pros.length==0){return alert("请选择关键词");}
   try{
    var job=JSON.parse($.cookie('jobPaging'));
   
    job['where']['citys']=citys;
    job['where']['pros']=pros;
    job['current']=0;
    $.cookie('jobPaging',JSON.stringify(job) );
   }
   finally
   {
        location=location.pathname;
   }
   
}
function findClear()
{
    $.cookie('jobPaging','');
    location=location.pathname;
}
$(document).ready(function(){
    $("#citys a").bind("click",function(){addItme(this,'.findCity');});
    $("#pros a").bind("click",function(){addItme(this,'.findPro');});
    
    $(".findCity q").click( function () { delItem(this);}).hover(
            function () {$(this).css("color","red"); },
            function () {$(this).css("color","");}
            );
    $(".findPro q").click( function () { delItem(this);}).hover(
            function () {$(this).css("color","red"); },
            function () {$(this).css("color","");}
            );
});

