$(document).ready(function() {
	//TabSlides
	try {
		$('.tabContentWrapper').hide();
		$('.tabHeadingLink span').click(function(){
			
			var isActive = $(this).parent().hasClass('tabHeadingLinkActive');
			
			$('.tabContentWrapperActive').slideUp(200);
			$('.tabContentWrapperActive').removeClass('tabContentWrapperActive');
			$('.tabHeadingLinkActive').removeClass('tabHeadingLinkActive');
			
			if (!isActive) {
				$(this).parent().addClass('tabHeadingLinkActive');
				
				var slideTargetObj = $(this).parent().parent().next('.tabContentWrapper');
				slideTargetObj.slideToggle(200);
				slideTargetObj.addClass('tabContentWrapperActive');
			}
			
			return false;
		});
	} catch (e) {}
	
	//Search Field
	try {
		$('#searchFormTop').addClass('searchFieldBlur');
		var searchTextInitValTop = $('.searchTextTop').val();
		$('.searchTextTop').focus(function(){
			if ($(this).val() == searchTextInitValTop) {
				$(this).val('');
			}
			$('#searchFormTop').removeClass('searchFieldBlur');
		});
		$('.searchTextTop').blur(function(){
			if ($(this).val() == '') {
				$(this).val(searchTextInitValTop);
			}
			$('#searchFormTop').addClass('searchFieldBlur');
		});
	} catch (e) {}
	
//	try {
//		var searchTextInitVal = $('.searchText').val();
//		$('.searchText').focus(function(){
//			if ($(this).val() == searchTextInitVal) {
//				$(this).val('');
//			}
//		});
//		$('.searchText').blur(function(){
//			if ($(this).val() == '') {
//				$(this).val(searchTextInitVal);
//			}
//		});
//	} catch (e) {}
//	
	//round corners subscribe
	try {
		$('#footerSubscribeWrapper').css({'border-radius': 10, '-moz-border-radius': 10, '-webkit-border-radius': 10});
	} catch (e) {}

	// mainmenu slides
	
	try {
		$('#mainMenu li.isParent ul').css('display', 'block');
		$('#mainMenu li.isParent ul').hide();
		$('#mainMenu li.isParent').hover(function() {
			$(this).children('ul').stop(true, true);
			$(this).children('ul').slideDown();
		}, function() {
			$(this).children('ul').stop(true, true);
			$(this).children('ul').slideUp();
		});
	} catch (e) {}
	
	
	//tjenester popups
	try {
		$('.tjenesterDesc').css('display', 'block');
		$('.tjenesterDesc').hide();
		$('.tjenesterMenuItem a, .tjenesterDescItem span').hover(
			function() {
				$(this).parent().children('.tjenesterDesc').stop(true, true);
				$(this).parent().children('.tjenesterDesc').fadeIn(350);
			},
			function() {
				$(this).parent().children('.tjenesterDesc').stop(true, true);
				$(this).parent().children('.tjenesterDesc').fadeOut(100);
			}
		);
	} catch (e) {}
});
