$(document).ready(function(){
	ieHover('#menu li')
	slideBox();
	$('.gallery').galleryScroll({
		btPrev: 'a.link-prev',
		btNext: 'a.link-next',
		holderList: '.frame',
		scrollElParent: 'ul',
		scrollEl: 'li',
		slideNum: false,
		duration : 1000,
		step: false,
		circleSlide: true,
		disableClass: 'disable',
		funcOnclick: null
	});
});
/*--- IE6 hover ---*/
function ieHover(h_list){
	if ($.browser.msie && $.browser.version < 7){
		$(h_list).hover(function(){
			$(this).addClass('hover');
		}, function(){
			$(this).removeClass('hover');
		});
	}
}
/*-----slide box-------*/
function slideBox(){
	$('.slide-box-holder a.open').click(function(){
		$(this).toggleClass('active');
		$('.slide-box-holder .slide').slideToggle('slow');
	});
}






function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}

	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

$(document).ready(function(){
	$('#carusel').galleryScroll({
		btPrev: 'a.link-prev',
		btNext: 'a.link-next',
		holderList: '.frame1',
		scrollElParent: 'ul',
		scrollEl: 'li',
		slideNum: false,
		duration : 1000,
		step: false,
		circleSlide: true,
		disableClass: 'disable',
		funcOnclick: null
	});

	initAccordion();
});


function initAccordion() {
	$('a').click(function(){
		if(parseInt($(this).attr('rel'))>0) {
			setCookie('accnumber',$(this).attr('rel'));
		} else {
			setCookie('accnumber',-1);
		}
	});

	var _accordion = $('ul.accordion').eq(0);
	_accordion.find(' > li').each(function(_ind){
		var _menuItem = $(this);
		_menuItem.find('a').each(function(){
			var _opener = $(this);
			_opener.attr('rel',_ind);
			_opener.click(function(){
				setCookie('accnumber',$(this).attr('rel'));
			});
		});
	});

	var _curState = getCookie('accnumber');
	if(_curState) {
		_accordion.find('.selected').removeClass('selected');
		if(_curState >= 0)
			_accordion.find(' > li').eq(_curState).find('.opener').addClass('selected');
	}

	_accordion.accordion({
		autoheight: false,
		header: ".opener",
		active: '.selected',
		selectedClass: 'active',
		alwaysOpen: false,
		event: "click"
	});
}