﻿//Start Suryani
var Suryani={};
Suryani.extend=function(destination, source) 
{
	for (var property in source)
  	{
  		if(destination[property])
		{
			continue;
		}
    	destination[property] = source[property];
	}
  	return destination;
};
Suryani.clone=function(matrix)
{
	if(typeof(matrix)=="function")
	{
		return new matrix();
	}
	else if(typeof(matrix)=="object")
	{
		var cloning=new Object();
		for(var member in matrix)
		{
			switch(typeof(matrix[member]))
			{
				case "object":
					cloning[member]=clone(matrix[member]);
					break;
				default:
					cloning[member]=matrix[member];
			}
		}
		return cloning;
	}
	else
	{
		var cloning = matrix;
		return cloning;
	}
}
Suryani.getWindowWidth=function(objWindow)
{
	if(objWindow.innerWidth)
	{
		return Math.min(objWindow.innerWidth,objWindow.document.documentElement.clientWidth);
	}
	else
	{
		return objWindow.document.documentElement.clientWidth;
	}
}

Suryani.getWindowHeight=function(objWindow)
{
	if(objWindow.innerHeight)
	{
		return Math.min(objWindow.innerHeight,objWindow.document.documentElement.clientHeight);
	}
	else
	{
		return objWindow.document.documentElement.clientHeight;
	}
}

Suryani.getDocumentScrollTop=function(objDocument)
{
	return Math.max(objDocument.documentElement.scrollTop,objDocument.body.scrollTop);
}

Suryani.getDocumentScrollLeft=function(objDocument)
{
	return Math.max(objDocument.documentElement.scrollLeft,objDocument.body.scrollLeft);
}

Suryani.getDocumentWidth=function(objDocument)
{
	return objDocument.documentElement.scrollWidth;
}

Suryani.getDocumentHeight=function(objDocument)
{
	return objDocument.documentElement.scrollHeight;
}

Suryani.maxZIndex=function(objDocument)
{
	var zIndex=0;
	var elments=objDocument.getElementsByTagName("*");
	for(var i=0;i<elments.length;i++){
		if(elments[i].style.zIndex)
		{
			if(zIndex<parseInt(elments[i].style.zIndex))
			{
				zIndex=elments[i].style.zIndex;
			}
		} 
	}
	return parseInt(zIndex);
}

