$(function () {

    //setTimeout("$('#flashMessage').fadeOut('fast')", 3000);
    if (document.getElementById('graphicsSwf')) {    
    	swfobject.embedSWF('/img/GN_anim.swf', 'graphicsSwf', 200, 150, '8.0.0', false, {}, { menu: false });
    } 

	containerFix();

});

imageBuffer = Array();
function swapPhoto(id) {
    $('#bigPhoto img').attr('src', '/phpthumb/phpThumb.php?src=../img/estate_objects/' + id + '.jpg&w=308&h=231&q=90&zc=1&fltr[]=usm');
    $('#bigPhoto a').attr('href', '/phpthumb/phpThumb.php?src=../img/estate_objects/' + id + '.jpg&w=600&h=600&q=90&fltr[]=usm');
}

function launchScroll(speed) {
    scrollInterval = window.setInterval('scroll(' + speed + ')', 10);
}
function endScroll() {
    try {
        clearInterval(scrollInterval);
    } catch(e) { }
}
function scroll(speed) {
    e = document.getElementById('slideInner');
    e.scrollLeft = e.scrollLeft + speed;
}

function renderTab(type, offer_type) {
    $('#tabSelect div').removeAttr('class');
    $('#tabSelect #' + type).attr('class', 'active');
	/*
    //$('#tab form').fadeOut('fast', function () {
        $.get('/estate_objects/show_ajax_tab/' + type + '?offer_type=' + offer_type, function(data) {
           //$('#tab form').fadeOut('fast', function () {
	            $('#tab').html(data);
	            //$('#tab form').fadeIn('fast');
           //});
        });
    //});
    */
}
function updateDistricts(locality) {
    $('select[name=district]').html('<option value=""></option>');
    for (d = 0; d < districts[locality].length; d++) {
        $('select[name=district]').append('<option value="' + districts[locality][d] + '">' + districts[locality][d] + '</option>');
    }
}

function checkNumberFormat(object) {
    val = object.value;
    val = val.replace(/,/g, '.');
    val = val.replace(/[^0-9\.]/g, '');
    object.value = val;
} 

function containerFix() {
	selectors = $('#specialOffer, #recommendedOffer');
	if ($('#container').height() < $('html').height() - 120 && selectors.length == 0) {
		$('#container').height($('html').height() - 1 - $('#homepageDisclaimer').height());	
		//alert($('#container').width());		
	}
}
