

function initOverlay(selector) {

		
		var api = $(selector).overlay({ 
 
			expose: 'darkgrey', 
			effect: 'default',
			api:	true,
			 
			onBeforeLoad: function() { 
				// grab wrapper element inside content
				var wrap = this.getContent().find(".contentWrap");
				var self = this;
		
				// load the page specified in the trigger
					wrap.load(this.getTrigger().attr("href"), function(){
						$('.close', this).click(function(){self.close()});
					}); // end wrap.load
			}//end overlay.onBeforeLoad
			
	 
		});
		
		return api;
 
    
}

 // fade out flash messages after 3 seconds  
function fadeMe(msgType) {
	$(".flash_"+msgType).animate({opacity: 1.0}, 3000).fadeOut();  
}
			
function initMask() {
		
		
		$(".p-mask").each( function () {
			$(this).unmaskMoney();
			$(this).maskMoney({thousands:""});
		
		});
		
}

function showMore($prefix) {
	if ($prefix == '') return;
	
	$idMoreLink = $prefix + '_' + 'show_more_link';
	$idLessLink = $prefix + '_' + 'show_less_link';
	$idShow		= $prefix + '_' + 'show_more';

	$('#'+$idShow).slideDown();
	$('#'+$idMoreLink).hide();
	$('#'+$idLessLink).show();
	//Effect.BlindDown($idShow);
	//$($idMoreLink).hide();
	//$($idLessLink).show();

}


function showLess($prefix) {
	if ($prefix == '') return;
	
	$idMoreLink = $prefix + '_' + 'show_more_link';
	$idLessLink = $prefix + '_' + 'show_less_link';
	$idHide		= $prefix + '_' + 'show_more';

	$('#'+$idShow).slideUp();
	$('#'+$idMoreLink).show();
	$('#'+$idLessLink).hide();

	Effect.BlindUp($idHide);
	$($idMoreLink).show();
	$($idLessLink).hide();

}

var error = false;
		
function startLoading() {
	error= false;
	Element.show('loading');
}

function endLoading() {
	Element.hide('loading');
}

function toggleAdFormat() {
	
	//var element = event.element();
	var val = $('MediafileTypeId').getValue();
	if (val > 1) {
		Effect.BlindDown('AdFormat');
		
		
	}
	else {
		
		$('MediafileAdFormatId').setValue('');
		Effect.BlindUp('AdFormat');
		
		
	}
	
	//alert(val);
	
}

Rot13 = {
    map: null,

    convert: function(a) {
        Rot13.init();

        var s = "";
        for (i=0; i < a.length; i++) {
            var b = a.charAt(i);
            s += ((b>='A' && b<='Z') || (b>='a' && b<='z') ? Rot13.map[b] : b);
        }
        return s;
    },

    init: function() {
        if (Rot13.map != null)
            return;
              
        var map = new Array();
        var s   = "abcdefghijklmnopqrstuvwxyz";

        for (i=0; i<s.length; i++)
            map[s.charAt(i)] = s.charAt((i+13)%26);
        for (i=0; i<s.length; i++)
            map[s.charAt(i).toUpperCase()] = s.charAt((i+13)%26).toUpperCase();

        Rot13.map = map;
    },

    write: function(a) {
        document.write(Rot13.convert(a));
    }
}



