$(document).ready(function(){

	if (document.URL.indexOf('#sc-') != -1) {

		var _n = parseInt(document.URL.substr(document.URL.indexOf("#") + 4)) - 1;

		$('div.slide-holder').animate({marginLeft:-(663*_n)+'px'},{queue:false,duration:800, easing: 'easeOutExpo'});

	}

	$('#navigation ul a').click(function(){

		if ($(this).attr('href').indexOf('#sc-') != -1) {

			if ($(this).attr('href').indexOf('#sc-') == 0) {

				var _n = parseInt($(this).attr('href').replace('#sc-','')) - 1;

				$('div.slide-holder').animate({marginLeft:-(663*_n)+'px'},{queue:false,duration:800, easing: 'easeOutExpo'});

				return false;

			}

		}

	});

	

	// form popup

	$('a.subscribe').click(function(){

		$('body').addClass('popup-mode');

		$('#popup-shadow').css('display','block');

		$('#popup').fadeIn(400, function(){

			$('#popup .box div').slideDown(600);			

		}); 

		poupUp_height();

	});

	$('#popup a.close-block').click(function(){

		$('body').removeClass('popup-mode');

		$('#popup .box div').slideUp(600, function(){

			$('#popup').fadeOut(400, function(){

				$('#popup-shadow').css('display','none');

			})

		});

	});

	

	// hide text

	var _inputs = document.getElementsByTagName('input');

	var _value = '';

	if (_inputs) {

		for(var i=0; i<_inputs.length; i++) {

			if (_inputs[i].type == 'text' || _inputs[i].type == 'password') {

				_inputs[i].onfocus = function(){

					_value = this.value;

					this.value = '';

				}

				_inputs[i].onblur = function(){

					if (this.value == '')

						this.value = _value;

					_value = '';

				}

			}

		}

	}

	

});

function poupUp_height()

{

	var _lightbox = document.getElementById("popup");

	var _popup_table = document.getElementById("popup-shadow");

	var _minWidth = document.getElementsByTagName('div')[0].offsetWidth;

	

	

	var _height = 0;

	var _width = 0;

	if (window.innerHeight) {

		_height = window.innerHeight;

		_width = window.innerWidth;

	} else {

		_height = document.documentElement.clientHeight;

		_width = document.documentElement.clientWidth;

	}

	var _page = document.getElementsByTagName("body")[0];

	if (_lightbox && _popup_table && _page) {

		if (_height > _page.offsetHeight) _popup_table.style.height = _height + "px";

		else _popup_table.style.height = _page.offsetHeight + "px";

		if (_width < _minWidth) {_popup_table.style.width = _minWidth + "px";} else {_popup_table.style.width = '100%'}

		

		if (_width > _lightbox.offsetWidth) _lightbox.style.left = (_width - _lightbox.offsetWidth) / 2 + "px";

		else {_lightbox.style.left = "0px";_lightbox.style.position = "absolute";}

	}

}





if (window.addEventListener){window.addEventListener("resize", poupUp_height, false);}

else if (window.attachEvent){window.attachEvent("onresize", poupUp_height);}

