function doLoad(obj, id, size, num) {
	if(num == 1) {
		if(document.getElementById('progress_bar')) {
			document.getElementById('progress_bar').style.display='inline';
		}
		if(document.getElementById('preload_photo')) {
			document.getElementById('preload_photo').style.display='none';
		}
	}
	if(num > 1) {
		if(document.getElementById('progress_bar'+num)) {
			document.getElementById('progress_bar'+num).style.display='inline';
		}
		if(document.getElementById('preload_photo'+num)) {
			document.getElementById('preload_photo'+num).style.display='none';
		}
	}

    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(id).innerHTML = req.responseText;
        }
    }
    req.loader = 'form';
    req.open('POST', 'http://tour24.ru/modules/ajax/preload.php', false);
    req.send({file: obj, upload_width: size, num: num}); 
}

function FindHotel(country_id, category, destination_id) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(destination_id).innerHTML = req.responseText;
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/find_hotel.php', true);
    req.send({country_id: country_id, category: category}); 
}

function ChangeHotels(country_id, destination_id) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(destination_id).innerHTML = req.responseText;
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/change_hotels.php', true);
    req.send({country_id: country_id}); 
}

function ChangeImgCountriesAndHotels(country_id, hotel_id, destination_id) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(destination_id).innerHTML = req.responseText;
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/change_img_countries_and_hotels.php', true);
    req.send({country_id: country_id, hotel_id: hotel_id}); 
}

function OnlineNow(destination_id) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(destination_id).innerHTML = req.responseText;
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/onlinenow.php', true);
    req.send({destination_id: destination_id});

var Func = 'OnlineNow('+'"'+destination_id+'"'+')';
setTimeout(Func, 5000)
}

function ShowHide(destination_id) {
	document.getElementById(destination_id).style.marginTop='-265px';
}
function ShowHide2(destination_id) {
	document.getElementById(destination_id).style.marginTop='-175px';
}
function ShowHide3(destination_id, margin) {
	document.getElementById(destination_id).style.marginTop='-'+margin+'px';
}

function CloseHide(destination_id) {
	document.getElementById(destination_id).style.marginTop='-5265px';
}

lck=0;
function r(hval)
{ if ( lck == 0 ) {
document.addpage.c.value=hval; } }
function l()
{if (lck == 0) { lck = 1; }
else { lck = 0; } }

function fadeOpacity() {
	document.getElementById('black_mask').style.display='inline';
}
function fadeOpacityback() {
	document.getElementById('black_mask').style.display='none';
}
function ShowStar(ImageName, Num) {
	if( document.images ) {
		for(i=1;i<=Num;i++) {
			document.images[ImageName+i].src='http://tour24.ru/pic/star_active.gif';
		}
		for(i=Num+1;i<=5;i++) {
			document.images[ImageName+i].src='http://tour24.ru/pic/star_none.gif';
		}
	}
}
function CloseStar(ImageName, FieldId, Num) {
	if( document.images ) {
		for(i=1;i<=Num;i++) {
			document.images[ImageName+i].src='http://tour24.ru/pic/star_none.gif';
		}
		if(document.getElementById(FieldId).value>0) {
			var checked_star = document.getElementById(FieldId).value;
			for(i=1;i<=checked_star;i++) {
				document.images[ImageName+i].src='http://tour24.ru/pic/star_active.gif';
			}
		}
	}
}
function CheckStar(FieldId, Num) {
	if( document.images ) {
		//document.forms.find_hotel.elements.rating_star.value=Num;
		document.getElementById(FieldId).value=Num;
	}
}
function MaskHeight() {
var h1;
if (navigator.userAgent.match(/gecko/i)) {
	h1 = document.body.clientHeight + 38;
}
else {
	h1 = document.body.clientHeight;
}
document.getElementById('black_mask').style.height=h1+'px';
}


function focusJump() {
document.forms.enter.elements.password.focus();
}

function changeEnterFormType() {
document.getElementById('p1').style.display='none';
document.getElementById('p2').style.display='block';
document.forms.enter.elements.password.focus();
}
function focusJump2() {
document.forms.enter2.elements.password.focus();
}

