var ini_iframe_hight;
$('#loginFrame').load(function () {
//	ini_iframe_hight = $('#loginFrame').height();
});
$(document).ready(function(){
	ini_iframe_hight = $(window).height();
	ini_iframe_hight = ini_iframe_hight - 40;
	$(".loginDiv").css("margin-top","-"+ini_iframe_hight+"px");
	$("#loginFrame").attr("height",ini_iframe_hight+"px");
	setScreenMargin();
	h = $(window).height();
	$(".body_main").css("height",h+"px");
		$('#twitterConnect').click(function(){
			$('#main').fadeOut('slow', function(){
				$('#tConnect').fadeIn('slow');	
				});
			});

		$('#facebook').click(function(){
			$('#tConnect').fadeOut('slow', function(){
				$('#main').fadeIn('slow');	
				});
			});
		});
function showLogin() {
        $("#loginDiv").animate({'margin-top': '0px'},1500);
	$(".bmh_login").fadeOut('slow', function() {
			$(".bmh_invite").fadeIn('slow');
	});
}
function showInvite() {
        $("#loginDiv").animate({'margin-top': '-'+ini_iframe_hight+'px'},1500);
	$(".bmh_invite").fadeOut('slow', function() {
			$(".bmh_login").fadeIn('slow');
	});
}
function setScreenMargin(){
	h = $(window).height();
	nh = h-183;
	try{
		$('.bmh_Oops').css({'margin-top':nh});
		$('.success').css({'margin-top':nh});
	}catch(err){
	}
}
function validateForm()
{
var x=document.forms["input"]["email"].value
if (x==null || x=="")
  {
      document.getElementById("error").innerHTML='&raquo; '+lang.emailMustBeFilled;
      document.getElementById("error").style.display='';
      return false;
  }
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!filter.test(x))
  {
      document.getElementById("error").innerHTML='&raquo; '+lang.emailMustBeValid;
      document.getElementById("error").style.display='';
      return false;
  }


}

$(function(){
	positionHPItems();
	$(window).resize(function(){
		positionHPItems();
	});
});

function positionHPItems(){
	var winH = $(window).height() - 10;
	if(winH > 600){
		$('.hp_page').css({'height':winH});
	} else {
		$('.hp_page').css({'height':'600px'});
	}
}

var stripMessage = {
	'0' : lang.stripMessage1,
	'1' : lang.stripMessage2,
	'2' : lang.stripMessage3,
	'3' : lang.stripMessage4
}



$(function(){
	$('#hp_menu ul li a').live('mouseover', function(){
		switchHPBackground($(this));
	});
});

function switchHPBackground(obj){
	var hp = $(obj).attr('imgId');
	var hpId = hp.match(/[0-9.]+/g);
	$(obj).parents('ul.menus').find('a').removeClass('selected');
	$(obj).addClass('selected');
	$('#hp_img_group #bg0').fadeOut('slow');
	$('#hp_img_group #bg1').fadeOut('slow');
	$('#hp_img_group #bg2').fadeOut('slow');
	$('#hp_img_group #bg3').fadeOut('slow');	
    $('#hp_img_group #bg'+hpId).fadeIn('slow');
    $('.hp_footerItems .strip div').html(stripMessage[hpId]);
	
}
