function show_news_administration(mod_id) {
	jQuery('#news_administration_menu_' + mod_id).toggle();
}
function image_popup(which, max_width, max_height, image_height) {

	var cH = document.documentElement.clientHeight;
	var ScrollTop = document.body.scrollTop;
	if (ScrollTop == 0) {
	    if (window.pageYOffset)
	        ScrollTop = window.pageYOffset;
	    else
	        ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	//alert(ScrollTop);
	var div = document.createElement('div');
	div.setAttribute('id', 'popup_master_div');
	div.className = 'image_popup_div';

	var img = document.createElement('img');
	if (which.src) {
		img.setAttribute('src', which.src);
	} else {
		img.setAttribute('src', which);
	}
	img.setAttribute('id', 'img_popup');
	//img.setAttribute('onclick', 'removeImagePopup()');
	div.appendChild(img);
	document.getElementsByTagName('BODY')[0].appendChild(div);

	//alert(img.offsetWidth);
	setTimeout(function() {


		jQuery('#img_popup').click(function() {
			removeImagePopup();
		});

		var imgH = img.offsetHeight;
		var imgW = img.offsetWidth;
		var divH = div.offsetHeight;
		var divW = div.offsetWidth;



		if (image_height != null) {
			var centerY = image_height/2;
		} else {
			var centerY = Math.round(cH/2);
		}
		//imgH = jQuery('#img_popup').css('height');
		//imgW = jQuery('#img_popup').css('width');

		if(imgH > divH) {
			jQuery('#img_popup').css('height', divH);
		}
		if(imgW > divW) {
			jQuery('#img_popup').css('width', divW);
		}

		//alert(imgH + ':' + imgW);
		jQuery('#img_popup').css('height', '1px');
		jQuery('#img_popup').css('width',  '1px');
		jQuery('#popup_master_div').css('width', '1px');
		jQuery('#popup_master_div').css('height', '1px');
		jQuery('#popup_master_div').css('left', jQuery('#popup_master_div').css('left'));
		jQuery('#popup_master_div').css('top', centerY + 'px');

		jQuery('#popup_master_div').css('margin', ScrollTop + 'px 0 0 0');

		$('popup_master_div').morph({width: imgW + 'px', height: imgH + 'px'});
		$('img_popup').morph({width: imgW + 'px', height: imgH + 'px'});
		new Effect.Opacity('popup_master_div', { from: 0.01, to: 0.99});
		new Effect.Move('popup_master_div', { x: '-' + Math.round(parseInt(imgW)/2), y: '-' + Math.round(parseInt(imgH)/2), mode: 'relative' });
	}, 100);

}
function removeImagePopup() {
	jQuery('#popup_master_div').css('background-color', 'transparent');
	new Effect.Puff('img_popup', {duration: 0.7});
	setTimeout(function() {
		jQuery('#popup_master_div').remove();
	}, 720);
}
function offerPopup(width, height) {

	//var imgW = jQuery('.oferta_master')[0].offsetWidth + 'px';
	var imgW = '802px';
	var imgH = (jQuery('#jobOffer_body')[0].offsetHeight + jQuery('.offer_window_top')[0].offsetHeight + jQuery('.offer_window_footer')[0].offsetHeight) + 'px';

	jQuery('#jobOffer').css('width', imgW);
	jQuery('#jobOffer').css('height', imgH);
	jQuery('#jobOffer').css('overflow', 'hidden');
	jQuery('#jobOffer').css('width', '1px');
	jQuery('#jobOffer').css('height', '1px');
	jQuery('#jobOffer').css('left', Math.round(document.documentElement.clientWidth/2));
	jQuery('#jobOffer').css('top', '10px');

	setTimeout(function() {
		$('jobOffer').morph({width: imgW, height: imgH});
		new Effect.Opacity('jobOffer', { from: 0.01, to: 0.99});
		new Effect.Move('jobOffer', { x: '-' + Math.round(parseInt(imgW)/2), y: 0, mode: 'relative' });
	}, 700);

}
function post_copy(id) {
	jQuery('#answer').val(jQuery('#content'+id).html());
	return false;
}
function captcha_choice(which) {
	if(jQuery('input[name=captcha]').val() == "") {
		jQuery('input[name=captcha]').val(jQuery(which).html());
	}
	else {
		jQuery('input[name=captcha]').val(jQuery('input[name=captcha]').val() + ', ' + jQuery(which).html());
	}
}
function login(url) {
	window.location = url;
}
function login_pannel(mod_id) {
	jQuery('#ultra_modules_' + mod_id + '_body').toggle();
	return false;
}
function change_module_header(which, moduleId) {
	jQuery('#ultra_modules_' + moduleId + '_head').attr('id', 'ultra_modules_' + moduleId + '_head_' + which);
}
String.prototype.htmlspecialchars_decode = function(quote_style){
    // Convert special HTML entities back to characters
    //
    // version: 1003.2411
    // discuss at: http://phpjs.org/functions/htmlspecialchars_decode    // +   original by: Mirek Slugen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Mateusz "loonquawl" Zalega
    // +      input by: ReverseSyntax
    // +      input by: Slawomir Kaniecki    // +      input by: Scott Cariss
    // +      input by: Francois
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)    // +      input by: Ratheous
    // +      input by: Mailfaker (http://www.weedem.fr/)
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: htmlspecialchars_decode("<p>this -&gt; &quot;</p>", 'ENT_NOQUOTES');    // *     returns 1: '<p>this -> &quot;</p>'
    // *     example 2: htmlspecialchars_decode("&amp;quot;");
    // *     returns 2: '&quot;'
    var optTemp = 0, i = 0, noquotes= false;
    if (typeof quote_style === 'undefined') {        quote_style = 2;
    }
    string = this.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
    var OPTS = {
        'ENT_NOQUOTES': 0,        'ENT_HTML_QUOTE_SINGLE' : 1,
        'ENT_HTML_QUOTE_DOUBLE' : 2,
        'ENT_COMPAT': 2,
        'ENT_QUOTES': 3,
        'ENT_IGNORE' : 4    };
    if (quote_style === 0) {
        noquotes = true;
    }
    if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags        quote_style = [].concat(quote_style);
        for (i=0; i < quote_style.length; i++) {
            // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
            if (OPTS[quote_style[i]] === 0) {
                noquotes = true;            }
            else if (OPTS[quote_style[i]]) {
                optTemp = optTemp | OPTS[quote_style[i]];
            }
        }        quote_style = optTemp;
    }
    if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
        string = string.replace(/&#0*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
        // string = string.replace(/&apos;|&#x0*27;/g, "'"); // This would also be useful here, but not a part of PHP
    }
    if (!noquotes) {
        string = string.replace(/&quot;/g, '"');
    }
    // Put this in last place to avoid escape being double-decoded    string = string.replace(/&amp;/g, '&');

    return string;
};