function changeEnterFormType2() {
document.getElementById('p1_2').style.display='none';
document.getElementById('p2_2').style.display='block';
document.forms.enter2.elements.password.focus();
}
function focusToReg() {
	if(document.forms.register.elements.login) {
		document.forms.register.elements.login.focus();
	}
}

function ClearInput(id, string_value) {
	if(document.getElementById(id).value == string_value) {
		document.getElementById(id).value = '';
	}
}

function ChangeSeasons (month, destination_id) {
	if(month >= 1 && month <=2) {
		season = 1;
	}
	if(month >= 3 && month <=5) {
		season = 2;
	}
	if(month >= 6 && month <=8) {
		season = 3;
	}
	if(month >= 9 && month <=11) {
		season = 4;
	}
	if(month == 12) {
		season = 1;
	}
	if(season) {
		document.getElementById(destination_id).src='http://tour24.ru/i/season_'+season+'.jpg';
	}
if(month == 0) {
	document.getElementById(destination_id).src='http://tour24.ru/i/empty_add_resp.gif';
}
}

function ShowPhotoMask(destination_id) {
	document.getElementById(destination_id).style.display='inline';
}
function HidePhotoMask(destination_id) {
	document.getElementById(destination_id).style.display='none';
}

function HideSelectsIshak(id1, id2, mode) {
	if(mode == 1){
		if (navigator.userAgent.match(/gecko/i)) {
		}
		else {
			if(document.getElementById(id1)){document.getElementById(id1).style.display='none'; document.getElementById('vis_lie_1').style.display='inline';}
			if(document.getElementById(id2)){document.getElementById(id2).style.display='none'; document.getElementById('vis_lie_2').style.display='inline';}
		}
	}
	if(mode == 2) {
		if (navigator.userAgent.match(/gecko/i)) {
		}
		else {
			if(document.getElementById(id1)){document.getElementById(id1).style.display='inline'; document.getElementById('vis_lie_1').style.display='none';}
			if(document.getElementById(id2)){document.getElementById(id2).style.display='inline'; document.getElementById('vis_lie_2').style.display='none';}
		}
	}
}

function TimeZones(id, width, height){
	var top;
	var left;
	top=(screen.height-height-300)/2;
	left=(screen.width-width)/2;
	info_form=window.open("http://tour24.ru/static/timezones.php?id="+id, id, "top="+top+",left="+left+",width="+width+", height="+height+", status=0, menubar=0, location=0 resizable=0 directories=0 toolbar=0");
	info_form.focus();
}


function Find(val, country_id, city_id, rating, destination_id) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(destination_id).innerHTML = req.responseText;
            document.getElementById('pager').style.display = 'none';
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/find.php', true);
    req.send({val: val, country_id: country_id, city_id: city_id, rating: rating}); 
}

function AddSmile (destination_id, string) {
	if(string == "") {document.getElementById(destination_id).value='';}
	else {document.getElementById(destination_id).value = document.getElementById(destination_id).value+' '+string+' ';}
}

function ResponseSearch(country_id, city_id, destination_id) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(destination_id).innerHTML = req.responseText;
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/response_search.php', true);
    req.send({country_id: country_id, city_id: city_id}); 
}

function ChangeModes(destination_id, id) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(destination_id).innerHTML = req.responseText;
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/change_modes.php', true);
    req.send({destination_id: destination_id, id: id}); 
}

function ActiveScrollLeft(destination_id, step) {
var old = document.getElementById(destination_id).style.marginLeft;
if(!old) { old = '0px'; }
var oldmarg = old.split('px');
var oldmarg = oldmarg[0];
if(!oldmarg) { oldmarg = 0; }

	var newmarg = oldmarg - (Math.abs(oldmarg)+1);
	if(Math.abs(newmarg) > Math.abs(step)) {
		var newmarg = '-'+step;
		var er = 1;
	}
	document.getElementById(destination_id).style.marginLeft = newmarg+'px';

var Func = 'ActiveScrollLeft('+'"'+destination_id+'"'+', '+'"'+step+'"'+')';
if(er != 1) {setTimeout(Func, 50)}
}

