this.initlogin = function (e) {

	this.placelogin = function () {
		var win = "loginwindow",
			css = {
			'position': 'fixed',
			'bottom': '0',
			'left': '0',
			'right': '0',
			'width': '100%',
			'height': '50px',		
			'background': 'url(http://www.bluesys.ch/img/b80.png)',
			'margin-bottom': '-50px',
			'overflow' : 'hidden'
		},
		fcss = {
			'float': 'left',
			'margin': '5px'
		},
		iphone = false
		
		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/android/i)) ) {
				css = {
					'position': 'fixed',
					'top': '150px',
					'left': '50%',
					'margin-left': '-160px',
					'width': '330px',
					'height': '50px',		
					'background': 'url(http://www.bluesys.ch/img/b80.png)',
					'overflow' : 'hidden',
					'border' : '3px solid #fff',
					'display' : 'none'
				}
				
				iphone = true	
		}

		$('body').append('<div id="' + win + '" style="display:none;overflow:hidden;font-family:arial;"><form id="kFormLogin" action="?action=login" method="post" style="float:right;margin-right:10px;"><p><label for="uname" style="display:block;line-height:16px;height:16px;font-size:11px;color:#bbb;">Identifiant</label><input type="text" name="uname" id="kUname" style="line-height:16px;height:16px;font-size:11px;"/></p><p><label for="pwd" style="display:block;line-height:16px;height:16px;font-size:11px;color:#bbb;">Mot de passe</label><input type="password" name="pwd" style="line-height:16px;height:16px;font-size:11px;"/></p><p><div style="background:url(/data/themes/kameleo25/layout/sprites-small-20px.png) left -220px;width:20px;height:20px;float:left;margin-top:20px; margin-left:-10px;cursor:pointer;" id="kSubmit" ></div></p></form></div>')
		$('#' + win).css(css).find('p').css(fcss).end().toggle()
		
		if (iphone) {
			$('#loginwindow').css("display", "none") 
		}
		
		$(e).click(
			function(){
					if (iphone) {
						$('#loginwindow').show()
					}else{
						$('#loginwindow').stop().animate( {marginBottom: '0px'}, 500)
					}
					$('#loginwindow').stop().animate( {marginBottom: '0px'}, 500)
					$("#kUname").focus();		
			}
		)
		
		
	$('#' + win + " input").keyup(function(e) {
     	if(e.keyCode == 13) {
     		if($("#loginwindow input[type=password]").val()){
	    	 	$("#kFormLogin").submit();
	    	}
	    	 
    	 }
	});
	
	}
	
	placelogin()
	
	
}

$("document").ready(function(){
	initlogin('#kLogin')
	$("#kSubmit").click(
		function(){
			$("#kFormLogin").submit();
		}
	)
	
}
)

