$(document).ready(function(){
	
//~ $('.snap_noshots, .begun_adv_title, .begun_adv_title b, .begun_adv_text b').css('cssText', 'font-weight: normal !important');


//~ $("#multilogin a").colorbox({
	//~ width: "500px",
	//~ height: "500px",
	//~ iframe:true
	//~ });



//----------->> START <<--------------//
	$('#chat_status a').attr("target", '_blank');
	$('#chat_status a').attr("onload", 'statusImagesLiveHelp[statusImagesLiveHelp.length] = this;');

	if ($('.unread_m').length) {
		$('.unread_m').blink();
	}

$('.sh_img').wrap('<div class="sh1"><div class="sh2"><div class="sh3"><div class="sh4"><div class="sh5"><div class="sh6"><div class="sh7"><div class="sh8"></div></div></div></div></div></div></div></div>').addClass('va_m');



$("#where").click(function() {

	var checked_status = this.checked;


	$(".forall").each(function() {
	this.checked = checked_status;
	this.disabled = checked_status;
	});

});

$("input[name='searchtype']").click(function() {

	if($(this).val() == "local") {
  	$("#localsearch").show();
  	$("#local_results").show();
  	$("#yandex-results-outer").hide();
  	$("#cse-search-results").hide();
	} else if ($(this).val() == "google") {
  	$("#localsearch").hide();
  	$("#local_results").hide();
  	$("#yandex-results-outer").hide();
  	$("#cse-search-results").show();
	} else if ($(this).val() == "yandex")
	{
		$("#localsearch").hide();
  	$("#local_results").hide();
  	$("#yandex-results-outer").show();
  	$("#cse-search-results").hide();
	}
	
	SearchType == $(this).val() ? $("#find_button_reminder").hide() : $("#find_button_reminder").show();
	
	});




$('.content_container a:not(.advert a, .img_tn, .maybe_img_tn, a[href*="javascript"], .forum-post-entry .img_zoom a, .review_message .img_zoom a)').filter(function() {

		if (typeof (this.hostname) != "string") return false;
		
    return this.hostname
    && this.hostname !== location.hostname
    && this.hostname !== 'javascript'
    && this.hostname !== 'www.greencard.by'
    && this.hostname !== 'www.green-card.by'
	&& this.hostname !== 'www.green-card.ru'
	&& this.hostname !== 'www.green-card.ua'
	&& this.hostname !== 'www.greencard.ua'
	&& this.hostname !== 'www.greencard.com.ua'
	&& this.hostname !== 'www.greencard.kz'
	&& this.hostname !== 'www.green-card.kz'
	&& this.hostname !== 'www.green-card.md'
	&& this.hostname !== 'www.usa-green-card-lottery.com'
    && this.hostname !== 'greencard.by'
    && this.hostname !== 'green-card.by'
	&& this.hostname !== 'green-card.ru'
	&& this.hostname !== 'green-card.ua'
	&& this.hostname !== 'greencard.ua'
	&& this.hostname !== 'greencard.com.ua'
	&& this.hostname !== 'greencard.kz'
	&& this.hostname !== 'green-card.kz'
	&& this.hostname !== 'green-card.md'
	&& this.hostname !== 'usa-green-card-lottery.com';

  }).addClass('ext_link');
  
//$('a[href*=javascript]').removeClass('ext_link');

// price select


var country =  $("#select-country option:selected").val();
 $("#"+country).show();

 $("#select-country").change(function() {
        var country = $("option:selected", this).val();
        $(".switch:visible").hide();

        $("#"+country).show();
        return false;
    });

	if($.browser.msie) {
		var buga = $('#country1').html();
		$('.price tfoot').after('<tbody id="country0">' + buga + '</tbody>')
	}

var COOKIE_NAME_COLUMN = 'greencard_hide_column';
var COOKIE_NAME_HEAD = 'greencard_hide_head';
var options = { path: '/', expires: 999 };




	$("#hide-column").click(function() {

		$('#leftc').hide();
		$('#centerc').css({"margin-left":"0"});
		$('#cinner').css({"margin-left":"0"});
		$(this).css({"display":"none"});
		$('#show-column').css({"display":"inline"});

		$.cookie(COOKIE_NAME_COLUMN, 'yes', options);

		return false;
	  });

	$("#show-column").click(function() {

		$('#leftc').show();
		$('#centerc').css({"margin-left":"-261px"});
		$('#cinner').css({"margin-left":"261px"});
		$(this).css({"display":"none"});
		$('#hide-column').css({"display":"inline"});

		$.cookie(COOKIE_NAME_COLUMN, null, options);

		return false;
	  });


	$("#hide-head").click(function() {

		$('#header_red_line').hide();
		$('#usa').hide();
		$('#alias').hide();
		$('#chat_block').hide();
		$('#header_img').css({'height':'auto','margin-top':'6px','margin-bottom':'0','background-color':'#fff'});
		$('.top-breadcrumbs').hide();
		$('.login_block').hide();
		$('.simple-login').show();
		$('#simple_chat_block').show();
		$(this).hide();
		$("#show-head").show();

		$.cookie(COOKIE_NAME_HEAD, 'yes', options);

		return false;

	 });

	$("#show-head").click(function() {

		$('#header_red_line').show();
		$('#usa').show();
		$('#alias').show();
		$('#chat_block').show();
		$('#header_img').css({'height':'200px','margin-top':'0','margin-bottom':'4','background-color':'#3376AB'});
		$('.top-breadcrumbs').show();
		$('.login_block').show();
		$('.simple-login').hide();
		$('#simple_chat_block').hide();
		$(this).hide();
		$('#hide-head').show();

		$.cookie(COOKIE_NAME_HEAD, null, options);

		return false;

	 });











//----------->> выподающее меню <<--------------//

	if($.browser.msie) {

		$('input#enter').hover(function() {
			$(this).addClass("hover");
		} , function() {
			$(this).removeClass("hover");

		});
	}

	$('#top-menu li').find("ul").hide();
	$('#top-menu li').hover(function() {
		$(this).find("ul").show();
		$('> a', this).addClass("hover");
	} , function() {
		$('> a', this).removeClass("hover");
		$(this).find("ul").hide();
	});

	$('.login_block input').hover(function() {
		$('#top-menu a').removeClass("hover");
		$('#top-menu li ul').hide();
	} , function() {

	});


//----------->> изголения над кнопкой чата <<--------------//


	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		$('#chat_block').append('<img id="ahand" src="http://images.green-card.by/hand.gif" />');
	} else {
		$('#chat_block').append('<img id="ahand" src="http://images.green-card.by/hand.png" />');
	}


	function handMove() {
		if($.browser.msie || $.browser.safari) {
			$("#chat_block #ahand")
			.animate({left:'+=85',top:'-=100',width:'60px'},2000);
		} else {
			$("#chat_block #ahand")
			.animate({left:'+=120',top:'-=100',width:'60px'},2000);
		}
		$("#chat_block #ahand")
			.animate({"width": "50"}, "fast")
			.animate({"width": "60"}, "fast");

		if($.browser.msie || $.browser.safari) {
			$("#chat_block #ahand")
			.animate({left:'-=85',top:'+=100',width:'0px'},2000);
		}  else {
			$("#chat_block #ahand")
			.animate({left:'-=120',top:'+=100',width:'0px'},2000);
		}
	}



	$('#header_red_line p').css({'opacity': '1'});

	function textFade() {
		$('#header_red_line p')
			.animate({opacity: 0}, 20)
			.animate({opacity: 1}, 20)
			.animate({opacity: 0}, 20)
			.animate({opacity: 1}, 20)
			.animate({opacity: 0}, 20)
			.animate({opacity: 1}, 20)
			.animate({opacity: 0}, 20)
			.animate({opacity: 1}, 1000);
	}

	function arrFade() {
		setTimeout(function(){handMove();},37000);
		setTimeout(function(){textFade();},97000);
		setTimeout(function(){arrFade();},157000);
	}
	setTimeout(function(){arrFade();},60000);

//----------->> зажигаем кнопку чата <<--------------//

	$('#lstext, #chat_status a').hover(function () {
		$('#chat_status a img').css('margin-top', '-83px');
		$('#lstext').css('text-decoration', 'none')
	}, function () {
		$('#chat_status a img').css('margin-top', '0');
		$('#lstext').css('text-decoration', 'underline')
	});/**/

//----------->> заточки для разных расрешений <<--------------//

	function bodyPadd() {
		if ($(window).width() <= 1100) {
			$('body').css('margin-left', '5px');
			//~ alert ($(window).width());
		} else {
			$('body').css('margin-left', '15px');
		}
		
	}

	bodyPadd();

	$(window).resize(function(){
		bodyPadd();
	});

	var tempText = $('#header_red_line p').html(); //текст красной полосы по умолчанию

	function textChange() {

		if($.browser.msie) {
			if ($('.otherform button').width() > 349) {
				$('.otherform button').css({width:'349px'});
			} else {
				$('.otherform button').css({width:'100%'});
			}

		}


		if ($(window).width() < 760) {
			$('#header_red_line p').html('Участвуйте <a href="/contacts/" class="l1">в офисе</a>, <a href="/profile/lottery/" class="l2">Интернете</a> или <a href="#"><strong>по телефону</strong></a>!</span>');
		}
		if ($(window).width() > 760) {
		}
		if ($(window).width() < 980 && $('body').width() > 760) {
				$('#header_red_line p').html('<span class="now">Станьте участником</span> <a href="/contacts/" class="l1">в офисе</a>, <a href="/profile/lottery/" class="l2">Интернете</a> или <a href="#"><strong>по телефону</strong></a>!</span>');
		}
		if ($(window).width() < 1240 && $('body').width() > 980) {
				$('#header_red_line p').html('<span class="now">Станьте участником!</span> Заполните анкету <a href="/contacts/" class="l1">в офисе</a>, <a href="/profile/lottery/" class="l2">Интернете</a> или <a href="#"><strong>закажите по телефону</strong></a></span>');
		}
		if ($(window).width() > 1240) {
				$('#header_red_line p').html(tempText);
		}
		if ($(window).width() < 1010) {
			$('#header_img').css('background-position', 'left');
		}
		if ($(window).width() < 980) {
			$('#rightc').attr("id", 'rightc2');
			$('#rightc2').css('height', 'auto');
			$('#rightc2').css('width', 'auto');

			$('#centerc-index').attr("id", 'centerc-index2');
			$('#centerc-index2').css('width', '100%');
			$('#rightc2 .type_block:odd').css('float', 'right');
			$('#rightc2 .type_block:even').css('clear', 'both');
			//$("#leftc, #centerc2, #centerc-index2").equalizeCols();
		}
		if ($(window).width() < 700) {
			$('#header_img').css('background-position', '-50px 0');
		}
		if ($('form.entr').length > 0){
			var headerPos = '160px';
		} else {
			var headerPos = '180px';
		}
		if ($(window).width() < 1240) {
				$('#prichina').css({'margin':'auto'});
				$('#prichina .pin').css({'margin':'auto'});
				$('#prichinanav').css({'width':'auto','float':'none'});
				$('#prichinaphoto').css({'margin':'auto','float':'none','clear':'both','padding-top':'20px'});
		} else {
				$('#prichina').css({'margin':'0 -640px 0 0'});
				$('#prichina .pin').css({'margin':'0 640px 0 0'});
				$('#prichinanav').css({'width':'622px','float':'right'});
				$('#prichinaphoto').css({'margin':'auto','float':'right','clear':'right','padding-top':'0px'});
		}
		if ($(window).width() > 1010) {
			$('#header_img').css('background-position', '' + headerPos + ' 0');
		}
		if ($(window).width() < 980) {
			$('#rightc2').attr("id", 'rightc');
			$('#centerc-index2').attr("id", 'centerc-index');
			$('#rightc .type_block:odd').css('float', 'none');
			$('#rightc .type_block:even').css('clear', 'none');


			$('#rightc').css('width', '240px');

		}
	}

	textChange();

	$(window).resize(function(){
		textChange();

	});

//----------->> ровняем высоту колонок <<--------------//

	//~ $(window).resize(function(){
		//~ $("#leftc, #centerc, #rightc, #centerc-index").equalizeCols();
	//~ });
	//~ $("#leftc, #centerc, #rightc, #centerc-index").equalizeCols();

//----------->> ровняем фотокартинку <<--------------//

	var iHeight = $('.photo img').attr('height');
	var iMarg = (200 - iHeight) / 2;
	$('.photo img').css('margin-top',iMarg);

//----------->> выравниваем <<--------------//

if($.browser.safari ){
	$('.voter input, #mem').css({'vertical-align':'-30%'});
	$('.bt75,.bt75-white,.simpleform .bt75,.simpleform .bt75-white').css({'padding-top':'5px'});
}
//----------->> тоглер инфоблока <<--------------//
$('#from-info-show').click(function() {
	$('#from-info').slideToggle("fast",function() {
		//$("#leftc, #centerc, #rightc, #centerc-index").equalizeCols();
	});
	return false;
});

$('.show-smile').click(function() {
	//~ $('.other-smile').slideToggle();
	return false;
});

//----------->> FILES <<----------------//

$("a[href$='.pdf']").parent().addClass("pdf");


if ($('#photos').length) {
	$('#photos').galleryView({
			panel_width: 600,
			panel_height: 400,
			frame_width: 60,
			frame_height: 60,
			overlay_height: 60,
			overlay_position: 'top',
			fade_panels: true,
			pause_on_hover: true
		});
}




//----------->> THE END <<--------------//
});
