
$(document).ready(function() {

	$.backstretch("kp_img/strand.jpg");

	$('.h12').click(function(){
		location.href='index.php';
		return false;
	})	
	
	$('#mainnav ul a').prepend('&rsaquo; ');
	
	$('#mainnav li.top').hover(function() {
	  $('#mainnav li.top a').removeClass('hover');
	  $('#mainnav li a.act').parent('li').parent('ul').parent('li').find('a:first').addClass('hover');
	  $('a:first',this).addClass('hover');
	},function(){  
	  	$('#mainnav li.top a').removeClass('hover');
		$('#mainnav li a.act').parent('li').parent('ul').parent('li').find('a:first').addClass('hover');
	});	
	
	$('#mainnav li a.act').parent('li').parent('ul').parent('li').find('a:first').addClass('hover');

	$(document).pngFix();
	SetForm();
	SetZoom();


	//---------------------------------------
	
	var open = $('#topslider').attr('rel');
	
	if(open=='no'){
		$('#topslider').hide();
	}
	
	$("#sliderbtn a").click(function(){
	  $("#topslider").slideToggle(600);
	  //$(this).toggleClass("active");
	});
	
	//---------------------------------------
	
	$('#mlr-alert').hide();

	$('input.subm').hover(function() {
	  $(this).addClass('hover');
	}, function() {
	  $(this).removeClass('hover');
	});

	$('#frm_cnt').ajaxForm({
			beforeSubmit: BeforeSendCnt,
			success		: SendSuccesCnt,
			clearForm	: false
	});

	function BeforeSendCnt(resp, stat)  {
		$('#loader').addClass('loading');
		$('#frm_cnt input[value=]').addClass('empt');
	}	
	
	function SendSuccesCnt(resp, stat)  {
		
		$('#loader').removeClass('loading');
		$('#frm_cnt input.empt').clearingInput();
		$('#frm_cnt input').removeClass('empt');		
		
		var json = eval('(' + resp + ')');
		
		if (json.send=='yes') {
			$('#mlr-alert').html(json.msg).fadeIn('slow', function(){ setTimeout( "$('#mlr-alert').fadeOut('slow')" ,3000)  });
			$('#frm_cnt').resetForm();
			SetForm();
		}else{
			$('#mlr-alert').html(json.msg).fadeIn('slow');
		}		
		
	}
	
	//---------------------------------------
	
	
});

//--------------------------------------------------

function SetZoom() {
	$('a.zoom').colorbox({opacity:0.70});
	$("a#mlr-alert").colorbox({opacity:0.70, width:"320px", inline:true, href:"#inline_alert"});
}

function SetForm() {
	$('input:text:[value=""]').clearingInput();
	$('textarea').clearingInput();
}

//--------------------------------------------------

function loadimg(image,wrap) {		
	var img = new Image();
	$(img).load(function () {   
		$(this).hide();
		wrap.find('.imgholder').append(this);
		$(this).fadeIn(600);
	})
	.attr('src', image);
 }

//--------------------------------------------------
