var Synergia = {
	start: function() {
		this.forms();
		this.cycle();
		this.nav();
	},
	
	forms: function() {
		$("form *[title!='']").each(function() {
			if ($.trim($(this).val()) == "") {
				$(this).val($(this).attr("title"));
			}
		}).focus(function () {
			if($(this).val() == $(this).attr("title")) {
				$(this).val("");
			}
		}).blur(function () {
			if($(this).val() == "") {
				$(this).val($(this).attr("title"));
			}
		});
		$("form").submit(function() {
			$(this).find("*[title!='']").each(function() {
				if ($(this).val() == $(this).attr("title")) {
					$(this).val("");
				}
			});
		});
	},
	
	cycle: function() {
		$("#experts-cycle").cycle({ 
			fx: "scrollVert",
			next: "#experts-cycle-next", 
			prev: "#experts-cycle-prev"
		});
		$("#sentences-cycle").cycle({ 
			fx: "toss",
			pause: 1,
			random: 1,
			timeout: 5000
		});
	},
	
	nav: function() {
		$("#nav ul li").hover(function () {
			$(this).find("ul:first").show();
			
			if ($(this).hasClass("submenu")) {
				$(this).addClass("hover");
			}
		}, function () {
			$(this).find("ul:first").hide();
			
			if ($(this).hasClass("submenu")) {
				$(this).removeClass("hover");
			}
		});
	}
}

/*-------------*/

function draw() {
    var a = $('#ramka3').offset().top - $('#k1').offset().top - 110;
    var b = $('#ramka2').offset().top - $('#k1').offset().top - 110;
    $("#canvas").drawLine({
      strokeStyle: "#DA5C09",
      strokeWidth: 1,
      strokeCap: "round",
      strokeJoin: "miter",
      x1: 230, y1: 0,
      x2: 230, y2: a,
      x3: 418, y3: a
    });
    
    $("#canvas").drawLine({
      strokeStyle: "#F7941D",
      strokeWidth: 1,
      strokeCap: "round",
      strokeJoin: "miter",
      x1: 281, y1: 10,
      x2: 281, y2: b,
      x3: 418, y3: b
    });
}

/*-------------*/
$(function() {
	Synergia.start();
  draw();
  
  $(".kolo-nav li a").hover(
    function () {
      $('#oferta-panel div').filter(this.hash).addClass('hover');
    }, 
    function () {
      $('#oferta-panel div').filter(this.hash).removeClass('hover');
    }
  );
  
	$("a[rel=fancybox], a[rel=fancybox2]").fancybox({
		'titleShow'     : true,
		'autoScale'			:	false
	});
});