Suryani.BindEvent=function(element,type,listener)
{
	if (window.addEventListener) 
	{
   		element.addEventListener(type, listener, false);
	} 
	else if (window.attachEvent) 
	{
		element.attachEvent('on'+type, listener);
	}
}
Suryani.userAgent = navigator.userAgent.toLowerCase();
Suryani.browser = {
    version: (Suryani.userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
    safari: /webkit/.test(Suryani.userAgent),
    opera: /opera/.test(Suryani.userAgent),
    msie: /msie/.test(Suryani.userAgent) && !/opera/.test(Suryani.userAgent),
    mozilla: /mozilla/.test(Suryani.userAgent)&&!/(compatible|webkit)/.test(Suryani.userAgent)
};
//End Suryani

//Start List
function List()
{
	this.data=new Array();
}
List.prototype.count=function()
{
	return this.data.length;
}

List.prototype.indexOf=function(item)
{
	var index=-1;
	for(var i=this.count();i>=0;)
	{
		if(this.data[--i]==item)
		{
			index=i;
			break;
		}
	}
	return index;
}
List.prototype.contain=function(item)
{
	return this.indexOf(item)==-1?false:true;
}
List.prototype.add=function(item)
{
	if(this.contain(item))
	{
		return;
	}
	this.data.push(item);
}
List.prototype.removeAt=function(index)
{
	for(var i=index;i<this.count()-1;i++)
	{
		this[i]=this[i+1];
	}
	return this.data.pop();
}
List.prototype.item=function(index)
{
	if(index>=0 && index<=this.count()-1)
	{
		return this.data[index]
	}
}
List.prototype.remove=function(item)
{
	var index=this.indexOf(item);
	if(index!=-1)
	{
		return this.removeAt(index);
	}
	return null;
}
//End List

//Start MaskPopup
function MaskPopup(param)
{
	this.targetWindow=param["targetWindow"]||window;
	this.elementKey=new Array();
	this.element=new Object();
	this.style=new Object();
	this.cssClass=new Object();
	
	this.elementKey.push("maskSpan");
	this.elementKey.push("maskDiv");
	this.element["maskSpan"]=this.targetWindow.document.createElement("span");
	this.element["maskDiv"]=this.targetWindow.document.createElement("div");
    this.style["maskDiv"]={opacity:0.5, zIndex:Suryani.maxZIndex(this.targetWindow.document)+1, backgroundColor:'#EEE',position:'absolute',overflow:'hidden'};
}
MaskPopup.prototype.setStyle=function()
{
	this.element.maskDiv.style.zIndex=this.style["maskDiv"]["zIndex"];
	this.element.maskDiv.style.position=this.style["maskDiv"]["position"];
	this.element.maskDiv.style.backgroundColor=this.style["maskDiv"]["backgroundColor"];
	this.element.maskDiv.style.overflow=this.style["maskDiv"]["overflow"];
	if(typeof(this.element.maskDiv.style.opacity)=="undefined")
	{
		this.element.maskDiv.style.filter="alpha(opacity="+this.style["maskDiv"]["opacity"]*100+")";
	}
	else
	{
		this.element.maskDiv.style.opacity=this.style["maskDiv"]["opacity"];
	}
}

MaskPopup.prototype.setSize=function()
{
	this.element.maskDiv.style.width="100%";
	this.element.maskDiv.style.height=Math.max(Suryani.getWindowHeight(this.targetWindow),Suryani.getDocumentHeight(this.targetWindow.document))+"px";
}

MaskPopup.prototype.setPosition=function()
{
	this.element.maskDiv.style.left="0px";
	this.element.maskDiv.style.top="0px";
}
MaskPopup.prototype.build=function()
{
	//IE6SelectHack
	if(Suryani.browser.msie && parseInt(Suryani.browser.version)<=6)
	{
		var html="<iframe src=\"\" style=\"z-index:-1;background-color:transparent;width:100%;height:100%\"></iframe>";
		this.element.maskDiv.insertAdjacentHTML("beforeEnd",html);
	}
	this.element.maskSpan.appendChild(this.element.maskDiv);
	this.targetWindow.document.body.appendChild(this.element.maskSpan);
}
MaskPopup.prototype.bindEvent=function()
{
	var me=this;
	Suryani.BindEvent(this.targetWindow,"resize",function(){ me.setSize();});
}
MaskPopup.prototype.show=function()
{
	this.setSize();
	this.setStyle();
	this.build();
	this.setPosition();
	this.bindEvent();
}
MaskPopup.prototype.close=function()
{
	this.targetWindow.document.body.removeChild(this.element.maskSpan);
}
//End MaskPopup

//Start Popup
function Popup(param)
{
	this.targetWindow=param["targetWindow"]||window;
	this.elementKey=new Array();
	this.config=new Object();
	this.element=new Object();
	this.callBack=new Object();
	this.cssClass=new Object();
	this.style=new Object();
	this.size=new Object();
	this.position=new Object();
	this.action=new Object();
	this.actionData=new Object();
	
	if(param.showMask)
	{
		this.config["showMask"]=param.showMask;
		this.mask=new MaskPopup({targetWindow:this.targetWindow});
	}
	this.config["title"]=param.title;
	this.config["content"]=param.content;
	this.config["language"]=param["language"]||"en-us";
	this.config["autoSize"]=false;
	this.config["moveable"]=!!param["moveable"];
	this.callBack["closeCallBack"]=param.closeCallBack;
	
	this.size["width"]=param.width||300;
	this.size["height"]=param.height||180;
	
	this.position["top"]=param.top;
	this.position["left"]=param.left;
	this.init();
}

Popup.language=new Object();

Popup.language["en-us"]=new Object();
Popup.language["en-us"]["ok"]="OK";
Popup.language["en-us"]["cancel"]="Cancel";
Popup.language["en-us"]["close"]="Close";
Popup.language["en-us"]["yes"]="Yes";
Popup.language["en-us"]["no"]="No";

Popup.prototype.init=function()
{
	this.action["hasShow"]=false;
	this.action["isMoving"]=false;
	
	this.actionData["moveStart"]=null;
	this.actionData["moveEnd"]=null;
	
	this.elementKey.push("popupSpan");
	this.elementKey.push("popupDiv");
	this.elementKey.push("popupBorderTop");
	this.elementKey.push("popupBorderBottom");
	this.elementKey.push("popupContent");

	this.elementKey.push("closeDiv");
	this.elementKey.push("headerDiv");

	this.elementKey.push("contentDiv");
	this.elementKey.push("contentBorderDiv");
	this.element["popupSpan"]=this.targetWindow.document.createElement("span");
	this.element["popupDiv"]=this.targetWindow.document.createElement("div");
	this.element["popupBorderTop"]=this.targetWindow.document.createElement("div");
	this.element["popupBorderBottom"]=this.targetWindow.document.createElement("div");
	
	this.element["popupContent"]=this.targetWindow.document.createElement("div");
	this.element["popupContent"].setAttribute("class","stickyTooltipContent");
	this.element["popupContent"].setAttribute("className","stickyTooltipContent");
	
	this.element["contentBorderDiv"]=this.targetWindow.document.createElement("div");
	this.element["contentBorderDiv"].setAttribute("class","stickyTooltipContentLeftBorder");
	this.element["contentBorderDiv"].setAttribute("className","stickyTooltipContentLeftBorder");
	
	this.element["headerDiv"]=this.targetWindow.document.createElement("h2");
	if (this.config["title"]!=""){
	    this.element["headerDiv"].setAttribute("class","stickyTooltipTitle");
	    this.element["headerDiv"].setAttribute("className","stickyTooltipTitle");
	}
	else{
	    this.element["headerDiv"].setAttribute("class","stickyTooltipTitleNoLine");
	    this.element["headerDiv"].setAttribute("className","stickyTooltipTitleNoLine");
	}
	this.element["closeDiv"]=this.targetWindow.document.createElement("div");
	this.element["closeDiv"].setAttribute("class","closeBtn");
	this.element["closeDiv"].setAttribute("className","closeBtn");
	this.style["closeDiv"]={position:"absolute",right:"15px",top:"10px"};
	
	this.element["contentDiv"]=this.targetWindow.document.createElement("div");
	this.style["contentDiv"]={padding:"10px 0px 5px 0"};
	
	this.style["popupDiv"]={position:"absolute"};
	
	this.style["popupDiv"]["zIndex"]=Suryani.maxZIndex(this.targetWindow.document)+3;
}

//initBackground
Popup.prototype.initBackground=function(){}
//initContent
Popup.prototype.initContent=function(){}
//setStyle
Popup.prototype.setStyle=function()
{
	for(var i=this.elementKey.length-1;i>0;i--)
	{
		var key=this.elementKey[i];
		if(!this.style[key])
		{
			continue;
		}
		for(var styleItem in this.style[key])
		{
			try
			{
				this.element[key].style[styleItem]=this.style[key][styleItem];
			}
			catch(e)
			{}
		}
	}
}
Popup.prototype.setClass=function()
{
	for(var i=this.elementKey.length-1;i>0;i--)
	{
		var key=this.elementKey[i];
		if(!this.cssClass[key])
		{
			continue;
		}
		try
		{
			this.element[key].className=this.cssClass[key];
		}
		catch(e)
		{}
	}
}
//setSize
Popup.prototype.setSize=function()
{
	this.element.popupDiv.style["width"]=this.size.width+"px";
	this.element.popupDiv.style["height"]=this.size.height+"px";
}
//setSize with URL iframe
Popup.prototype.setUrlSize=function()
{
	this.element.popupDiv.style["width"]=(parseInt(this.size.width)+32) +"px";
	this.element.popupDiv.style["height"]=this.size.height+"px";
}
//setPosition
Popup.prototype.setPosition=function()
{
        if(this.position.top)
        {
            this.element.popupDiv.style["top"]=this.position.top+"px";
        }
        else
        {
			var availHeight=Suryani.getWindowHeight(this.targetWindow);
			var availTop=0;
			if(availHeight-this.size.height>0)
			{
				availTop=(availHeight-this.size.height)/2+Suryani.getDocumentScrollTop(this.targetWindow.document);
			}
            this.element.popupDiv.style["top"]=availTop+"px";
        }
        if(this.position.left)
        {
            this.element.popupDiv.style["left"]=this.position.left+"px";
        }
        else
        {
			var availWidth=Suryani.getWindowWidth(this.targetWindow);
			var availLeft=0;
			if(availWidth-this.size.width>0)
			{
				availLeft=(availWidth-this.size.width)/2+Suryani.getDocumentScrollLeft(this.targetWindow.document);
			}
            this.element.popupDiv.style["left"]=availLeft+"px";
        }
}
//build
Popup.prototype.build=function()
{
	this.element["headerDiv"].innerHTML=this.config["title"];
	
	//IE6SelectHack
	if(Suryani.browser.msie && parseInt(Suryani.browser.version)<=6)
	{
		var html="<iframe src=\"\" style=\";position:'absolute';top:0;left:0;z-index:-1;filter:mask();width:100%;height:100%\"></iframe>";
		this.element["popupDiv"].insertAdjacentHTML("beforeEnd",html);
	}
	
    this.element["popupBorderTop"].innerHTML = "<div class=\"stickyTooltipTopLeft\"> </div><div class=\"stickyTooltipTopRight\"> </div><div class=\"clear\"> </div>";
    this.element["popupBorderTop"].setAttribute("class","stickyTooltipTop");
    this.element["popupBorderTop"].setAttribute("className","stickyTooltipTop");
    this.element["popupDiv"].appendChild(this.element["popupBorderTop"]);
    
    this.element["contentBorderDiv"].appendChild(this.element["headerDiv"]);
    this.element["contentBorderDiv"].appendChild(this.element["contentDiv"]);
    this.element["contentBorderDiv"].appendChild(this.element["closeDiv"]);
    
    this.element["popupContent"].appendChild(this.element["contentBorderDiv"]);
    this.element["popupDiv"].appendChild(this.element["popupContent"]);
	
	this.element["popupSpan"].appendChild(this.element["popupDiv"]);
	try{
		this.targetWindow.document.body.appendChild(this.element["popupSpan"]);
	}
	catch(ex){
		//alert(this.targetWindow.document.body.innerHTML);
		//alert(ex.message);
	}
	
    this.element["popupBorderBottom"].innerHTML = "<div class=\"stickyTooltipBtmLeft\"> </div><div class=\"stickyTooltipBtmRight\"> </div><div class=\"clear\"> </div>";
    this.element["popupBorderBottom"].setAttribute("class","stickyTooltipBtm");
    this.element["popupBorderBottom"].setAttribute("className","stickyTooltipBtm");
    this.element["popupDiv"].appendChild(this.element["popupBorderBottom"]);  
}
//buildContent
Popup.prototype.buildContent=function(){}
//bindEvents
Popup.prototype.bindEvents=function()
{
	var me=this;
	Suryani.BindEvent(this.element["closeDiv"],"click",function(){
			me.close();
			if(me.callBack.close)
			{
				me.callBack.close();
			}
	});
    if(me.config["moveable"])
    {
        Suryani.BindEvent(this.element["headerDiv"],"mousedown",function(event){
                me.action["isMoving"]=true;
                me.actionData["moveStart"]={left:event.clientX,top:event.clientY};
                me.element["headerDiv"].style["cursor"]='move';
        });
        Suryani.BindEvent(this.targetWindow.document,"mousemove",function(event){
                if(me.action["isMoving"])
                {
                    var srcelement = event.srcelement || event.target;
                    me.actionData["moveEnd"]={left:event.clientX,top:event.clientY};
                    var targetLeft=parseInt(me.element.popupDiv.style["left"])+event.clientX-me.actionData["moveStart"].left;
                    var targetTop=parseInt(me.element.popupDiv.style["top"])+event.clientY-me.actionData["moveStart"].top;
                    if(targetLeft>=0 && targetLeft<=Suryani.getDocumentWidth(me.targetWindow.document)-me.element.popupDiv.clientWidth)
                    {
                        me.element.popupDiv.style["left"]=targetLeft+"px";
                    }
                    else
                    {
                        me.action["isMoving"]=false;
                        me.element["headerDiv"].style["cursor"]='auto';
                    }
                    if(targetTop>=0 && targetTop<=Suryani.getDocumentHeight(me.targetWindow.document)-me.element.popupDiv.clientHeight)
                    {
                        me.element.popupDiv.style["top"]=targetTop+"px";
                    }
                    else
                    {
                        me.action["isMoving"]=false;
                        me.element["headerDiv"].style["cursor"]='auto';
                    }
                    me.actionData["moveStart"]=me.actionData["moveEnd"];
                }
        });
        Suryani.BindEvent(this.targetWindow.document,"mouseup",function(){
            me.action["isMoving"]=false;
            me.element["headerDiv"].style["cursor"]='auto';
        });
    }
}
Popup.prototype.bindContentEvents=function(){}
//show
Popup.prototype.show=function()
{
	this.initBackground();
//	this.init();
//	this.initContent();
	this.setStyle();
	this.setClass();
	this.bindEvents();
	this.bindContentEvents();
	this.build();
	this.buildContent();
	this.setSize();
	this.setPosition();

	if(this.config.showMask)
	{
		this.mask.show();
	}
}
Popup.prototype.showModalDialog=function()
{
    this.show();
    this.mask.show();
}
//close
Popup.prototype.close=function()
{
	this.targetWindow.document.body.removeChild(this.element.popupSpan);
	if(this.config["showMask"])
	{
		this.mask.close();
	}
}
//addCallBack
Popup.prototype.addCallBack=function(elementKey,listener)
{
	elementKey=elementKey.toLowerCase();
	if(this.element[elementKey])
	{
		this.callBack[elementKey].add(listener);
	}
}
//removeCallBack
Popup.prototype.removeCallBack=function(elementKey,listener)
{
	elementKey=elementKey.toLowerCase();
	if(this.element[elementKey])
	{
		this.callBack[elementKey].remove(listener);
	}
}
//End Popup

//Start TipPopup
function TipPopup(param)
{
	this.base = new Popup(param);
	Suryani.extend(this,this.base);
    this.config["autoClose"]=param["autoClose"]||0;
	this.initContent();
}
TipPopup.prototype.initContent=function()
{
	this.elementKey.push("tipDiv");
	this.element["tipDiv"]=this.targetWindow.document.createElement("div");
	this.element["tipDiv"].innerHTML=this.config["content"];
	this.style["tipDiv"]={color:"#DDD",margin:"20px"}
}
TipPopup.prototype.bindContentEvents=function(){
    var me=this;
    if(me.config["autoClose"])
    {
        setTimeout(function(){try{me.close()}catch(ex){}},me.config["autoClose"]);
    }
}
TipPopup.prototype.buildContent=function()
{
	this.element["contentDiv"].appendChild(this.element["tipDiv"]);
}

//End TipPopup

//Start AlertPopup
function AlertPopup(param)
{
	this.base = new Popup(param);
	Suryani.extend(this,this.base);
	this.initContent();
}
AlertPopup.prototype.initContent=function()
{
	this.elementKey.push("tipDiv");
	this.elementKey.push("ok");
	this.elementKey.push("innerContentDiv");
	this.elementKey.push("innerButtonDiv");
	this.element["tipDiv"]=this.targetWindow.document.createElement("div");
	this.element["tipDiv"].innerHTML=this.config["content"];
	this.element["tipDiv"].setAttribute("class","redText bold");
	this.element["tipDiv"].setAttribute("className","redText bold");
	this.style["tipDiv"]={fontSize:"17px",lineHeight:"30px"};
	this.element["ok"]=this.targetWindow.document.createElement("input");
	this.element["ok"].setAttribute("type","button");
	this.element["ok"].setAttribute("value",Popup.language[this.config["language"]]["ok"]);
	this.element["ok"].setAttribute("class","redBtn");
	this.element["ok"].setAttribute("className","redBtn");
	this.element["innerContentDiv"]=this.targetWindow.document.createElement("div");
	this.element["innerButtonDiv"]=this.targetWindow.document.createElement("div");
	this.element["innerButtonDiv"].setAttribute("class","btnsBox alertHopupWinBtn textCenter");
	this.element["innerButtonDiv"].setAttribute("className","btnsBox alertHopupWinBtn textCenter");
	this.callBack["ok"]=new List();
}
AlertPopup.prototype.bindContentEvents=function()
{
	var me=this;
	Suryani.BindEvent(me.element["ok"],"click",function(){
		for(var i=0;i<me.callBack["ok"].count();i++)
		{
			me.callBack["ok"].item(i)();
		}
		me.close();
	});
}
AlertPopup.prototype.buildContent=function()
{
	this.element["innerContentDiv"].appendChild(this.element["tipDiv"]);
	this.element["innerButtonDiv"].appendChild(this.element["ok"]);
	this.element["innerContentDiv"].appendChild(this.element["innerButtonDiv"]);
	this.element["contentDiv"].appendChild(this.element["innerContentDiv"]);
}

//End AlertPopup

//Start ConfirmPopup
function ConfirmPopup(param)
{
	this.base = new Popup(param);
	Suryani.extend(this,this.base);
	this.initContent();
}
ConfirmPopup.prototype.initContent=function()
{
	this.elementKey.push("tipDiv");
	this.elementKey.push("ok");
	this.elementKey.push("cancel");
	this.elementKey.push("innerContentDiv");
	this.elementKey.push("innerButtonDiv");
	this.element["tipDiv"]=this.targetWindow.document.createElement("div");
	this.element["tipDiv"].innerHTML=this.config["content"];
	this.element["tipDiv"].setAttribute("class","redText bold");
	this.element["tipDiv"].setAttribute("className","redText bold");
	this.style["tipDiv"]={fontSize:"17px",lineHeight:"30px"};
	this.element["ok"]=this.targetWindow.document.createElement("input");
	this.element["ok"].setAttribute("type","button");
	this.element["ok"].setAttribute("value",Popup.language[this.config["language"]]["yes"]);
	this.element["ok"].setAttribute("class","redBtn");
	this.element["ok"].setAttribute("className","redBtn");
	this.element["cancel"]=this.targetWindow.document.createElement("input");
	this.element["cancel"].setAttribute("type","button");	
	this.element["cancel"].setAttribute("value",Popup.language[this.config["language"]]["no"]);
	this.element["cancel"].setAttribute("class","cancelBtn");//for firefox and safari
	this.element["cancel"].setAttribute("className","cancelBtn");//for IE
	this.element["innerContentDiv"]=this.targetWindow.document.createElement("div");
	this.element["innerButtonDiv"]=this.targetWindow.document.createElement("div");
	this.element["innerButtonDiv"].setAttribute("class","btnsBox alertHopupWinBtn textCenter");
	this.element["innerButtonDiv"].setAttribute("className","btnsBox alertHopupWinBtn textCenter");
	this.callBack["ok"]=new List();
	this.callBack["cancel"]=new List();
}
ConfirmPopup.prototype.bindContentEvents=function()
{
	var me=this;
	Suryani.BindEvent(me.element["ok"],"click",function(){
		for(var i=0;i<me.callBack["ok"].count();i++)
		{
			me.callBack["ok"].item(i)();
		}
		me.close();
	});
	Suryani.BindEvent(me.element["cancel"],"click",function(){
		for(var i=0;i<me.callBack["cancel"].count();i++)
		{
			me.callBack["cancel"].item(i)();
		}
		me.close();
	});
}
ConfirmPopup.prototype.buildContent=function()
{
	this.element["innerContentDiv"].appendChild(this.element["tipDiv"]);
	this.element["innerButtonDiv"].appendChild(this.element["ok"]);
	this.element["innerButtonDiv"].appendChild(this.element["cancel"]);
	this.element["innerContentDiv"].appendChild(this.element["innerButtonDiv"]);
	this.element["contentDiv"].appendChild(this.element["innerContentDiv"]);
}
//End ConfirmPopup

//Start PromptPopup
function PromptPopup(param)
{
	this.base = new Popup(param);
	Suryani.extend(this,this.base);
	this.initContent();
}
PromptPopup.prototype.initContent=function()
{
	this.elementKey.push("tipDiv");
	this.elementKey.push("ok");
	this.elementKey.push("text");
	this.elementKey.push("innerContentDiv");
	this.elementKey.push("innerButtonDiv");
	this.element["tipDiv"]=this.targetWindow.document.createElement("div");
	this.element["ok"]=this.targetWindow.document.createElement("input");
	this.element["ok"].setAttribute("type","button");
	this.element["ok"].setAttribute("value",Popup.language[this.config["language"]]["ok"]);
	this.element["ok"].setAttribute("class","redBtn");
	this.element["ok"].setAttribute("className","redBtn");
	this.element["text"]=this.targetWindow.document.createElement("input");
	this.element["text"].setAttribute("type","text");	
	this.element["tipDiv"].innerHTML=this.config["content"];
	this.element["innerContentDiv"]=this.targetWindow.document.createElement("div");
	this.element["innerButtonDiv"]=this.targetWindow.document.createElement("div");
	this.element["innerButtonDiv"].setAttribute("class","btnsBox alertHopupWinBtn textCenter");
	this.element["innerButtonDiv"].setAttribute("className","btnsBox alertHopupWinBtn textCenter");
	this.callBack["ok"]=new List();
	this.callBack["text"]=new List();
	this.input="";
}
PromptPopup.prototype.bindContentEvents=function()
{
	var me=this;
	Suryani.BindEvent(me.element["ok"],"click",function(){
		for(var i=0;i<me.callBack["ok"].count();i++)
		{
			me.callBack["ok"].item(i)();
		}
		me.close();
	});
	Suryani.BindEvent(me.element["text"],"keyup",function(){
		me.input=me.element["text"].value;
	});
}
PromptPopup.prototype.buildContent=function()
{
	this.element["innerContentDiv"].appendChild(this.element["tipDiv"]);
	this.element["innerContentDiv"].appendChild(this.element["text"]);
	this.element["innerButtonDiv"].appendChild(this.element["ok"]);
	this.element["innerContentDiv"].appendChild(this.element["innerButtonDiv"]);
	this.element["contentDiv"].appendChild(this.element["innerContentDiv"]);
}
//End PromptPopup

//Start HtmlPopup
function HtmlPopup(param)
{
	this.base = new Popup(param);
	Suryani.extend(this,this.base);
	this.initContent();
}
HtmlPopup.prototype.initContent=function()
{
	this.element["contentDiv"].innerHTML=this.config["content"];
}
HtmlPopup.prototype.bindContentEvents=function(){}
HtmlPopup.prototype.buildContent=function(){}
//End HtmlPopup

//Start UrlPopup
function UrlPopup(param)
{
	this.base = new Popup(param);
	Suryani.extend(this,this.base);
	this.config["autoSize"]=true;
	this.initContent();
}
UrlPopup.prototype.initContent=function()
{
	this.elementKey.push("url");
	this.element["url"]=this.targetWindow.document.createElement("iframe");
	this.element["url"].setAttribute("border","0");
	this.element["url"].setAttribute("frameBorder","0");
	this.element["url"].setAttribute("scrolling","no");
	this.element["url"].setAttribute("src",this.config["content"]);
	this.element["url"].setAttribute("width",(this.size.width)+"px");
}
UrlPopup.prototype.bindContentEvents=function(){
	var me=this;
	if(this.config["autoSize"])
	{
		Suryani.BindEvent(me.element["url"],"load",function(){
			try{
				var obj=me.element["url"];	
				if (obj.contentDocument && obj.contentDocument.body.offsetHeight)
				{
					obj.height = obj.contentDocument.body.scrollHeight;
					obj.width = obj.contentDocument.body.scrollWidth;
				}
				else
				{
					obj.height = obj.Document.body.scrollHeight;
					obj.width = obj.Document.body.scrollWidth;
				}
				me.size.height=obj.height;
				me.size.width=obj.width;
				me.setUrlSize();
				me.setPosition();
			}catch(e){
			}
		});
	}
}
UrlPopup.prototype.buildContent=function()
{
	this.element["contentDiv"].appendChild(this.element["url"]);
}
//End UrlPopup
//Start ImagePopup
function ImagePopup(param)
{
	this.base = new Popup(param);
	Suryani.extend(this,this.base);
	this.config["autoSize"]=true;
	this.initContent();
}
ImagePopup.prototype.initContent=function()
{
	this.elementKey.push("url");
	this.element["url"]=this.targetWindow.document.createElement("iframe");
	this.element["url"].setAttribute("border","0");
	this.element["url"].setAttribute("frameBorder","0");
	this.element["url"].setAttribute("scrolling","no");
	this.element["url"].setAttribute("src",this.config["content"]);
	this.element["url"].setAttribute("width",(this.size.width)+"px");
	
}
ImagePopup.prototype.bindContentEvents=function(){
	var me=this;
	if(this.config["autoSize"])
	{
		Suryani.BindEvent(me.element["url"],"load",function(){
			try{
				var obj=me.element["url"];	
                var ifrm=obj.contentWindow.document.body; 
                ifrm.style.cssText="margin:0px;padding:0px;overflow:hidden";
                var div=document.createElement("img");
                div.src=obj.src;
                obj.height=div.height;
                obj.width=div.width;
				me.size.height=obj.height;
				me.size.width=obj.width;
				me.setUrlSize();
				me.setPosition();
			}catch(e){
			}
		});
	}
}
ImagePopup.prototype.buildContent=function()
{
	this.element["contentDiv"].appendChild(this.element["url"]);
}
//End ImagePopup

//get element position: top and left
function getElementPos(elementId) {
    var ua = navigator.userAgent.toLowerCase();
    var isOpera = (ua.indexOf('opera') != -1);
    var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof
    var el = document.getElementById(elementId);
    if(el.parentNode === null || el.style.display == 'none') {
      return false;
    } 
    var parent = null;
    var pos = [];     
    var box;     
    if(el.getBoundingClientRect)    //IE
    {         
        box = el.getBoundingClientRect();
        var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
        var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
        return {x:box.left + scrollLeft, y:box.top + scrollTop};
     }
     else if(document.getBoxObjectFor)    // gecko    
     {
        box = document.getBoxObjectFor(el); 
        var borderLeft = (el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0; 
        var borderTop = (el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0; 
        pos = [box.x - borderLeft, box.y - borderTop];
     } 
     else    // safari & opera    
     {
        pos = [el.offsetLeft, el.offsetTop];  
        parent = el.offsetParent;     
        if (parent != el) { 
            while (parent) {  
                pos[0] += parent.offsetLeft; 
                pos[1] += parent.offsetTop; 
                parent = parent.offsetParent;
            }  
        }   
        if (ua.indexOf('opera') != -1 || ( ua.indexOf('safari') != -1 && el.style.position == 'absolute' )) { 
            pos[0] -= document.body.offsetLeft;
            pos[1] -= document.body.offsetTop;         
        }    
    }              
    if (el.parentNode) { 
        parent = el.parentNode;
    } 
    else {
        parent = null;
    }
    while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') { // account for any scrolled ancestors
        pos[0] -= parent.scrollLeft;
        pos[1] -= parent.scrollTop;
        if (parent.parentNode) {
            parent = parent.parentNode;
        } 
        else {
            parent = null;
        }
    }
    return {x:pos[0], y:pos[1]};
}  