var mx,my;
function getMouseIntXY(e){
	if(e.clientX!=undefined){
		mx=e.clientX;
		my=e.clientY+Math.round(document.documentElement.scrollTop);
	}else if(e!=undefined){
		mx=e.pageX;
		my=e.pageY; 
	}else{
		mx=e.pageX;
		my=e.pageY;
	}
	return Array(mx,my)	;
}

function loginPan(x,y){
	this.x=x;
	this.y=y;
	
	this.pageContainer=$('body');
	if(window.innerHeight){ 
		this.height=window.innerHeight;
		this.width=window.innerWidth;
	}else{
		this.height=document.body.clientHeight;
		this.width=document.body.clientWidth;
	}	
	this.win();
}

loginPan.prototype.win=function(){ 
	if($('over')){
		over=$('over');
		over.innerHTML='';
	}else{
		over=document.createElement('div');
		over.id="over";
		over.style.position	="absolute";
		over.style.top		="0px";
		over.style.left		="0px";
		over.style.width	="100%";
		over.style.height	="100%";
	}
	
	this.pageContainer.appendChild(over);
	backgr=document.createElement('div');
	backgr.style.backgroundColor="#000000";
	backgr.style.position	="absolute";
	backgr.style.zIndex		="9";
	backgr.style.top		="0px";
	backgr.style.left		="0px";
	backgr.style.width		="100%";
	//backgr.style.height	="100%";
	backgr.style.height		="100%"; 
	backgr.style.opacity	="0.2";
	backgr.style.filter	="alpha(opacity=20)";
	over.appendChild(backgr);
	
	pan= document.createElement('div'); 
	over.appendChild(pan);
	pan.style.zIndex		="10";
	pan.style.backgroundColor="#ffffff";
	pan.style.border	="3px solid #888888";
	pan.style.position	="absolute";
	pan.style.top		=(this.y-100)+"px";
	pan.style.left		=(this.width/2-100)+"px";
	pan.style.width		="400px";
	pan.style.height	="240px";
	
	newpostForm= document.createElement('form'); 
	pan.appendChild(newpostForm);
	newpostForm.action='';
	newpostForm.method="post";
	//newpostForm.onupload=function(){return false;}
	newpostFormFieldset=document.createElement('fieldset');
	newpostForm.appendChild(newpostFormFieldset);
	newpostFormFieldset.style.padding="5px 10px 10px 10px";
	newpostFormFieldset.style.margin="10px";
	
	newpostFormFieldsetLegend=document.createElement('legend');
	newpostFormFieldset.appendChild(newpostFormFieldsetLegend);
	newpostFormFieldsetLegend.innerHTML='<img src="'+imgpath+'icon_keyLock_20.png" /> Вход';
	newpostFormFieldsetLegend.style.fontWeight="bold";
	
	newpostFormFieldsetDiv=document.createElement('div');
	newpostFormFieldset.appendChild(newpostFormFieldsetDiv);
	newpostFormFieldsetDiv.style.styleFloat="left";
	newpostFormFieldsetDiv.style.width="355px";
	newpostFormFieldsetDiv.style.marginTop="10px";
	newpostFormFieldsetLable1=newLabel('username','Потребителско име:');
	newpostFormFieldsetDiv.appendChild(newpostFormFieldsetLable1);
	newpostFormFieldsetLable1.style.styleFloat="left";
	newpostFormFieldsetLable1.style.margin="3px 0px 0px 0px";
	newpostFormFieldsetInput1=newInput('text','username','username','');
	newpostFormFieldsetDiv.appendChild(newpostFormFieldsetInput1);
	newpostFormFieldsetInput1.style.styleFloat='right';
	
	newpostFormFieldsetDiv=document.createElement('div');
	newpostFormFieldset.appendChild(newpostFormFieldsetDiv);
	newpostFormFieldsetDiv.style.styleFloat="left";
	newpostFormFieldsetDiv.style.width="355px";
	newpostFormFieldsetLable1=newLabel('password','Парола:');
	newpostFormFieldsetDiv.appendChild(newpostFormFieldsetLable1);
	newpostFormFieldsetLable1.style.styleFloat="left";
	newpostFormFieldsetLable1.style.margin="2px 0px 0px 0px";
	newpostFormFieldsetInput1=newInput('password','password','password','');
	newpostFormFieldsetDiv.appendChild(newpostFormFieldsetInput1);
	newpostFormFieldsetInput1.style.styleFloat='right';
	
	/*newpostForm= document.createElement('form'); 
	pan.appendChild(newpostForm);
	newpostForm.onupload=function(){return false;}
	newpostFormFieldset=document.createElement('fieldset');
	newpostForm.appendChild(newpostFormFieldset);
	newpostFormFieldset.style.padding="5px 0px 5px 20px";
	newpostFormFieldset.style.margin="10px";*/
	
	ok=document.createElement('button');
	ok.name="login";
	ok.id="login";
	newpostFormFieldset.appendChild(ok);
	ok.style.styleFloat='right';
	ok.style.background="url('"+imgpath+"icon_right_20.png') no-repeat top left #f0fff0";
	ok.style.width='90px';
	ok.style.height='22px';
	ok.style.textAlign='left';
	ok.style.border='1px solid #f0f0f0';
	ok.style.padding='0px 0px 0px 25px';
	ok.style.margin='5px 10px 5px 0px';
	ok.innerHTML="Вход";
	ok.obj=this;
	ok.onclick=newpostForm.submit;
	ok.value='Вход!';
	
	cancel=document.createElement('button');
	newpostFormFieldset.appendChild(cancel);
	cancel.style.styleFloat='right';
	cancel.style.background="url('"+imgpath+"icon_exit_20.png') no-repeat top left #fff0f0";
	cancel.style.width='90px';
	cancel.style.height='22px';
	cancel.style.textAlign='left';
	cancel.style.border='1px solid #f0f0f0';
	cancel.style.padding='0px 0px 0px 25px';
	cancel.style.margin='5px 10px 5px 0px';
	cancel.innerHTML="Отмени";
	cancel.onclick=this.closeWindow;
	
	panDiv=document.createElement('div');
	pan.appendChild(panDiv);
	panDiv.style.margin="0px 0px 0px 10px;";
	
	a1=document.createElement('a');
	panDiv.appendChild(a1);
	a1.href=base+"lostPassword";
	a1.innerHTML='Забравена парола';
	
	panDiv=document.createElement('div');
	pan.appendChild(panDiv);
	panDiv.style.margin="5px 0px 0px 10px;";
	
	a1=document.createElement('a');
	panDiv.appendChild(a1);
	a1.href=base+"signup"
	a1.innerHTML='Регистрация';
	
}
loginPan.prototype.closeWindow=function(){
	tinyMCE.execCommand('mceRemoveControl',false,'tinyMCE');
	try{
		over=$('over');
		over.parentNode.removeChild(over);
	}catch(ex){
		alert(ex);
	}
	return false;
}