function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function inbox_confirm( thefrm )
{
	checked = false;
	$("input[type='checkbox']").each(function(){
		 if ( $(this).attr('checked') && $(this).attr('id') != 'check_all' )
		 	checked = true;
	});
	if ( checked == true )
		new_confirm( thefrm ,'Are you sure you want to delete this messages?','<input type=\'hidden\' name=\'delete_x\' value=\'10\' />');
	else
		new_alert('Please select at least one message.');
}

function lists_confirm( )
{
	checked = false;
	$("input[type='checkbox']").each(function(){
		 if ( $(this).attr('checked') && $(this).attr('id') != 'check_all' )
		 	checked = true;
	});
	if ( checked == true )
		new_confirm('form_list','Are you sure you want to delete this user(s)?' );
	else
		new_alert('Please select at least one user.');
}

function move_to_folder_check()
{
	checked = false;
	$("input[type='checkbox']").each(function(){
		 if ( $(this).attr('checked') && $(this).attr('id') != 'check_all' )
		 	checked = true;
	});
	if ( checked == true )
		return true;
	else{
		new_alert('Please select at least one message.');
		return false;
	}
}


new_confirm_flag_restricter = 0;

function new_confirm( action, msg, hidden_form_field )
{
	src = getScrollXY();
	scrOfX = src[0];
	scrOfY = src[1];
	tmp = getClientWidth();
	bw = tmp[0];
	bh = tmp[1];
	
	ch = $('#container').height();
	if ( bh > ch )
		ch = bh;
			
	if ( new_confirm_flag_restricter == 0 ){
		new_confirm_flag_restricter = 1;
		$('body').append('<div id="restricter" style="width:' + bw + ';height:' + ch + ';position:absolute; top:0; left:0; right:0; bottom:0; background-color:#333; z-index:20; filter:alpha(opacity=70); opacity:.70; "></div>');
	}else
		$('#restricter').show();
	
	$('#confMessage').html( msg );	
	$('#divConfMessage').show();

	bw += scrOfX;
	bh += scrOfY;
	
	w = parseInt( $('#divConfMessage').width() );
	h = parseInt( $('#divConfMessage').height() );
	
	l = bw/2 - w/2; 
	t = bh/ 2 - h/2;
	t -= 50;
	
	$('#divConfMessage').css( 'top' , t );
	$('#divConfMessage').css( 'left' , l );

	$('#btnConfOK').click(function(){
		if ( action.indexOf('.') == -1 ){
			if ( hidden_form_field ){
				$('#' + action).append( hidden_form_field );
			}
			$('#' + action).submit();
			return true;
		}else
			document.location.href = action;
	});
	
	$('#btnConfCancel').click(function(){
		$('#restricter').fadeOut( 100 );
		$('#divConfMessage').fadeOut( 100 );
	});
	
	return false;
}

function new_alert( msg )
{
	src = getScrollXY();
	scrOfX = src[0];
	scrOfY = src[1];
	tmp = getClientWidth();
	bw = tmp[0];
	bh = tmp[1];

	ch = $('#container').height();
	if ( bh > ch )
		ch = bh;

	if ( new_confirm_flag_restricter == 0 ){
		new_confirm_flag_restricter = 1;
		$('body').append('<div id="restricter" style="width:' + bw + ';height:' + ch + ';position:absolute; top:0; left:0; right:0; bottom:0; background-color:#333; z-index:20; filter:alpha(opacity=70); opacity:.70; "></div>');
	}else
		$('#restricter').show();
	
	$('#confMessage').html( msg );	
	$('#divConfMessage').show();

	bw += scrOfX;
	bh += scrOfY;
	
	w = parseInt( $('#divConfMessage').width() );
	h = parseInt( $('#divConfMessage').height() );
	
	l = bw/2 - w/2; 
	t = bh/ 2 - h/2;
	t -= 50;
	
	$('#divConfMessage').css( 'top' , t );
	$('#divConfMessage').css( 'left' , l );

	$('#btnConfCancel').hide();
	
	$('#btnConfOK').click(function(){
		$('#restricter').hide();
		$('#divConfMessage').hide();
		$('#btnConfCancel').show();
	});
	
	return false;
}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
function getClientWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [ myWidth, myHeight ];
}