$(document).ready(function(){
	var hash = window.location.hash;
	hash = hash.replace('#','');
	changeView(hash);
	
	var flashvars = {};
	var params = {wmode:"opaque"};
	var attributes = {};
	swfobject.embedSWF("smarty/images/new/banki.swf","banks","970","57","9.0.115","false", flashvars, params, attributes);
		
	$('#logging .formRow input[type=text],#logging .formRow input[type=password]').focus(function() {
		var id = $(this).attr('id');
		$('form label[for='+id+']').addClass('focus');
	});
	$('#logging .formRow input[type=text],#logging .formRow input[type=password]').focusout(function() {
		var id = $(this).attr('id');
		var len = $(this).val().length;
		$('form label[for='+id+']').removeClass('focus');
		if(len==0){ $('form label[for='+id+'] span').removeClass('hide'); }
	});
	$('#logging .formRow input[type=text],#logging .formRow input[type=password]').keyup(function(){
		var id = $(this).attr('id');
		var len = $(this).val().length;
		if(len>=1){ $('form label[for='+id+'] span').addClass('hide'); }
		else{ $('form label[for='+id+'] span').removeClass('hide'); }
	});
	
	$('#step1 h2 a').click(function(event){
		$('#step1 .content .inner').show();
		$('html, body').animate({ scrollTop: ($('#content').height() + $('#step1 div.header').height())+'px' }, 'slow');
		return changeHash(event, this.hash, false);
	});
	
	$('#step1 .next h2 a').click(function(event){
		$('#step2').show();
		$('html, body').animate({ scrollTop: ($('#content').height() + $('#step1').height())+'px' }, 'slow');
		return changeHash(event, this.hash, false);
	});
	
	$('#step1b h2 a').click(function(event){
		$('#step1b .content .inner').show();
		$('html, body').animate({ scrollTop: ($('#content').height() + $('#step1b div.header').height())+'px' }, 'slow');
		return changeHash(event, this.hash, false);
	});
	
	$('#step1b .next h2 a').click(function(event){
		$('#step2b').show();
		$('html, body').animate({ scrollTop: ($('#content').height() + $('#step1b').height())+'px' }, 'slow');
		return changeHash(event, this.hash, false);
	});
	
	$('li.business a').click(function(event){
		changeView('enterprise');
		return changeHash(event, this.hash, true);
	});
	
	$('li.individual a').click(function(event){
		changeView('personal');
		return changeHash(event, this.hash, true);
	});
	
	//randomizeIndividual();

	// banks icon
	var move_top = '0%';
	var move_left = '0%';
	$('.banks .bank').hover(function() {
		width = 80+'px';
		height = 50+'px';
		
		$(this).find('img').stop(false,true).animate({'width':width,  'top':move_top, 'left':move_left}, {duration:200});
	},
	function() {
		$(this).find('img').stop(false,true).animate({'width':'28px',  'top':'50%', 'left':'50%'}, {duration:100});	
	});
	
	$('#forms').validate({errorElement: "span"});
	
});

function randomizeIndividual()
{
	var nu = Math.ceil(Math.random()*11);
	if((nu==1) || (nu==2)){ $('#content.b2c').css({'background': "url('smarty/images/new/bg-b2c_3.jpg') no-repeat top center"});}
	if((nu==3) || (nu==4) || (nu==10)){ $('#content.b2c').css({'background': "url('smarty/images/new/bg-b2c.jpg') no-repeat top center"});}
	if((nu==5) || (nu==6) || (nu==11)){ $('#content.b2c').css({'background': "url('smarty/images/new/bg-b2c_4.jpg') no-repeat top center"});};
	if((nu==7) || (nu==8) || (nu==9)) {$('#content.b2c').css({'background': "url('smarty/images/new/bg-b2c_5.jpg') no-repeat top center"});};
	
}

function changeView(caseof)
{
	switch(caseof)
	{
		default:
		case 'personal':
			$('#content').addClass('b2c').removeClass('b2b');
			$('#content.b2c').css({'background': "url('smarty/images/new/bg-b2c.jpg') no-repeat top center"});
			$('#client-types li.business').removeClass('active');
			$('#client-types li.individual').addClass('active');
			
			$('#sliderbox2').show();
			$('#sliderbox .individual').removeClass('hide').addClass('active');
			$('#sliderbox .business').removeClass('active').addClass('hide');

			$('#main div.bussiness,  #logging div.enterprise').addClass('hide').hide();
			$('#main div.individual, #logging div.individual').removeClass('hide').show();
			
			$('#customersRight').show();

		break;
		
		case 'enterprise':
			$('#content').attr('style', '');
			$('#content').addClass('b2b').removeClass('b2c');
			$('#client-types li.individual').removeClass('active');
			$('#client-types li.business').addClass('active');
			
			$('#sliderbox2').hide();
			$('#sliderbox .business').removeClass('hide').addClass('active');
			$('#sliderbox .individual').removeClass('active').addClass('hide');
			
			$('#main div.individual, #logging div.individual').addClass('hide').hide();
			$('#main div.bussiness, #logging div.enterprise').removeClass('hide').show();

			$('#customersRight').hide();
			
		break;
	}
	Cufon.now()
}
$(function(){
	   
	$.fn.scrollToTop=function(){
		$("#goTop").hide();
		
		if($(window).scrollTop()!="0"){ $(this).fadeIn("slow")}
		var scrollDiv = $(this);
		$(window).scroll(function(){ if($(window).scrollTop()=="0"){ $(scrollDiv).fadeOut("slow")}else{	$(scrollDiv).fadeIn("slow")}});
		$(this).click(function(){ $("html, body").animate({scrollTop:0},"slow"); });
	}
	
	$.fn.resizeSliders = function()
	{
		$winH = $(window).height();
		if($winH>500)
		{
			$scrollDiv = $(this);
			if($scrollDiv.height()<$winH)
			{
				$scrollDiv.css('height', $winH - $('#step1 div.header').height());
			}
		}
	}
			
});
$(function() {
	$("#goTop").scrollToTop();
	//$('#content, #step1 .content .inner, #step2 .content .inner').resizeSliders();
});

