function init(){
	$('#menu ul li a').hover(function(){
		$(this).addClass('hover');
	}, function(){
		$(this).removeClass('hover');
	});
	$('.login-panel .btn').hover(function(){
		$(this).addClass('btn-hover');
	}, function(){
		$(this).removeClass('btn-hover');
	});	
	/*
	var rate = 0.38;
	$("#doc-wrapper .strip").css({
			"opacity": rate,
			"-moz-opacity": rate,
			"filter": "alpha(opacity="+(rate*100)+")"
	});
	*/
	$('#username').focus(function(){
		if($(this).val() == 'Enter your username'){
			$(this).val('');
		}
	});
	$('#username').blur(function(){
		if($(this).val() == ''){
			$(this).val('Enter your username');
		}
	});
	
	initPassText();
	
	showWin("#showForm", "win_responseform.php");
	showWin("#regform", "win_registerform.php");
	
	$('#forgotpass').click(function(){
		
	if ($('#username').val() == 'Enter your username') { alert("Please enter your username or email address to continue."); $('#username').focus();  } else {
		
	$.post("forgotpass.php", { 'username': $('#username').val() }, function(data) { alert(data);       }, "text");
		
		} 
		
		
		
	});
	
	
}


function checkPass() { 

theusername = $('#username').val();
thepass = $('#password').val();


$.ajax({
   type: "POST",
   url: "checkpass.php",
   data: "username=" + theusername + "&password=" + thepass,
   success: function(msg){
    if (msg == 'Invalid') { 
     alert( "Invalid username or password. Please try again.");
     return false;
   } else { document.loginform.submit(); } 
   
   }
 });


}








function initPassText(){
	$('#password').focus(function(){
		if($(this).val() == 'Enter your password'){
			$(this).val('');
			var p = $(this).parent();
			$(this).remove();
			$(p).append('<input type="password" id="password" name="password" value="" class="txt password"/>');
			initPassword();
			$('#password').focus();
		}
	});	
}
function initPassword(){
	$('#password').blur(function(){
		if($(this).val() == ''){
			var p = $(this).parent();
			$(this).remove();
			
			$(p).append('<input type="text" id="password" name="password" value="Enter your password" class="txt password"/>');
			$('#password').val('Enter your password');
			initPassText();
			$('#username').focus();
		}
	});	
}
function initSliderPanel(selector){
    var container = $('.slider-panel', selector);
    var sbody = $('.slider-body', container);        
	var sbodyHeight = sbody.innerHeight() - container.innerHeight();  
	var s = (sbodyHeight > 0)?-1:1;
	$('.scrollbar', container).slider({
		axis: "vertical",
    	min: 0,
        max: sbodyHeight,
        handle: '.slider',
        stop: function (event, ui) {
            sbody.animate({'top' : ui.value * s}, 500);
        },
        slide: function (event, ui) {
            sbody.css('top', ui.value * s);
        }
    });			
}


function showWin(id, url){
	if(!$('#show-win')){
		$(document).append('<div id="show-win"></div>');
	}
	if(id != ''){
		$(id).click(function(){
				$(this).createDialog({
					url: url,
					bg: '#000000',
					progress: false,
					center: true,
					opacity: 0.65
				});
		});
	}
	else{
		$('#show-win').createDialog({
			url: url,
			bg: '#000000',
			progress: false,
			center: true,
			opacity: 0.65		
		} );			
	}
	
	
}
