if (!window['Node']) {
    window.Node = new Object();
    Node.ELEMENT_NODE = 1;
    Node.ATTRIBUTE_NODE = 2;
    Node.TEXT_NODE = 3;
    Node.CDATA_SECTION_NODE = 4;
    Node.ENTITY_REFERENCE_NODE = 5;
    Node.ENTITY_NODE = 6;
    Node.PROCESSING_INSTRUCTION_NODE = 7;
    Node.COMMENT_NODE = 8;
    Node.DOCUMENT_NODE = 9;
    Node.DOCUMENT_TYPE_NODE = 10;
    Node.DOCUMENT_FRAGMENT_NODE = 11;
    Node.NOTATION_NODE = 12;
		Node.prototype= new Object();
}

Node.prototype.removeNode=function(removeChildNodes){
	var node=this.parentNode;
	if(node&&!removeChildNodes){
		var documentFragment=document.createDocumentFragment();
		for(var i=0;i<this.childNodes.length;i++){
			documentFragment.appendChild(this.childNodes[i])
		}
		node.insertBefore(documentFragment,this)
	}
	return node?node.removeChild(this):this;
}
	
Node.prototype.clearChildNodes=function(){
	nodes=[];
	for(i=0,j=0;i<this.childNodes.length;i++){
		if(this.childNodes[i].nodeType==3){
			continue;
		}else{
			nodes[j]=this.childNodes[i];
			j++;
		}
	}
	return nodes;
}

function checkNode(node,nodeType){
  return ((nodeType==null) || (node.nodeType==Node[nodeType]) || (node.nodeName.toUpperCase()==nodeType.toUpperCase()));
}

function getChildNodes(node,nodeType){
  var result=new Array();
  node.childNodes;
  for(var i=0;i<node.childNodes.length; i++){
    if(checkNode(node.childNodes[i],nodeType)){
			result[result.length]=node.childNodes[i];
		}
  }
  return result;
}

function getElementChildNodes(node){
  return getChildNodes(node, "ELEMENT_NODE");
}

function getFirstElementChildNode(node){
  return getFirstChildNode(node,"ELEMENT_NODE");
}

function getFirstChildNode(node,nodeType){
  for(var i=0;i<node.childNodes.length;i++){
    if(checkNode(node.childNodes[i],nodeType)){
			return node.childNodes[i];
		}
  }
  return null;
}

function getNextSibling(node, nodeType){
  for(var i=node.nextSibling;i!=null;i=i.nextSibling){
    if(checkNode(i,nodeType)){
			return i;
		}
  }
  return null;
}

function getElementNextSibling(node){
   return getNextSibling(node,"ELEMENT_NODE");
}



window.location.subdomain=function(){
	var subdomain=null;
	var domain_array=window.location.hostname.toString().split('.');
	if(domain_array.length>=2){
		domain_array.pop();
		domain_array.pop();
		subdomain=domain_array.join('.');
	}
	domain_array=null;
	return subdomain;
}

/* OKKKKKKKKKKKKKK
var window_force_focus = {
	init : function() {
		var opener = window.opener;
		var child_window = self;
		if (opener.addEventListener) {
			if (!opener || !child_window) return;
			if (!opener.blur || !child_window.focus) return;
			opener.addEventListener("focus", function() {
				setTimeout(function(){
					opener.blur();
					child_window.focus();
				}, 0);
			}, false)
		} else if (opener.attachEvent) {
			opener.attachEvent("onfocus", function() {
				opener.blur();
				child_window.focus();
			})
		}
	}
}
window_force_focus.init();
*/


function dialog(url,name,feature,isModal){
	if(url==null){return false;}
		url = url
		if(name==null){name=""}
		if(feature==null){feature=""};
		if(window.showModelessDialog){
			var WindowFeature = new Object();
			WindowFeature["width"] = 400;
			WindowFeature["height"]  =400;
			WindowFeature["left"]  = "";
			WindowFeature["top"]  =  "";
			WindowFeature["resizable"]  = "";
		
			if(feature !=null && feature!=""){
				feature = ( feature.toLowerCase()).split(",");
				for(var i=0;i< feature.length;i++){
					if( feature[i].isArgument()){
						var featureName = feature[i].split("=")[0];
						var featureValue = feature[i].split("=")[1];
						if(WindowFeature[featureName]!=null){WindowFeature[featureName] = featureValue; }
					}
				}
			}
		
			if(WindowFeature["resizable"]==1 || WindowFeature["resizable"]=="1" || WindowFeature["resizable"].toString().toLowerCase()=="yes"){WindowFeature["resizable"] = "resizable:1;minimize:1;maximize:1;"}
			if(WindowFeature["left"]!=""){WindowFeature["left"] ="dialogLeft:" +  WindowFeature["left"] +"px;";}
			if(WindowFeature["top"]!=""){WindowFeature["top"] ="dialogTop:" +  WindowFeature["Top"] +"px;"; }
			if(window.ModelessDialog==null){window.ModelessDialog=new Object();};
			if(name!=""){
				if(window.ModelessDialog[name]!=null && !window.ModelessDialog[name].closed ){
					window.ModelessDialog[name].focus();
				return window.ModelessDialog[name];
			}
		}
		
		var F = WindowFeature["left"] +WindowFeature["top"] +  "dialogWidth:"+WindowFeature["width"] +" px;dialogHeight:"+WindowFeature["height"]+"px;center:1;help:0;" + WindowFeature["resizable"] +"status:0;unadorned:0;edge: raised; ;border:thick;"
		if(isModal){
			window.showModalDialog(url,self,F);
			return false;
		}else{
			window.ModelessDialog[name] = window.showModelessDialog(url,self,F);
			return window.ModelessDialog[name];
		}	
	}else{
		if(document.getBoxObjectFor){
			if(isModal){		 
				var Modal = window.open(url,name,"modal=1," + feature);
				var ModalFocus = function(){
					if(!Modal.closed){Modal.focus();}
					else{Modal =null;window.removeEventListener(ModalFocus,"focus");ModalFocus = null; };					
				}
				window.addEventListener( "focus",ModalFocus, false ); 
				return false;
			}else{
				return window.open(url,name,"modal=1," + feature);
			}	 
		}else{ 
			return window.open(url,name,feature);
		}
	}
	return null;
}
   
function modal(url,feature){
	dialog(url,"",feature,true);
	return false;
}