var ie=document.all
var ns6=document.getElementById && !document.all
var m=false;
var x=0, y=0;
var xmouse=0, ymouse=0;
var time;
var dragapproved=false
var win=false;

function initializedrag(e){
	offsetx=ie? event.clientX : e.clientX
	offsety=ie? event.clientY : e.clientY
	if (ie)
		document.getElementById("showimage").style.display=''
	
	tempx=parseInt(document.getElementById("showimage").style.left)
	tempy=parseInt(document.getElementById("showimage").style.top)
	
	dragapproved=true
	document.onmousemove=drag_drop
}

function drag_drop(e){
	if (ie&&dragapproved&&event.button==1){
		height=document.body.clientHeight+document.body.scrollTop-255;
		width=document.body.clientWidth+document.body.scrollLeft-365;
		xpos=tempx+event.clientX-offsetx;
		ypos=tempy+event.clientY-offsety;
		if( xpos>0 && xpos<width && ypos>0 && ypos<height ){
			document.getElementById("showimage").style.left=xpos;
			document.getElementById("showimage").style.top=ypos;
		}
	}else if (ns6&&dragapproved){
		document.getElementById("showimage").style.left=tempx+e.clientX-offsetx
		document.getElementById("showimage").style.top=tempy+e.clientY-offsety
	}
}

function open_win(source){
	win=true;
	if (ie||ns6){
		Obj=document.getElementById? document.getElementById("showimage") : document.all.showimage
		if (Obj.style.visibility=="hidden"){
			Obj.innerHTML='\
<table border=0 bordercolor="#ff00ff" width="415" height="366" id=drag bgcolor=#ffffff cellpadding="0" cellspacing="0">\
	<tr>\
		<td style="cursor:move" onMousedown="initializedrag(event)" onSelectStart="return false" colspan=2 style="border-color:black; border-style:inset; border-width:0px;padding-top:3px;padding-right:3" background='+source+' valign=top bgcolor="#ffffff">\
			<table width="100%" height="100%" border="0" bordercolor="#ff0000" cellpadding="0" cellspacing="0">\
				<tr>\
					<td colspan="2" height="20"><img style="cursor:hand" src=close.gif alt=Close onClick=close_win()></td>\
				</tr>\
				<tr>\
					<td colspan="2">&nbsp;\
					</td>\
				</tr>\
				<tr>\
					<td colspan="2">\
					<div>\
					<marquee dir="rtl" width="100%" scrollamount="3" align="right" direction="right" style="height:10">\
					<b><font size="3" face="Arial" color="#4AE839;">ميلاد با سعادت سرور کائنات، خاتم پيامبران حضرت محمد مصطفى (ص) و سالروز فرخنده ميلاد پايه گذار فقه جعفرى امام صادق (ع) مبارک باد.</font></b>\
					</marquee>\
					</div>\
					</td>\
				</tr>\
				<tr>\
					<td width="100%" height="35" align="left"><b><a href="monasebat/28_safar/index.htm" target="_blank"><font size="+1" face="Arial" color="#FF6666;"><a href="monasebat/veladat_rasol/index.htm">ويژه نامه ولادت&nbsp;&nbsp;&nbsp;\
					</a></b></font></td>\
				</tr>\
				<tr>\
					<td colspan="2" height="190">&nbsp;\
					</td>\
				</tr>\
			</table>\
		</td>\
	</tr>\
</table>\
'
			if(ie){
				Obj.style.left=document.body.scrollLeft+1
				Obj.style.top=document.body.scrollTop+1
			}
			Obj.style.visibility="visible"
		}else
			Obj.style.visibility="hidden"
	}
}

function close_win(){
	if(win){
		Obj.style.visibility="hidden"
		win=false;
	}
}

function Esc(){
	if( ie && event.keyCode==27 )
		close_win()
}

document.onkeypress=Esc


