///-------------------------------------------------------------------------
//jQuery弹出窗口 By Await [2009-11-22]
//--------------------------------------------------------------------------
/*参数：[可选参数在调用时可写可不写,其他为必写]
----------------------------------------------------------------------------
    title:	窗口标题
  content:  内容(可选内容为){ text | id | img | url | iframe }
    width:	内容宽度
   height:	内容高度
	 drag:  是否可以拖动(ture为是,false为否)
     time:	自动关闭等待的时间，为空是则不自动关闭
   showbg:	[可选参数]设置是否显示遮罩层(0为不显示,1为显示)
  cssName:  [可选参数]附加class名称
 ------------------------------------------------------------------------*/
 //示例:
 //------------------------------------------------------------------------
 //simpleWindown("例子","text:例子","500","400","true","3000","0","exa")
 //------------------------------------------------------------------------
var showWindown = true;
function tipsWindown(title,content,width,height,drag,time,showbg,cssName) {
	jQuery("#windown-box").remove(); //请除内容
	var width = width>= 828?this.width=828:this.width=width;	    //设置最大窗口宽度
	var height = height>= 440?this.height=440:this.height=height;  //设置最大窗口高度
	if(showWindown == true) {
		var simpleWindown_html = new String;
			simpleWindown_html = "<div id=\"windownbg\"></div>";
			simpleWindown_html += "<div id=\"windown-box\">";
			//simpleWindown_html += "<div id=\"windown-title\"><h2>&nbsp;&nbsp;&nbsp;&nbsp;单个照片尺寸设置</h2><span id=\"windown-close\"></span></div>";
			simpleWindown_html += "<div id=\"windown-content-border\"><div id=\"windown-content\"></div></div>"; 
			simpleWindown_html += "</div>";
			jQuery("body").append(simpleWindown_html);
			show = false;
	}
	contentType = content.substring(0,content.indexOf(":"));
	content = content.substring(content.indexOf(":")+1,content.length);
	switch(contentType) {
		case "text":
		jQuery("#windown-content").html(content);
		break;
		case "id":
		jQuery("#windown-content").html(jQuery("#"+content+"").html());
		break;
		case "img":
		jQuery("#windown-content").ajaxStart(function() {
			jQuery(this).html("<img src='img_ljl/loading.gif' class='loading' />");
		});
		jQuery.ajax({
			error:function(){
				jQuery("#windown-content").html("<img src="+content+" alt='' />");
			},
			success:function(html){
				jQuery("#windown-content").html("<img src="+content+" alt='' />");
			}
		});
		break;
		case "iframe":
		jQuery("#windown-content").ajaxStart(function(){
			jQuery(this).html("<img src='img_ljl/loading.gif' class='loading' />");
		});
		jQuery.ajax({
			error:function(){
			jQuery("#windown-content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+parseInt(height)+"px"+"\" scrolling=\"no\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
			},
			success:function(html){
				jQuery("#windown-content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+parseInt(height)+"px"+"\" scrolling=\"no\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
			}
		});
	}
	//jQuery("#windown-title h2").html(title);
	if(showbg == "true") {jQuery("#windownbg").show();}else {jQuery("#windownbg").remove();};
	jQuery("#windownbg").animate({opacity:"0.5"},"normal");//设置透明度
	jQuery("#windown-box").show();
	if( height >= 440) {
		//jQuery("#windown-title").css({width:(parseInt(width)+22)+"px"});
		jQuery("#windown-content").css({width:(parseInt(width)+17)+"px",height:height+"px"});
	}else {
		//jQuery("#windown-title").css({width:(parseInt(width)+10)+"px"});
		jQuery("#windown-content").css({width:width+"px",height:height+"px"});
	}
	var	cw = document.documentElement.clientWidth,ch = document.documentElement.clientHeight,est = document.documentElement.scrollTop; 
	var _version = jQuery.browser.version;
	
	if ( _version == 6.0 ) {
		jQuery("#windown-box").css({left:"50%",top:"50%",marginTop: -((parseInt(height)+53)/2)+"px",marginLeft:-((parseInt(width)+32)/2)+"px",zIndex: "999999"});
	}else {
		jQuery("#windown-box").css({left:"50%",top:"50%",marginTop:-((parseInt(height)+53)/2)+"px",marginLeft:-((parseInt(width)+32)/2)+"px",zIndex: "999999"});
	};
	var Drag_ID = document.getElementById("windown-box"),DragHead = document.getElementById("windown-title");
		
	var moveX = 0,moveY = 0,moveTop,moveLeft = 0,moveable = false;
		if ( _version == 6.0 ) {
			moveTop = est;
		}else {
			moveTop = 0;
		}
	
	jQuery("#windown-content").attr("class","windown-"+cssName);
	var closeWindown = function() {
		jQuery("#windownbg").remove();
		jQuery("#windown-box").fadeOut("slow",function(){jQuery(this).remove();});
	}
	if( time == "" || typeof(time) == "undefined") {
		jQuery("#windown-close").click(function() {
			jQuery("#windownbg").remove();
			jQuery("#windown-box").fadeOut("slow",function(){jQuery(this).remove();});
		});
	}else { 
		setTimeout(closeWindown,time);
	}
}
function windowClose(){
	document.getElementById("windownbg").style.display = "none";
	document.getElementById("windown-box").style.display = "none";
	//jQuery("#windownbg").remove();
	//jQuery("#windown-box").fadeOut("slow",function(){jQuery("#windown-box").remove();});
}

