hs.graphicsDir = '/js/highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
//hs.dimmingOpacity = 0.75;

// Add the controlbar
if (hs.addSlideshow) hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 3000,
	repeat: false,
	useControls: true,
	fixedControls: false,
	overlayOptions: {
		opacity: 1,
		position: 'top right',
		hideOnMouseOut: false
	}
});

(function($) {

	function my_kwicks()
	{
    	$('.kwicks').kwicks({
			duration: 300,   
	        spacing:0,
	        max: 151
    	});
	}  
	
   	function equalHeightFooter()
	{
		// This function sets min-height, which doesn't work in IE6. Use browser detection if needed!
		var highestCol = Math.max( jQuery('.FAQ_section_round_box_content').height()+12, jQuery('.newsletter_round_box_content').height()+67, jQuery('.download_area_equal_height_container').height()-16 );
		jQuery('.FAQ_section_round_box_content').css('height', highestCol-12);
		jQuery('.newsletter_round_box_content').css('height', highestCol-67);
		
		var temp = jQuery('.download_area_equal_height_container .download_software_size_text').height();
		jQuery('.download_area_equal_height_container .equalizer').css('height', highestCol-137-temp);
	}
	
   	function equalHeightFooterLinks()
	{
		// This function sets min-height, which doesn't work in IE6. Use browser detection if needed!
		var col_1 = $('.inquiry .inquiry_question').height() + $('.inquiry .inquiry_form').height();
		var col_2 = $('.FAQ_list').height();
		var col_3 = $('.brief_production_info_text').height();
		
		//alert('col_1:' + col_1 + 'col_2:' + col_2 + 'col_3:' + col_3);
		var highestCol = Math.max( col_1, col_2, col_3 );
		$('.inquiry .inquiry_form').css('height', highestCol-$('.inquiry .inquiry_question').height() );
		$('.FAQ_list').css('height', highestCol);		
		$('.brief_production_info_text').css('height', highestCol);		
	}
	
	$(document).ready(function() {
		
		
		my_kwicks();
		
		$('#login_form_username').hint();
		$('#newsletter_form_text_field').hint();
		$('#download_email_field').hint();
		
		// On load add password hint
		//$("#login_form_password").hide();
		//// If browser remember the password, do not show password text!!!
		if ($("#login_form_password").val()=="") {
			$("#login_form_password_text").show();
		}
		
		// Now bind events for switching password field/hint
		$("#login_form_password_text").focus(function() {
			$("#login_form_password_text").hide();
			$("#login_form_password").show().focus();
		});
		$("#login_form_password").blur(function() {
			if ($(this).val() == "") {
				$("#login_form_password_text").show();
				$("#login_form_password").hide();
			}
		});
		

		jQuery('#mycarousel').jcarousel({
			// Configuration goes here
    		scroll: 1
    	});

    	
		jQuery('#one_product_carousel').jcarousel({
			// Configuration goes here
    		scroll: 1
    	});
		
		// Equalize heights
        equalHeightFooter();
		
        equalHeightFooterLinks();
        
		//Switch between two groups of form fileds by chaging the value of the radio buttons
		
		$('#physical_person, #physical_person_label').bind('click', function(){
			$('#juridical_person_fields').slideUp('normal', function(){
				$('#physical_person_fields').slideDown();
			});
		});
		$('#juridical_person, #juridical_person_label').bind('click', function(){
			$('#physical_person_fields').slideUp('normal', function(){
				$('#juridical_person_fields').slideDown();
			});
		});
		
		if ($("input[@name='person_type']:checked").val() == 1){

			$('#juridical_person_fields').slideUp('normal', function(){
				$('#physical_person_fields').slideDown();
			});
		}
		if ($("input[@name='person_type']:checked").val() == 2){

			$('#physical_person_fields').slideUp('normal', function(){
				$('#juridical_person_fields').slideDown();
			});
		}
		
		/*****/
	
		$("#one_product_carousel_section .smallPic img").fadeTo(200, 0.4);


		
		/*Hover effect*/
		$("#one_product_carousel_section .smallPic").hover(function() {
			var thisHREF = $(this).attr("href");
			var thisALT = $(this).find("img").attr("alt");
			$("#one_product_content_left .one_product_enlarged_image a").attr("href", thisHREF);
			$("#one_product_content_left .one_product_enlarged_image a img").fadeTo(200, 0.1, function() {
				$(this).attr("src", thisALT).fadeTo(200, 1);
			});
			$("img", this).fadeTo(200, 1);
		}, function() {
			$("img", this).fadeTo(200, 0.4);
		});
		
		$("#one_product_carousel_section .smallPic").click(function() {
			return false;
		});
		
		/*Lightbox*/
		
		$('.lightbox').lightBox({
			overlayBgColor: '#000',
			overlayOpacity: 0.8,
			imageLoading: 'images/lightbox-ico-loading.gif',
			imageBtnClose: 'images/lightbox-btn-close.gif',
			imageBtnPrev: 'images/lightbox-btn-prev.gif',
			imageBtnNext: 'images/lightbox-btn-next.gif',
			containerBorderSize: 10,
			containerResizeSpeed: 350
		});
		

		$(function()
		{
			$('a.lightbox').lightBox();
		});

		
		// Gallery level
		var currContentHeight = 0;
		var maxContentHeight = 0;
		var currTitleHeight = 0;
		var maxTitleHeight = 0;
		var oneRowLevel = $(".oneRowLeveler");
		oneRowLevel.each(function() {
			var titleLeveler = $(this).find(".titleLeveler");
			//console.log(titleLeveler);
			titleLeveler.each(function() {
				currTitleHeight = $(this).height();
				if (currTitleHeight > maxTitleHeight) {
					maxTitleHeight = currTitleHeight;
				}
			});
			titleLeveler.height(maxTitleHeight);
			//console.log(maxTitleHeight);
			currTitleHeight = 0;
			maxTitleHeight = 0;
			
			var contentLeveler = $(this).find(".contentLeveler");
			//console.log(contentLeveler);
			contentLeveler.each(function() {
				currContentHeight = $(this).height();
				if (currContentHeight > maxContentHeight) {
					maxContentHeight = currContentHeight;
				}
			});
			contentLeveler.height(maxContentHeight);
			//console.log(maxContentHeight);
			currContentHeight = 0;
			maxContentHeight = 0;
		});
		
		
		$('#copy_from_da').bind('click', function(){
			$("#registration_form textarea[name='ba_address']").val( $("#registration_form textarea[name='da_address']").val() ); // Do not work first attempt with html() - Works with val()
			$("#registration_form input[name='ba_postal_code']").val( $("#registration_form input[name='da_postal_code']").val() );
			$("#registration_form input[name='ba_city']").val( $("#registration_form input[name='da_city']").val() );
			$("#registration_form input[name='ba_state']").val( $("#registration_form input[name='da_state']").val() );
			return false;
		});
		$('#vote_front').bind('click', function(){
			var temp = $("#inquiry_form input[name='survey_answer']:checked").val();
			if( temp>0 ) {
				$('#inquiry_form').submit();
			}
			else {
				alert('Моля, изберете опция!');
			}
			return false;
		});
		
		// Set captcha by JS
		$("input[name='cap_prot']").val('1');
		
	});
	
})(jQuery);