function changeHash(event, hash, reload){ event.preventDefault(); if(reload==true){ window.location.hash = hash; } return false; }
Cufon.now();
Cufon.replace('div#logging h4, div#logging p, .slider h2, ul li h3, .slider .content .text h3, .slider .content .text h4,div#logging h4.business, .cufon', { fontFamily: 'Alwyn New Th', hover: true });
Cufon.replace('input[type=submit]', { fontFamily: 'Alwyn New Rg', hover: true });

$(function()
{
	$('#sliderbox .sliderbox_btn').toggle( function () {t=setTimeout(function() { if ($('#sliderbox').css('right')=='-328px'){ $('#sliderbox').animate( {right: '+=328'}, 500, function() {}); $('#sliderbox .sliderbox_btn').css('cursor', 'auto');  } }, 500) },
		function(){	if ($('#sliderbox').css('right')=='0px'){ $('#sliderbox').animate({right: '-=328'}, 500, function() {}); $('#sliderbox .sliderbox_btn').css('cursor', 'pointer'); }	}
	);
	$('#sliderbox .closeBtn span').click(
		function () { clearTimeout(t); if ($('#sliderbox').css('right')=='0px') { $('#sliderbox').animate({right: '-=328'}, 500, function() {}); $('#sliderbox .sliderbox_btn').css('cursor', 'pointer'); } }
	);
	
	
	if (parseInt(jQuery.browser.version)==6 && jQuery.browser.msie)	{$('#sliderbox').css('display','none');}
	else { $('#sliderbox').css('visibility','visible');}
	
	
	$('#sliderbox2 .sliderbox_btn').toggle(
			function () {t=setTimeout(function() { if ($('#sliderbox2').css('right')=='-328px'){ $('#sliderbox2').animate( {right: '+=328'}, 500, function() {});} }, 500); $('#sliderbox2 .sliderbox_btn').css('cursor', 'auto'); },
			function(){	if ($('#sliderbox2').css('right')=='0px'){ $('#sliderbox2').animate({right: '-=328'}, 500, function() {}); $('#sliderbox2 .sliderbox_btn').css('cursor', 'pointer'); }	}	
	);
	$('#sliderbox2 .closeBtn span').click(
		function () { clearTimeout(t); if ($('#sliderbox2').css('right')=='0px') { $('#sliderbox2').animate({right: '-=328'}, 500, function() {}); $('#sliderbox2 .sliderbox_btn').css('cursor', 'pointer'); } }
	);

	if (parseInt(jQuery.browser.version)==6 && jQuery.browser.msie)	{$('#sliderbox2').css('display','none');}
	else { $('#sliderbox2').css('visibility','visible');}
	
});	
	
function setFacebookIconHeight(top){ $('#sliderbox').css('top',top);}

$(document).ready(function () {
	$("#tab1").click(function() {
		if ($("#step2").is(':visible')) {
			$("#step1").show();
			$("#step2").hide();
			$("#tab1").css('background-position', '0% 100%');
			$("#tab2").css('background-position', '0% 0%');
		}
	});
	$("#tab2").click(function() {
		if ($("#step1").is(':visible')) {
			$("#step2").show();
			$("#step1").hide();
			$("#tab2").css('background-position', '0% 100%');
			$("#tab1").css('background-position', '0% 0%');
		}
	});
	
	$("#tab3").click(function() {
		if ($("#step2b").is(':visible')) {
			$("#step1b").show();
			$("#step2b").hide();
			$("#tab3").css('background-position', '0% 100%');
			$("#tab4").css('background-position', '0% 0%');
		}
	});
	$("#tab4").click(function() {
		if ($("#step1b").is(':visible')) {
			$("#step2b").show();
			$("#step1b").hide();
			$("#tab4").css('background-position', '0% 100%');
			$("#tab3").css('background-position', '0% 0%');
		}
	});
});
