// registrace
function ajaxRegistrace(f){
    $.post('/ajax/user/register/', {
            AjaxRequest: 1,
            FRMlogin: $('#FRMlogin').val(),
            FRMemail: $('#FRMemail').val(),
            FRMpassword: $('#FRMpassword').val(),
            FRMpassword2: $('#FRMpassword2').val(),
            FRMfirst: $('#FRMfirst').val(),
            FRMlast: $('#FRMlast').val(),
            FRMgender: $('#FRMgender').val(),
            FRMphone: $('#FRMphone').val(),
            FRMaddress: $('#FRMaddress').val(),
            FRMaddress_number: $('#FRMaddress_number').val(),
            FRMzip: $('#FRMzip').val(),
            FRMcity: $('#FRMcity').val(),
            FRMcountry: $('#FRMcountry').val(),
            FRMlanguage: $('#FRMlanguage').val(),
            FRMmailer_check: $('#FRMmailer_check').val(),
            FRMmailer: $('#FRMmailer').val(),
            FRMlicence: $('#FRMlicence').val()
        } , ajaxRegistraceCallback);

        return false;

}

function ajaxRegistraceCallback(data){
    $('#infoWindow').html(data);
}

// odhlaseni
function ajaxLogout(){
    window.location = '/user/logout/';
    return false;
}

// znovuvygenerovani kontrolniho kodu
function ajaxCodeGenerate(){
    $.post('/ajax/user/code/', { generateCode: 1 } , ajaxCodeGenerateCallback );
    return false;
}

function ajaxCodeGenerateCallback(data){
    $('#infoWindow').html(data);
}


// kod na kontrolu emailu
function ajaxCodeSend(){
    $.post('/ajax/user/code/', { code: $('#FRMcode').val() } , ajaxCodeCallback , 'json');
    return false;
}

function ajaxCodeCallback(data){
    if (data.status == 'ALL_OK') {
            window.location.reload();
    } else {
            $.jGrowl(data.msg, {"theme":"error"});
    }
}

function ajaxRestorePassword()
{
	login = $('#FRMlogin').val();
	email = $('#FRMemail').val();
	referrer = $('#referrer').val();

	$.post('/ajax/user/restore/', {login:login, email:email, referrer:referrer}, ajaxRestorePasswordCallback, 'json');
}

function ajaxRestorePasswordCallback(data)
{
	if (data.status == 'ALL_OK')
	{
		window.location.reload();
	} else {
		$.jGrowl(data.msg, {"theme":"error"});
	}
}

function insert_flash (file,width,height,flashvars,winmode,id,classs,alternative) {
	var shockmode = false;
	if(id!=''){
		id=" id=\""+id+"\"";
	}
	if(classs!=''){
		classs=' class="'+classs+'"';
	}
	var mimetype = 'application/x-shockwave-flash';

	if (navigator.mimeTypes) {
		if (navigator.mimeTypes[mimetype] != null) {
			if (navigator.mimeTypes[mimetype].enabledPlugin != null) {
				shockmode = true;
		      }
		}
	}
	if (!shockmode && navigator.appVersion.indexOf('MSIE') !=-1) {
		shockmode = true;
	}
	if (shockmode) {
		document.write("<object"+id+" type=\"application/x-shockwave-flash\" data=\""+file+"\""+classs+" width=\""+width+"\" height=\""+height+"\">");
		document.write("<param name=\"movie\" value=\""+file+"\" />");
		document.write("<param name=\"menu\" value=\"false\" />");
		document.write("<param name=\"wmode\" value=\""+winmode+"\" />");
		document.write("<param name=\"\allowScriptAccess\" value=\"always\" />");
		if(flashvars!=''){
			document.write("<param name=\"flashvars\" value=\""+flashvars+"\" />");
		}
		document.write(alternative);
		document.write("</object>");
	}
	else {
		document.write(alternative);
	}
}

function newWin(URL) {
	 okno=window.open(URL,'blank');
	 okno.focus();
	 return false;
}
