if(typeof(EZDATA) == 'undefined') { EZDATA = {}; }


ezQuery(document).ready(function(){
	ezQuery(".ez-mainContent").prepend('<p class="ez-pageLabel"></p>');
	ezQuery(".ez-pageLabel").html(EZDATA.pageLabel);
    ezQuery(".ez-search-sort").appendTo(".ez-search-details");
    ezQuery(".ez-search-sort").css("display", "block");
	
    //move channel title to top
    ezQuery(".ez-itemMod-item .ez-main .ez-metaextra1").each(function() {
        var c = ezQuery(this);
        ezQuery(c.parent().parent()).prepend(c);
    });
	
	// add on country code to specific href links
	ezQuery(".ez-relatedTopics a").each(function() {
        EZDATA.addCountry(ezQuery(this));
    });
	ezQuery(".ez-Video a").each(function() {
        EZDATA.addCountry(ezQuery(this));
    });
    ezQuery(".ez-Image a").each(function() {
        EZDATA.addCountry(ezQuery(this));
    });
    ezQuery(".ez-breadcrumb a").each(function() {
        EZDATA.addCountry(ezQuery(this));
    });
    ezQuery(".ez-letter-index a").each(function() {
        EZDATA.addCountry(ezQuery(this));
    });
    ezQuery(".ez-listMod-page a").each(function() {
		EZDATA.addCountry(ezQuery(this));
	});
    ezQuery(".ez-listMod-folder a.ez-folder-link").each(function() {
        EZDATA.addCountry(ezQuery(this));
    });
});

// adds country code param to URL's
EZDATA.addCountry = function(obj){
	var link = obj.attr("href");
	// remove last character if it's "/"
	if (link.charAt(link.length - 1) == "/") {
	    link = link.substring(0, link.lastIndexOf("/"));
	}
    var delim = "&";
    if (link.indexOf("?") == -1) {
        delim = "?";
    }
    if (EZDATA.countryCode != "" && EZDATA.countryCode != "undefined") {
       obj.attr("href", link + delim + "c=" + EZDATA.countryCode);
    }
};