var Base64 = {

	    // private property
	    _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	    // public method for encoding
	    encode : function (input) {
	        var output = "";
	        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
	        var i = 0;

	        input = Base64._utf8_encode(input);

	        while (i < input.length) {

	            chr1 = input.charCodeAt(i++);
	            chr2 = input.charCodeAt(i++);
	            chr3 = input.charCodeAt(i++);

	            enc1 = chr1 >> 2;
	            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
	            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
	            enc4 = chr3 & 63;

	            if (isNaN(chr2)) {
	                enc3 = enc4 = 64;
	            } else if (isNaN(chr3)) {
	                enc4 = 64;
	            }

	            output = output +
	            this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
	            this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

	        }

	        return output;
	    },

	    // public method for decoding
	    decode : function (input) {
	        var output = "";
	        var chr1, chr2, chr3;
	        var enc1, enc2, enc3, enc4;
	        var i = 0;

	        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	        while (i < input.length) {

	            enc1 = this._keyStr.indexOf(input.charAt(i++));
	            enc2 = this._keyStr.indexOf(input.charAt(i++));
	            enc3 = this._keyStr.indexOf(input.charAt(i++));
	            enc4 = this._keyStr.indexOf(input.charAt(i++));

	            chr1 = (enc1 << 2) | (enc2 >> 4);
	            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
	            chr3 = ((enc3 & 3) << 6) | enc4;

	            output = output + String.fromCharCode(chr1);

	            if (enc3 != 64) {
	                output = output + String.fromCharCode(chr2);
	            }
	            if (enc4 != 64) {
	                output = output + String.fromCharCode(chr3);
	            }

	        }

	        output = Base64._utf8_decode(output);

	        return output;

	    },

	    // private method for UTF-8 encoding
	    _utf8_encode : function (string) {
	        string = string.replace(/\r\n/g,"\n");
	        var utftext = "";

	        for (var n = 0; n < string.length; n++) {

	            var c = string.charCodeAt(n);

	            if (c < 128) {
	                utftext += String.fromCharCode(c);
	            }
	            else if((c > 127) && (c < 2048)) {
	                utftext += String.fromCharCode((c >> 6) | 192);
	                utftext += String.fromCharCode((c & 63) | 128);
	            }
	            else {
	                utftext += String.fromCharCode((c >> 12) | 224);
	                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
	                utftext += String.fromCharCode((c & 63) | 128);
	            }

	        }

	        return utftext;
	    },

	    // private method for UTF-8 decoding
	    _utf8_decode : function (utftext) {
	        var string = "";
	        var i = 0;
	        var c = c1 = c2 = 0;

	        while ( i < utftext.length ) {

	            c = utftext.charCodeAt(i);

	            if (c < 128) {
	                string += String.fromCharCode(c);
	                i++;
	            }
	            else if((c > 191) && (c < 224)) {
	                c2 = utftext.charCodeAt(i+1);
	                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
	                i += 2;
	            }
	            else {
	                c2 = utftext.charCodeAt(i+1);
	                c3 = utftext.charCodeAt(i+2);
	                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
	                i += 3;
	            }

	        }

	        return string;
	    }
};