/* Addons */

String.prototype.replaceAll = function(search, replace)
{
	return this.split(search).join(replace);
}

function uniqId()
{
	return (new Date()).getTime() + "" + Math.random() + "" + Math.random();
}

/* Captcha */

function captchaRefresh(img_id)
{
	$('img#'+img_id).attr("src", "captcha?"+uniqId());
}

/* Functions URL */

function urlConfirm(url, msg) {
	if (confirm(msg))
		window.location = url;
}

function jsConfirm(js, msg) {
	if (confirm(msg))
		eval(js);
}

function urlPopup(p_url, p_w, p_h) {

	var p_left = ($(window).width() - p_w) / 2;
	var p_top = ($(window).height() - p_h) / 2;

	newWin = window.open(p_url, 'newWin', 'location,width='+p_w+',height='+p_h+',left='+p_left+',top='+p_top);
	newWin.focus();
}

/* Navigation & colorbox & misc */

$(document).ready(function() { /* doc ready start */

	/* Form submit */
	$("form").submit(function() {
		$("input[type=submit]:not(.no-auto-disable)").attr({
			'disabled': 'disabled',
			'value': 'Loading...'
		});
	});

	/* slider */
	$('div#mp-area-submenu > div#nivo-slider1 > div.nivoSlider').nivoSlider({
        animSpeed:500,
        pauseTime:3000,
        startSlide:0,
		pauseOnHover:false
    });

	/* colorbox */
	$("a[rel='cb_gallery']").colorbox({
					initialWidth:200,
					initialHeight:50,
					opacity: 0.6,
					maxWidth:'1200px'
	});
	$("a.cb_gallery").colorbox({
					initialWidth:200,
					initialHeight:50,
					opacity: 0.6,
					maxWidth:'1200px'
	});

	/* navigation */
	$("div#mp-area-menu > ul > li.parent").hover(
		function () {
			var left = Math.round($(this).width() / 7);
			$(this).children('div.pContainer').children('div.pMenu')
				.css('left', left)
				.show();
				/*.slideDown(100);*/
		}, 
		function () {
			$(this).children('div.pContainer').children('div.pMenu').hide();
		}
	);

}); /* doc ready end */

