$(document).ready(function() {
	if($.browser.msie) {$('#rightFon').css({'height':'99%','width':'100%'});$('.rightItem').mouseover(function(){rightFon=[$('#rightFon').width(),$('#rightFon').height()];$(this).addClass('back35');$('#rightFon').height(rightFon[1]);$('#rightFon').width(rightFon[0]);$(this).find('a[class!=page],span[class!=page]').addClass('hover');}).mouseout(function(){$(this).removeClass('back35');$('#rightFon').css({'height':'99%','width':'100%'});$(this).find('a,span').removeClass('hover');});}
	else $('.rightItem').mouseover(function(){$(this).addClass('back35');$(this).find('a[class!=page],span[class!=page]').addClass('hover');}).mouseout(function(){$(this).removeClass('back35');$(this).find('a,span').removeClass('hover');});
	var docwidth;
	if($(window).width()<960) docwidth=960;
	else if($(window).width()>1300) docwidth=1300;
	else docwidth=$(window).width();
	$('body').css('fontSize',(docwidth*0.015625)+'px');
	$(window).bind('resize', function() {
		if($(window).width()<960) docwidth=960;
		else if($(window).width()>1300) docwidth=1300;
		else docwidth=$(window).width();
		$('body').css('fontSize',(docwidth*0.015625)+'px');
		//$('.rightCloud').height($(document).height());
	});
	$('input[name="search"]').val($('#msg_search').text()).focus(function(){
		if(this.value==$('#msg_search').text()) this.value='';
	}).blur(function(){
		if(this.value=='') this.value=$('#msg_search').text();
	});


	$('#loading').css({'top':document.documentElement.scrollTop+'px','height':'100%'});
	$(window).scroll(function () {
		$('#loading').css('top',document.documentElement.scrollTop+'px');
	});
	//if($.browser.msie && $.browser.version<7) document.write('Sorry! But this site require IE version greater 6!');
});
var rightFon;

var imgCount=0;
function loadingImg(limit){
	imgCount++;
	if(imgCount>=limit) {
		$('#loading').animate({'opacity':0},1500,'linear',function(){$(this).hide(0);})
	}
}

function contactus(){
    $('#modalWindow').modal({
        overlayClose:true,
        containerCss: {
            width:700,
            height:400,
            'background':'#fff url(/images/loading.gif) center center no-repeat'
        },
        containerId:'simplemodal-container'
    });
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            if(req.responseJS) {
                if(req.responseJS.answer) {
                    $('#modalWindow').html(req.responseJS.answer);
                    $('#simplemodal-container').css('background-image','none');
                }
            }
            if(req.responseText!='') alert(req.responseText);
        }
    }
    req.open(null, '/ajax.php', true);
    req.send( { mode: 'getContactForm',lang:window.location.href } );
    return false;
}
function sendMail(){
    var reqired=$('#getContactForm *[required="1"]');
    var next=true;
    reqired.each(function(){if(this.value==''){$(this).addClass('bad');next=false;}else{$(this).removeClass('bad');}});
    
    if(!next) return false;
    var form = $('#getContactForm').get(0);
       
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            if(req.responseJS) {
                if(req.responseJS.answer) {
                    $('#modalWindow').html(req.responseJS.answer);
                    $('#modalWindow').modal({
                        overlayClose:true,
                        containerCss: {
                            width:700,
                            height:400
                        }
                    });
                }
            }
            if(req.responseText!='') alert(req.responseText);
        }
    }
    req.open(null, '/ajax.php', true);
    req.send( { mode: 'getContact',form:form,lang:window.location.href } );
}
