function substr( f_string, f_start, f_length )
{
	if ( f_start < 0 )
		f_start += f_string.length ;
 
	if ( f_length == undefined ) {
		f_length = f_string.length ;
	} else if( f_length < 0 ) {
		f_length += f_string.length ;
	} else {
		f_length += f_start ;
	}
 
	if ( f_length < f_start )
		f_length = f_start ;
	
	return f_string.substring( f_start, f_length ) ;
}

function SetVisible( item )
{
	if ( $( item ).is( ":hidden" ) )
		$( item ).fadeIn() ;
	else
		$( item ).slideUp() ;
}

function ShowFaq( id ) {
	var id ;var item ;
	
	item = 'div#faq' + id ;
	
	$( 'img.f4q' ).attr( 'src', 'http://www.oki-doki.ru/design/images/icons/plus.png' ) ;
	$( 'img.f4q' ).attr( 'alt', '+' ) ;
	
	if ( $( item ).is( ":hidden" ) ) {
		$( 'div.faq' ).slideUp() ;
		$( 'img#f4q' + id ).attr( 'src', 'http://www.oki-doki.ru/design/images/icons/minus.png' ) ;
		$( 'img#f4q' + id ).attr( 'alt', '-' ) ;
		$( item ).fadeIn() ;
	}
	else {
		$( item ).slideUp() ;
	}
	
}

function SetItem( id, isSet )
{
	var id ; var item ; var isSet ;
	
	item = 'span#item-' + id ;
	
	if ( true == isSet )
		$( item ).removeClass( 'item-normal' ).addClass( 'item-selected' ) ;
	else
		$( item ).removeClass( 'item-selected' ).addClass( 'item-normal' ) ;
}
	
$(document).ready(function()
{
	$("a[rel^='lightBox']").prettyPhoto({
		theme:'facebook',
		social_tools:'',
		deeplinking: true,
		showTitle: false
	});
	
	$("a[rel^='formBox']").prettyPhoto({
		theme:'facebook',
		social_tools:'',
		deeplinking: true,
		allow_resize: false,
		modal: true,
		showTitle: true,
	markup: '<div class="pp_pic_holder"> \
						<div class="ppt">&nbsp;</div> \
						<div class="pp_top"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"></div> \
						</div> \
						<div class="pp_content_container"> \
							<div class="pp_left"> \
							<div class="pp_right"> \
								<div style="height: 600px;background:#fff" class="p_content"> \
									<div class="pp_loaderIcon"></div> \
									<div class="pp_fade"> \
										<a href="#" class="pp_expand" title="Expand the image">Expand</a> \
										<div class="pp_hoverContainer"> \
											<a class="pp_next" href="#">next</a> \
											<a class="pp_previous" href="#">previous</a> \
										</div> \
										<div id="pp_full_res"></div> \
										<div class="pp_details"> \
											<div class="pp_nav"> \
												<a href="#" class="pp_arrow_previous">Previous</a> \
												<p class="currentTextHolder">0/0</p> \
												<a href="#" class="pp_arrow_next">Next</a> \
											</div> \
											<p class="pp_description"></p> \
											{pp_social} \
											<a class="pp_close" href="#">Close</a> \
										</div> \
									</div> \
								</div> \
							</div> \
							</div> \
						</div> \
						<div class="pp_bottom"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"></div> \
						</div> \
					</div> \
					<div class="pp_overlay"></div>'
	});
	
	if( '' != window.location.hash )
	{
		ShowFaq(substr(window.location.hash,4)) ;
	}
	
	// New Year snoflakes
	$(document).snowfall({flakeCount : 350, minSize: 5, maxSize: 8, round: true});
});