function ActiveScrollRight(destination_id, step) {
var old = document.getElementById(destination_id).style.marginLeft;
if(!old) { old = '0px'; }
var oldmarg = old.split('px');
var oldmarg = oldmarg[0];
if(!oldmarg) { oldmarg = 0; }

	var newmarg = Math.abs(oldmarg) - (1 + (step - Math.abs(oldmarg)));
	if(newmarg > 0) {
		var newmarg = '-'+newmarg;
	}
	else {
		var newmarg = 0;
		var er = 1;
	}
	document.getElementById(destination_id).style.marginLeft = newmarg+'px';


var Func = 'ActiveScrollRight('+'"'+destination_id+'"'+', '+'"'+step+'"'+')';
if(er != 1) {setTimeout(Func, 50)}
}

function ClearVoteStars() {
	for(i=1;i<=5;i++) {
		document.images['rate'+i].src='http://tour24.ru/pic/star_none.gif';
	}
}

function Vote(destination_id, contest_id, page_id, object_id, mark) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(destination_id).innerHTML = req.responseText;
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/vote.php', true);
    req.send({contest_id: contest_id, page_id: page_id, object_id: object_id, mark: mark}); 
}

function ChangeCaptcha(destination_id) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(destination_id).innerHTML = req.responseText;
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/changecaptcha.php', true);
    req.send({destination_id: destination_id}); 
}

function ChangePages(destination_id, page) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(destination_id).innerHTML = req.responseText;
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/changepages.php', true);
    req.send({page: page, destination_id: destination_id}); 
}

function UpBalls(id, balls) {
	document.getElementById('upballs_'+id).style.display='none'; 
	document.getElementById('balls_'+id).innerHTML = balls;

    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            //document.getElementById(destination_id).innerHTML = req.responseText;
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/upballs.php', true);
    req.send({id: id, balls: balls}); 
}

function Buy(id, mode) {
  if(mode==1) {
    document.getElementById('buy'+id).style.display='none'; document.getElementById('buybw'+id).style.display='inline';
  }
  else {
    document.getElementById('buy'+id).style.display='inline'; document.getElementById('buybw'+id).style.display='none';
  }

    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById('mybasket').innerHTML = req.responseText;
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/buy.php?id='+id+'&mode='+mode, true);
    req.send({id: id, mode: mode}); 
}
function ChangeView(mode) {
	if(document.getElementById('ml1')) {
		if(mode==1) {
			document.getElementById('ml1').style.display='none';
			document.getElementById('m1').style.display='none';
			document.getElementById('ml2').style.display='inline';
			document.getElementById('m2').style.display='inline';
		}
		if(mode==2) {
			document.getElementById('ml2').style.display='none';
			document.getElementById('m2').style.display='none';
			document.getElementById('ml1').style.display='inline';
			document.getElementById('m1').style.display='inline';
		}
	}
}

function ClickBanner(id) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
    }
    req.open(null, 'http://tour24.ru/modules/ajax/clickbanner.php', true);
    req.send({id: id}); 
}

function GoodIsSaled (id, mode) {
	if(mode == 1) {
		document.getElementById('helper'+id).style.display='none';
		if(document.getElementById('buybw'+id).style.display == 'inline'){
			document.getElementById('saled'+id).style.display='inline';
		}
	}
	else {
		document.getElementById('saled'+id).style.display='none';
		document.getElementById('helper'+id).style.display='none';
	}
}

function ShowHelper(destination_id, id) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(destination_id+id).style.display='inline';
            document.getElementById(destination_id+id).innerHTML = req.responseText;
        }
    }
    req.open(null, 'http://tour24.ru/modules/ajax/show_helper.php', true);
    req.send({destination_id: destination_id}); 

var Func = 'GoodIsSaled('+'"'+id+'",'+'1)';
setTimeout(Func, 4000)
}
