$(function(){
 jQuery.expr[':'].Contains = function(a, i, m) {return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0;};


    $("textarea").attr("style","height: 138px;");
    $(".basket div").attr("style","");
    $(".basket table").attr("width","").attr("style","float: right;");

	$(".seminar_when:last #event_map_container, .seminar_when:last #event_map").attr("style","display: none;");

    var blogContent = $(".blogFeed").html();
        $("#blogFeed").html(blogContent); 

    $(".breadcrumb").each(function(){
        var charReplace = $(this).html();
        charReplace = charReplace.replace("&gt;","|");
        charReplace = charReplace.replace("&gt;","|");
        charReplace = charReplace.replace("&gt;","|");
        charReplace = charReplace.replace("&gt;","|");
        charReplace = charReplace.replace("&gt;","|");
        $(this).html(charReplace);
    });
    
   
    $(".clients .client:nth-child(even)").addClass("even");
    $(".clients .client:last").attr("style","margin-bottom: 10px; float: right;");
    $(".search_result_item:first").attr("style","border-top: 0px;");
    
    $(".content_right .mm_form tr, #home .mm_form tr, .book .mm_form tr").each(function(){
        $("td:first",this).addClass("label");
    });
    $(".content_right .mm_form tr, #home .mm_form tr, .book .mm_form tr").each(function(){
        $("td:last",this).addClass("input");
    });
    
    $(".content_right .mm_form .label, #home .mm_form .label, .book .mm_form .label").wrapInner("<div></div>");
    
    $(".content_right .mm_form input:last, #home .mm_form input:last, .book .mm_form input:last").addClass("SubmitButton");
    
    $(".venues").each(function(){
        var keywords = $(this).text().split(", ");
        for (x=0;x<keywords.length;x++) {
            var keyword = keywords[x];
            var duplicate = $("#venue:Contains('"+keyword+"')").length;
            if (duplicate==0) {
                var button = "<li>"+keyword+"</li>";
                $("#venue").prepend(button);
            }
        }
    });
    
    var pagingItems = Math.ceil(eval($(".seminar").length-3)/3);
    var countItems = 1;
    while (countItems<=pagingItems+1) {
        $(".paging").append("<span id=\""+countItems+"\">"+countItems+"</span>");
        countItems++;
    }
    
    $(".paging span").click(function(){
        $(".paging span").removeClass("active");
        $(this).addClass("active");
        var pageNumber=$(this).attr("id")-1;
        $(".seminars .container .seminar").animate({"top":"-"+eval(pageNumber*459)+"px"});
    }); 
    
    $(".question:first").attr("style","border-top: 1px solid #ccc;");
    
    $(".question .desc").hide();
   $(".question").click(function(){
        if ($(this).children(".desc").is(":visible")) {
            $(this).children(".desc").slideUp();
        } else {
            $(this).children(".desc").slideDown();
        }
    }); 
    
    
    
    var url = window.location.pathname;
    if (url=="/cm/sites/183/default.phuse") {
        
       
    
        } else {
        $("#list").wrapInner("<select id=\"links\"></select>");
        $("#list a").each(function(){
            var link = $(this).attr("href");
            var text = $(this).text();
            $("#links").append("<option value=\""+link+"\">"+text+"</option>\n");
        }).hide();
        
        $("#links").change(function() {
            var newLocation = $("#links option:selected").val();
            window.location=newLocation;
        });
    }
    
    $(".cases .case .title:first").attr("style","border-top: 1px solid #ccc;");
    

    if ($(".seminar_detail").is(":visible")) {
        $(".seminars").hide();
    }
    
    $(".book").hide();
    $(".attend a").removeAttr("href");
    $(".attend").click(function(){
        $(".book").fadeIn();
        $(".attend").hide();
    
    });
    
    $("#venue li").click(function(){
        $(".seminar, .seminar_detail, .seminar_when, .attend_btn").hide();
        $(".seminars").show();
        $(".attend").hide();
	    $(".book").hide();
        
        
        $(".venues:Contains('"+$(this).text()+"')").parent().fadeIn();
        $(".paging").empty().append("Page");
        var pagingItems = Math.ceil(eval($(".seminar:visible").length-3)/3);
        var countItems = 1;
        while (countItems<=pagingItems+1) {
            $(".paging").append("<span id=\""+countItems+"\">"+countItems+"</span>");
            countItems++;
        }
        
        $(".paging span").click(function(){
            $(".paging span").removeClass("active");
            $(this).addClass("active");
            var pageNumber=$(this).attr("id")-1;
            $(".seminars .container .seminar").animate({"top":"-"+eval(pageNumber*460)+"px"});
        });
    });
    
    $(".paging a").each(function(){
        var getStyle = $(this).attr("style");
        if (getStyle=="font-weight: bold; text-decoration: underline;") {
            $(this).css("text-decoration","none").css("color","#162b58");
        }
    });
    
    $(".paging a").each(function(){
        $(this).html($(this).html().replace("Next &gt;","&gt;").replace("&lt; Prev","&lt;"));
    });
    
    $(".video .image").hide()
    var timeout = setTimeout(function() {
            $(".video .flash").hide()
            $(".video .image").fadeIn("slow")
        }, 73000);
    
    
    
   $(".video .image").click(function(){
	    $(this).hide();
	    $(".video .flash").show();
	    var timeout = setTimeout(function() {
            $(".video .flash").hide()
            $(".video .image").fadeIn("slow")
        }, 73000);
	}).hover(function(){
	    $(this).css("cursor","pointer");
	}, function() {
	    $(this).css("cursor","default");
	});
	
	
	
	
	
	
	 
   
    

});