nav = navigator.appName.indexOf("Microsoft")!= -1 ? 1 : 2;
function deleteMessage(){

    if(confirm('Are you sure, you want to delete this record')){

      document.inboxForm.submit();

    }

}

function mouseX(evt){
	return evt.pageX ? evt.pageX : evt.clientX+(document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
}

function mouseY(evt){
	return evt.pageY ? evt.pageY : evt.clientY+(document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
}

function replyMessage(email,id){

    $("#replyDiv").show();

    $("#memid").val(id);

    $("#to").val(email);

}
function addEvent(obj,type,fn,bubbling){
	bubbling=bubbling || false;
	if(window.addEventListener){
		//Standard
		obj.addEventListener(type,fn,bubbling);
		return true;
	}else if(window.attachEvent){
		//IE
		obj['e'+type+fn]=fn;
		obj.attachEvent('on'+type,function(){
			obj['e'+type+fn](window.event);
		});
		//obj.attachEvent('on'+type,fn);
		return true;
	}
	return false;
}
addListener=addEvent;
function setAlpha(obj,value){
	if(nav==1){
		if(obj.filters.alpha){
			obj.filters.alpha.opacity=value;
		}else{
			obj.style.filter+=" alpha(opacity="+value+")";
		}
	}else{
		obj.style.opacity=value/100;
	}
}
function ToolTip(obj,title,content,width,fixed,padding,alpha){
	if(typeof(SSTT)=='undefined'){
		SSTT=document.createElement('div');
		document.body.appendChild(SSTT);
		SSTT.id='ToolTip';
		SSTT.style.display="none";
		SSTT.style.position="absolute";
		SSTT.style.zIndex=10100;
		SSTT.style.left='0px';
		SSTT.style.top='0px';
		SSTT.padding=padding==null ? "4px" : padding;
		SSTT.moved=0;
		SSTT.onmouseout=function(){
			this.style.display='none';
		}
		SSTT.intID=setInterval(function(){
			if(SSTT.style.display=='' && !SSTT.moved){
				SSTT.update(SSTT.last_e);
			}
			SSTT.moved=0;
		},500);
		SSTT.update=function(e){
			if(e){
				SSTT.last_e={pageX:e.pageX,clientX:e.clientX,clientY:e.clientY,pageY:e.pageY};
			}
			if(SSTT.move){
				if(e=e ? e : window.event){
					SSTT.moved=1;
					var mousex=mouseX(e)+15;
					var mousey=mouseY(e)+15;
					var x=mousex;
					var y=mousey;
					if(x+SSTT.clientWidth>document.body.scrollLeft+document.body.clientWidth){
						x=mousex-SSTT.clientWidth-20;
						if(x<document.body.scrollLeft){
							x=document.body.scrollLeft+document.body.clientWidth-SSTT.clientWidth;
						}
					}
					if(y+SSTT.clientHeight>document.body.scrollTop+document.body.clientHeight){
						y=mousey-SSTT.clientHeight-20;
						if(y<document.body.scrollTop){
							y=document.body.scrollTop;
						}
					}
					SSTT.style.left = x+'px';
					SSTT.style.top = y+'px';
					if(SSTT.stopafterfirst){
						SSTT.move=0;
					}
				}
			}
		}
		addEvent(document,'mousemove',SSTT.update);
		SSTT.hide=function(){
			this.style.display='none';
			SSTT.move=0;
		}
	}
	if(obj==null){
		SSTT.hide();
	}else{
		title=decodeURIComponent(title);
		width=width==null ? "" : width;
		alpha=alpha==null ? (content==null ? 100 : 90) : alpha;
		setAlpha(SSTT,alpha);
		SSTT.style.cursor=(SSTT.onclick=obj.onclick) ? "pointer" : "default";
		SSTT.onmouseover=obj.onclick ? function(){
			this.style.display='';
		} : null;
		if(content==null){
			SSTT.innerHTML='<!--[if lte IE 6]><iframe id="SSTT_iframe" style="position:absolute;z-index:-100;filter:alpha(opacity=0);"></iframe><![endif]--><table style="border:solid 1px #36c;background:#fff;filter:progid:DXImageTransform.Microsoft.Shadow(color=#333333,direction=135,strength=2,enabled=true);width:'+width+';" cellPadding="1" cellSpacing="0"><tr><td style="padding:'+SSTT.padding+';">'+title+'</td></tr></table>';
		}else{
			content=decodeURIComponent(content);
            SSTT.innerHTML='<!--[if lte IE 6]><iframe id="SSTT_iframe" style="position:absolute;z-index:-100;filter:alpha(opacity=0);"></iframe><![endif]--><table style="border:solid 1px #36c;background:#fff;filter:progid:DXImageTransform.Microsoft.Shadow(color=#333333,direction=135,strength=2,enabled=true);width:'+width+';" cellpadding="1" cellspacing="0">'+(title!="" ? '<tr><td style="background:#4B5F6D;color:#fff;padding:'+SSTT.padding+';"><b>'+title+'</b></td></tr>' : '')+'<tr valign=top><td style="padding:'+SSTT.padding+';">'+content+'</td></tr></table>';
            SSTT.innerHTML='<!--[if lte IE 6]><iframe id="SSTT_iframe" style="position:absolute;z-index:-100;filter:alpha(opacity=0);"></iframe><![endif]--><div class="col-box col-shade col-shadow">'+(title!="" ? '<div class="tooltip-title"><b>'+title+'</b></div>' : '')+'<div class="tooltip-content">'+content+'</div></div>';
		}
		SSTT.style.display = "";
		var iframe=document.getElementById('SSTT_iframe');
		if(iframe!=null){
			iframe.style.width=SSTT.offsetWidth;
			iframe.style.height=SSTT.offsetHeight;
		}
		if(obj.onmouseout==null){
			obj.onmouseout=function(){
				SSTT.hide();
			}
		}
		SSTT.move=1;
		SSTT.stopafterfirst=fixed;
		SSTT.update();
	}
}

function swapUsernameText(isFocused, add, width) {
    if (add) addto = add; else addto = '';
    if (isFocused){
     $("#headerusername"+addto).siblings("label").hide();
    } else {
     if ($("#headerusername"+addto).val() == '')
       $("#headerusername"+addto).siblings("label").show();
    }
}
function swapPasswordText(isFocused, add, width) {
    if (add) addto = add; else addto = '';
    if (isFocused){
     $("#headerpassword"+addto).siblings("label").hide();
    } else {
     if ($("#headerpassword"+addto).val() == '')
       $("#headerpassword"+addto).siblings("label").show();
    }
}
