$(function(){
	$('.togglea  a').bind('click',function(){
		$(this).parent().next().toggle();
	});
	$('.tab li').bind('mouseover',function(){
		if($(this).attr('class')=='close'){
			$(this).removeClass('close');
			$(this).addClass('move');			
		}
	});
	$('.tab li').bind('mouseout',function(){
		if($(this).attr('class')=='move'){
			$(this).removeClass('move');
			$(this).addClass('close');			
		}
	});
	$('.headtag').bind('click',function(){
		$.each($('.text'),function(i,o){
			$(o).hide();
		})
		$('.tab li').removeClass();
		$('.tab li').addClass('close');
		$('#'+$(this).attr('rel')).show();
		$(this).parent().addClass('on');
		$(this).parent().removeClass('close');
		if($(this).attr('rel')=='dual_view'){
			$('#footer').css('top','750px') ;
		}else{
			$('#footer').attr('style','') ;
		}
		$('#nextpage').attr('rel',$(this).attr('id'));
		$('#prevpage').attr('rel',$(this).attr('id'));
		$('#nextpage').show();
		$('#prevpage').show();
		if(Number($('#nextpage').attr('rel'))==1){
			$('#prevpage').hide();
		}
		if(Number($('#nextpage').attr('rel'))==6){
			$('#nextpage').hide();
		}
		location.href="#";
	});
	$('#nextpage').bind('click',function(){
		o = $('#prevpage');
		if($(this).attr('rel')==''||$(this).attr('rel')=='undefined'){
			$(this).attr('rel','2');
			$(o).attr('rel','2');
		}else{
			
			if(Number($(this).attr('rel'))<6){
				$(this).attr('rel',Number($(this).attr('rel'))+1);
				$(o).attr('rel',Number($(this).attr('rel'))+1);
			}
		}
		$('#'+$(this).attr('rel')).click();
	});
	$('#prevpage').bind('click',function(){
		o = $('#nextpage');
		if($(this).attr('rel')==''||$(this).attr('rel')=='undefined'){
			$(this).attr('rel','2');
			$(o).attr('rel','2');
		}else{
			
			if (Number($(this).attr('rel')) > 1) {
				$(this).attr('rel', Number($(this).attr('rel')) - 1);
				$(o).attr('rel', Number($(this).attr('rel')) - 1);
			}	
		}
		$('#'+$(this).attr('rel')).click();
	});
	$('#forgetpassword').bind('click',function(){
   		$('#forgetpass').toggle();
	});
	$('#createuser').click(function(){
		$('#goregeist').toggle();
	})
	$('#activeEmail').bind('click',function(){
   		$('#activeEmailDiv').toggle();
	});
	
	$("#activeEmailSubmit").bind('click',function(){
		
		if(!$("#activeEmailName").val() == ""){
		
			$("#loadding").html("<img src='/img/loadding.gif' />");
			
			url = '/users/A_active?email='+$("#activeEmailName").val();
		    $.ajax({
		        url: url,
		        type: 'GET',
		        success:function(msg){
		    		if(msg == "error"){
		    			window.location = '/login?flag=7';
		    		}else{
		    			window.location = '/login?flag=8';
		    		}
		        }
		    });
		}else{
			return false;
		}
	});
	$("#RESET-BUTTON").click(function(){
		var pwd1 = $.trim($("#new_pwd1").val());
		var pwd2 = $.trim($("#new_pwd2").val());
		if(pwd1=='' || pwd2==''){
			var str = __('Password can not be empty');
			$("#reset_errormessage").html(str);
			$("#reset_errormessage").css({"width":str.length*8+40+'px',"margin-left":(960-(str.length*8+40))/2+'px'});
			$("#reset_errormessage").show();
			return false;
		}
		else if(pwd1!=pwd2){
			var str = __('Two password is not the same');
			$("#reset_errormessage").html(str);
			$("#reset_errormessage").css({"width":str.length*8+40+'px',"margin-left":(960-(str.length*8+40))/2+'px'});
			$("#reset_errormessage").show();
			return false;
		}
		$('#reset_pwd_form').submit();
	});
});

