
/*
$(document).ready(function() {
	//window.alert("jquery正常运转...");
});
*/

function addFavorite(url, title){	
   try{
       window.external.addFavorite(url, title);
   }catch (e){
       try{
           window.sidebar.addPanel(title, url, "");
       }catch (e) {
           alert("加入收藏失败，请使用Ctrl+D进行添加");
       }
   }
}


function mergeDialogOptions(default_options,options) {
	if (options) {
		if (!options.timeout) options.timeout = default_options.timeout;
		if (!options.title) options.title = default_options.title;
		if (!options.body_text) options.body_text = default_options.body_text;
		if (!options.show_div) options.show_div = default_options.show_div;		
	}
}

function showNotice(notice_text, options){
	var default_options = {title:"提示信息",timeout:5,modal:false,body_text:null,show_div:"dialog_message"};
	if(!options){
		var options = new Array();		
	}
	options.body_text = notice_text;
	mergeDialogOptions(default_options,options);
	doShowDialog(notice_text, options);
}
function showWarning(notice_text, options) {
	var default_options = {title:"警告信息",timeout:10,modal:false,body_text:null,show_div:"dialog_message"};
	if(!options){
		var options = new Array();		
	}	
	options.body_text = notice_text;
	mergeDialogOptions(default_options,options);
	doShowDialog(notice_text, options);
}
function showError(notice_text, options) {
	var default_options = {title:"错误信息",timeout:15,modal:false,body_text:null,show_div:"dialog_message"};
	if(!options){
		var options = new Array();		
	}	
	options.body_text = notice_text;
	mergeDialogOptions(default_options,options);
	doShowDialog(notice_text, options);
}


function doShowDialog(notice_text, options){
	var id = (new Date()).getTime();
	var body_text = "";
	if (options.body_text) {
		body_text = options.body_text;
	} else if (options["show_div"] && $('#'+options.show_div)[0]) {
        body_text = $('#'+options.show_div).html();
    }
	
	var $dialog = $("<div id=\"dialog_"+id+"\"></div>")
					.html("<div class='dialog_notice_text'>"+body_text+"</div><br/><div class='dialog_timer' id='dialog_timer_"+id+"'></div>")
					.dialog({
						autoOpen: true,
						title: options.title,
						buttons: {
						确认: function() {
							$(this).dialog('close');
						}
					}			
	});
	
	if (options.timeout>0) {
	   $('#dialog_timer_'+id).attr("timeout",options.timeout);
	   dialogTimeout(id);
	}
}

function dialogTimeout(id){
    var timer = $("#dialog_timer_"+id);
    if (timer[0]) {
        var n = timer.attr('timeout') - 1;
        timer.attr('timeout',n)
        var $dialog = $("#dialog_" + id);
        if (n > 0) {
            $(timer).html("[该提示信息将在&nbsp;<b>" + n + "</b>&nbsp;秒后自动关闭]");
            setTimeout("dialogTimeout('" + id + "')", 1000);
        } else {
        	$dialog.dialog('close');
        }
    }
}



/**
 * 打开一个窗口，全屏、最大化
 */
function openWindow_Max(url){
	window.open(temp_url,"new_window","top=0,left=0,toolbar=yes,resizable=yes,location=yes,fullscreen=yes");
}



function openwin_mainFrmame(url){
	top.mainFrame.location.href=url;
}


function openwin_blank(url) { 
	var width=800;
	var height=600;
	var aw=screen.availWidth;
	var ah=screen.availHeight;
	var top=(ah-height)/2;
	var left=(aw-width)/2;
	var new_win=window.open ("about:blank", "newwindow", "top="+top+", left="+left+", height="+height+", width="+width+", toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	//new_win.moveTo(0,0);
	//new_win.resizeTo(screen.availWidth,screen.availHeight);
	new_win.location=url;
}

function openwin_blank_small(url) { 
	var width=800;
	var height=600;
	var aw=screen.availWidth;
	var ah=screen.availHeight;
	var top=(ah-height)/2;
	var left=(aw-width)/2;
	var new_win=window.open ("about:blank", "newwindow", "top="+top+", left="+left+", height="+height+", width="+width+", toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	//new_win.moveTo(0,0);
	//new_win.resizeTo(screen.availWidth,screen.availHeight);
	new_win.location=url;
}

function openwin_blank_large(url) { 
	var width=screen.availWidth;
	var height=screen.availWidth;
	var aw=screen.availWidth;
	var ah=screen.availHeight;
	var top=(ah-height)/2;
	var left=(aw-width)/2;
	var new_win=window.open ("about:blank", "newwindow", "top="+top+", left="+left+", height="+height+", width="+width+", toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	//new_win.moveTo(0,0);
	//new_win.resizeTo(screen.availWidth,screen.availHeight);
	new_win.location=url;
}

function openwin_self(url){
	window.location.href=url;
}

function openwin_parent(url){
	top.mainFrame.location.href=url;
}



