/*
	Tämä funktio poistaa ne eMediate -bannerivaraukset joille ei löydy varattua kampanjaa ja
	lisää wmode=transparent -arvon kaikille object ja embed -tägeille.
*/

var emfx = {
	REQUIRED_PROTOTYPE: '1.6.0.3',
	REQUIRED_JQUERY: '1.2.6',
	init : function() {
    function convertVersionString(versionString) {
			var v = versionString.replace(/_.*|\./g, '');
	    v = parseInt(v + '0000'.substring(0,4-v.length));
	    return versionString.indexOf('_') > -1 ? v-1 : v;
	  }

		if ((typeof Prototype=='undefined') || (typeof Element == 'undefined') || (typeof Element.Methods=='undefined') || (convertVersionString(Prototype.Version) < convertVersionString(emfx.REQUIRED_PROTOTYPE))) {
			if ((typeof jQuery=='undefined') || (convertVersionString(jQuery.fn.jquery) < convertVersionString(emfx.REQUIRED_JQUERY))) {
        //throw "Neither Prototype 1.6.0.3+ nor JQuery 1.2.6+ found.";
      } else {
        $(document).ready(emfx.load_jquery);
      }
    } else {
      document.observe('dom:loaded', emfx.load_prototype);
    }
	},
	load_prototype : function() {
    $$('.bannerGeneric').each(function(el) {
			if (/No matching campaign/.test(el.innerHTML)) el.hide();
		});
	},
	load_jquery : function() {
    $(".bannerGeneric").filter(function(i) {
      return (/No matching campaign/.test(this.innerHTML));  
    }).hide();
	}
};
emfx.init();
