function controlBrowser_support(){
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))	{ 	//test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ieversion < 7) showErrorDiv = true;
	}
}// controlBrowser_support()


function setScreenParams(){
	s_width = $(window).width();
	s_height = $(window).height();
}// setScreenParams()


function updateAll_withAjax(url){
	$("#formDiv").load(url,function() {
		actCont = eval(document.mixMatch.actCont.value);
		$('#container').tabs(actCont, {fxFade: true, fxSlide: true, fxSpeed: 'normal' });

		$.fn.nyroModal.settings.debug = false;
		$.fn.nyroModal.settings.modal = false;

		onLoadPage_function();
		updateImages_withAjax();
	});
}// updateAll_withAjax(url)


function updateImages_withAjax(){
  	setScreenParams();

	document.mixMatch.actCont.value = $('#container').activeTab();
   	str = $("form").serialize();
	ajaxUrl = mixMatch_images_file + "?" + str + "&win_w="+s_width+"&win_h="+s_height;

	$.ajax({
		url: ajaxUrl,
		dataType: 'html',
		cache: true,
		success: function(html){
			$("#imagesDiv_" + index).html(html);
		}, // function succes
		complete: function(){
			if (index == 0) {
				$("#imagesDiv_0").show();
				$("#imagesDiv_1").hide();
				index = 1;
			}else{
				$("#imagesDiv_1").show();
				$("#imagesDiv_0").hide();
				index = 0;
			};
		}// function complete
	});// ajax()
}// updateImages_withAjax()


function submitMyForm(submitFile) {
	document.mixMatch.action = submitFile;
	document.mixMatch.actCont.value = $('#container').activeTab();
	if (submitFile != "mm_main.php") {
		showNyroModal();
	} else {
       	updateImages_withAjax();
	}
}// submitMyForm


function remove_backgroundImage()
{
	$("#bg").val('');

	document.mixMatch.actCont.value = $('#container').activeTab();
	str = $("form").serialize();

	ajaxUrl = mixMatch_form_file + "?" +  str + "&win_w="+s_width+"&win_h="+s_height;
	updateAll_withAjax(ajaxUrl);
}// remove_backgroundImage()


function showNyroModal(){
   	setScreenParams();

	$.fn.nyroModal.settings.width = s_width - 50;
	$.fn.nyroModal.settings.height = s_height - 50;

	$("#mixMatch").nyroModalManual();
}// showNyroModal()


function callAjax(param)
{
	setScreenParams();

	if (param=='reset') document.mixMatch.send.value = "reset";
	if (param=='mminch') document.mixMatch.send.value = "mminch";
	document.mixMatch.actCont.value = $('#container').activeTab();
	str = $("form").serialize();

	ajaxUrl = mixMatch_form_file + "?" +  str + "&win_w="+s_width+"&win_h="+s_height;
	updateAll_withAjax(ajaxUrl);
}// callAjax()


function onresizeFce(){
	updateImages_withAjax();		// -- prekresleni images ---

	pos_y = Math.max(10, Math.round((s_height - ajaxFormDiv_height) / 2));
	$("#ajaxFormDiv").css("top", pos_y);
}// onresizeFce()


function open_nyroModalWin_account(width, height, minWidth, minHeight, typeOfModal, urlString, actionEndRemove){
	$.ajax({
		url: "functions/ajax/controlAccount_isLogin.php",
		dataType: 'text',
		cache: true,
		success: function(msg){
			if (msg == "true") {
				open_nyroModal(width, height, minWidth, minHeight, typeOfModal, urlString, actionEndRemove);
			}else{
				$.ajax({
					url: 'functions/ajax/set_actualQueryString.php?' + $('#mixMatch').serialize(),
					dataType: 'text',
					cache: true,
					success: function(msg){
						urlString = 'login.php?timeout=true';
						window.location.href = urlString;
					}
				});
			}

			return false;
		} // function succes
	});// ajax()
}// open_nyroModalWin_account


function open_nyroModal(width, height, minWidth, minHeight, typeOfModal, urlString, actionEndRemove)
{
	$.fn.nyroModal.settings.width = width;
	$.fn.nyroModal.settings.height = height;
	$.fn.nyroModal.settings.minWidth = minWidth;
	$.fn.nyroModal.settings.minHeight = minHeight;

	switch(typeOfModal){
		case "submitForm":
			$('#mixMatch').nyroModalManual({
				endRemove: function(elts, settings){
					document.mixMatch.action = "mm_main.php";
					if (actionEndRemove) action_afterEndRemove_nyroModal(actionEndRemove);
				}
			});
			break;
		case "url":
			$.nyroModalManual({
      			url: urlString,
				endRemove: function(elts, settings){
					document.mixMatch.action = "mm_main.php";
					if (actionEndRemove) action_afterEndRemove_nyroModal(actionEndRemove);
				}
    		});
			break;
	} // switch
}// open_nyroModal()
