$(document).ready(function() {
	$('#styleNormal').click(function() {
		setActiveStyleSheet('normal');
		return false;
	});
	$('#styleBig').click(function() {
		setActiveStyleSheet('bigger');
		return false;
	});
	$('#inputQuicksearchText').focus(function() {
		$('#inputQuicksearchText').val('').addClass('active');
	});
	$(document).keypress( function ( e )
	{
	    if(e.which==13) 
	    {
	        return false;
	    }    
	});
	
	$('#ctl00_FullRegion_MainAndRightRegion_MainRegion_ctl00_SearchButton').click( function()
	{
	    try {
	        ajaxBox.setValue();
	    }
	    catch ( e )
	    {
	    
	    }
	})
	
	$('#inputQuicksearchText').keypress(function(e){
	if(e.which==13) {
		$('#ctl00_quicksearch_Button1').click();
		return false;
	};
	});
	/* added handler for advanced search */
	$('.SearchQueryTextbox').keypress(function(e){
	if(e.which==13) {
		$('#ctl00_FullRegion_MainAndRightRegion_MainRegion_ctl00_SearchButton').click();
		return false;
	};
	});

	$('.henkilohakusyote').keypress(function(e){
	if(e.which==13) {
		$('.henkilohakunappi').click();
		return false;
	};
	});
	
	
	$('.newsitem h2 a').append('<img src="../images/icon_newsarrow.png" alt="">');
	$('#printbtn').append('<img src="/images/icon_print.png" alt="">');
	$('#topNavi li:first').addClass('first'); 
	

	
	/* hspace & vspace for images */
	$('img[hspace]').each(
		function(){
			if($(this).attr('hspace')>-1) {
				$(this).css('margin-left',$(this).attr('hspace')+'px');
				$(this).css('margin-right',$(this).attr('hspace')+'px').removeAttr('hspace');
			}
		}
	);
	$('img[vspace]').each(
		function(){
			if($(this).attr('vspace')>-1) {
				$(this).css('margin-top',$(this).attr('vspace')+'px');
				$(this).css('margin-bottom',$(this).attr('vspace')+'px').removeAttr('vspace');
			}
		}
	);
	/* img borders */
	$('img[border]').each(
		function(){
			$(this).css('border',$(this).attr('border')+'px solid').removeAttr('border');
		}
	);

	/*kalenterin ulkoasu*/
	calWeekSelectors = $('.calendar .selectweekcell a');
	for (i=0;i<calWeekSelectors.length;i++) {
		obj = calWeekSelectors[i];
		if (i==0) $(obj).parent().addClass('selectmonthcell');
		currHtml=$(obj).html();
		$(obj).html('<span>'+currHtml+'</span>');
	}
	prevMonthSelectors = $('.calendarheaderrow a:contains("-")');
	for (i=0;i<prevMonthSelectors.length;i++) {
		obj = prevMonthSelectors[i];
		$(obj).addClass('prevmonth');
		currHtml=$(obj).html();
		$(obj).html('<span>'+currHtml+'</span>');
	}
	nextMonthSelectors = $('.calendarheaderrow a:contains("+")');
	for (i=0;i<nextMonthSelectors.length;i++) {
		obj = nextMonthSelectors[i];
		$(obj).addClass('nextmonth');
		currHtml=$(obj).html();
		$(obj).html('<span>'+currHtml+'</span>');
	}
	$('table.calendar').removeAttr('cellspacing');
	
	/*/kalenterin ulkoasu*/

	/* table zebra-stripes*/
	$('#persresult td').removeAttr('style');
	$('#persresult tr:odd td').addClass('trZebra');
	
	/* kuvakaruselli */
	if($('#frontImage').length > 0) {
		$('#frontImage').cycle({ 
			timeout:	12000,
			speed:  	2000
		}); 
	}
	/* /kuvakaruselli */
}); 