function innovaweb(urlbase){

	this.goHome = function(){
		window.location = this.urlbase;
	}
	
	this.goModule = function(){
		window.location = this.getCurrentModule();
	}
	
	this.setBackLink = function(cancelURL){
		this.cancelURL = cancelURL;
	}
	
	this.goModuleOp = function(){
		//window.location = this.getCurrentOp();
		this.goBack();
	}
	
	this.setCurrentModule = function(module){
		this.urlcurrentmod = this.urlbase+module;
	}
	
	this.getCurrentModule = function(){
		return this.urlcurrentmod;
	}
	
	this.setCurrentOp = function(op){
		this.urlcurrentmodop = this.getCurrentModule()+op;
	}

	this.getCurrentOp = function(){
		return this.urlcurrentmodop;
	}
	
	this.setSite = function (id){
		this.site = id;
	}
	
	this.getSite = function (){
		return this.site;	
	}
	
	this.goURL = function(link){
		window.location = link;
	}
	
	this.disableSubmit = function(obj){
		try{
			document.form1.onsubmit = this.eventDisabled(obj);
		}catch(e){}
		document.form1.submit();

	}
	
	this.goBack = function(){
		if(this.cancelURL!="undefined" && this.cancelURL!="") window.location = this.cancelURL;
	}
	
	this.initEditor = function(){
		try{
			if(this.editorIsActive){
				if(!this.mceCompatible) this.showMessageNotCompatibleMCE();
				else{
					tinyMCE.init({
						mode : "exact",
						elements : "content",
						theme : "advanced",
						language : "es",
						relative_urls : false,
						remove_script_host : false,
						cleanup : false,
						plugins : "table,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu,innovaweb",
						theme_advanced_buttons1_add : "fontselect,fontsizeselect",
						theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
						theme_advanced_buttons2_add_before: "cut,copy,paste,separator,search,replace,separator",
						theme_advanced_buttons3_add_before : "tablecontrols,separator",
						theme_advanced_buttons3_add : "explorer,insertmenu,advhr,separator,print",
						theme_advanced_toolbar_location : "top",
						theme_advanced_toolbar_align : "left",
						theme_advanced_path_location : "bottom",
						plugin_insertdate_dateFormat : "%Y-%m-%d",
						plugin_insertdate_timeFormat : "%H:%M:%S",
						extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
						external_link_list_url : "example_data/example_link_list.js",
						external_image_list_url : "example_data/example_image_list.js",
						flash_external_list_url : "example_data/example_flash_list.js"
					});
				}
			}
		}catch(e){}
	}

	this.eventDisabled = function(obj){
		try{
			obj.disabled = true;
		}catch(e){
			alert(e.value);
		}
	}
	
	this.urlbase = urlbase;

	this.hideLayer = function(id){
		var itm = null;
		if (document.getElementById) 	itm = document.getElementById(id);
		else if (document.all) 			itm = document.all[id];
		else if (document.layers) 		itm = document.layers[id];
	
		if(!itm){
		}else if (itm.style) 			itm.style.display 	= "none";
		else 							itm.visibility 		= "show";
	}

	this.showHideLayer = function(id1) {
		if (id1 != '') this.toggleBlockLayer(id1);
	}

	this.toggleBlockLayer = function(id) {
		var itm = null;
		if (document.getElementById) itm = document.getElementById(id);
		else if (document.all) itm = document.all[id];
		else if (document.layers) itm = document.layers[id];

		if(!itm){
		}else if (itm.style){
			if(itm.style.display == "none") itm.style.display = "";
			else itm.style.display = "none";
		}else itm.visibility = "show";
	}
	
	this.changeInnerText =  function(object,target,newText){
		try{
			object.document.getElementById(target).innerHTML = newText;
		}catch(e){}
	}
	
	this.writeCookie = function(name, value, hours){
		var expire = "";
		if(hours != null){
			expire = new Date((new Date()).getTime() + hours * 3600000);
			expire = "; expires=" + expire.toGMTString();
		}
		document.cookie = name + "=" + escape(value) + expire;
	}
	
	this.readCookie = function(name){
		var cookieValue = "";
		var search = name + "=";
		if(document.cookie.length > 0){ 
			offset = document.cookie.indexOf(search);
			if (offset != -1){ 
				offset += search.length;
				end = document.cookie.indexOf(";", offset);
				if (end == -1) end = document.cookie.length;
				cookieValue = unescape(document.cookie.substring(offset, end));
			}
		}
		return cookieValue;
	}
	
	this.openCloseTreeItem = function (value){
		if(this.readCookie(value)==1) this.writeCookie(value, '0', 24);
		else this.writeCookie(value, '1', 24);
		this.refresh();
	}
	
	this.refresh = function(){
		document.location = document.location;
	}
	

	this.openPopup = function(url,name,width,height){
		var str = "height=" + height + ",innerHeight=" + height;
		str += ",width=" + width + ",innerWidth=" + width;
		if (window.screen) {
			var ah = screen.availHeight - 30;
			var aw = screen.availWidth - 10;
		
			var xc = (aw - width) / 2;
			var yc = (ah - height) / 2;
		
			str += ",left=" + xc + ",screenX=" + xc;
			str += ",top=" + yc + ",screenY=" + yc;
		}
		str += ",toolbar=no,directories=no,menubar=no,status=no,resizable=no,scrollbars=yes";
		newWindow = window.open(url,"_blank",str);
	}
	
	this.grantTableCheckAll = function(){
		this.grantTableChangeStatus("checked");
	}

	this.grantTableUncheckAll = function(){
		this.grantTableChangeStatus("unchecked");
	}
	
	this.grantTableChangeStatus = function(status){
		var checks = document.form1.elements;
		
		for(var x=0; x<checks.length; x++){
			if(checks[x].type=="checkbox"){
				if(status=="checked") checks[x].checked = true;
				else checks[x].checked = false;
			}
		}
	}
	
	this.grantTableOpenTree = function(){
		var	layers = this.arrLayers;
		for(x=0; x<layers.length; x++){
			this.showHideLayer(layers[x]);
		}
	}
	
	this.arrLayers	= new Array();
	
	this.grantTableAddLayer = function(val){
		this.arrLayers.push(val);
	}
	
	this.browserName;
	this.browserVersion;
	this.OS;
	
	this.setBrowser = function(browser){
		this.browserName 	= browser;
	}
	
	this.setVersion = function(version){
		this.browserVersion = version;
	}

	this.setOS = function(os){
		this.OS = os;
	}
	
	this.mceIsCompatible = function(val){
		this.mceCompatible = val;
	}
	
	this.showMessageNotCompatibleMCE = function(){
		mceNotCompatibleMessage = "<div id=\"mce\" style=\"position:absolute; left:259px; top:31px; width:473px; height:34px; z-index:1\"> ";
		mceNotCompatibleMessage += "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
		mceNotCompatibleMessage += "<tr> ";
		mceNotCompatibleMessage += "<td width=\"35\" height=\"45\"><img src=\""+this.urlbase+"/img/1.gif\"></td>";
		mceNotCompatibleMessage += "<td valign=\"bottom\">";
		mceNotCompatibleMessage += "<table width=\"100%\" height=\"29\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
		mceNotCompatibleMessage += "<tr>";
		mceNotCompatibleMessage += "<td valign=\"middle\" background=\""+this.urlbase+"/img/2.gif\"><font face=\"verdana\" size=1>Su navegador no es compatible con tinyMCE Editor, solo podrá ingresar código HTML.</font></td>";
		mceNotCompatibleMessage += "</tr>";
		mceNotCompatibleMessage += "</table>";
		mceNotCompatibleMessage += "</td>";
		mceNotCompatibleMessage += "<td valign=\"bottom\">";
		mceNotCompatibleMessage += "<table width=\"13\" height=\"29\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
		mceNotCompatibleMessage += "<tr> ";
		mceNotCompatibleMessage += "<td valign=\"bottom\" background=\""+this.urlbase+"/img/4.gif\">&nbsp;</td>";
		mceNotCompatibleMessage += "</tr>";
		mceNotCompatibleMessage += "</table>";
		mceNotCompatibleMessage += "</td>";
		mceNotCompatibleMessage += "</tr>";
		mceNotCompatibleMessage += "</table>";
		mceNotCompatibleMessage += "</div>";
		document.write(mceNotCompatibleMessage);
	}
	
	this.activatePlaceholders = function() {
		var detect=navigator.userAgent.toLowerCase(); 
		if (detect.indexOf("safari")>0) return false;
		var inputs=document.getElementsByTagName("input");
		for (var i=0;i<inputs.length;i++) {
		  if (inputs[i].getAttribute("type")=="text") {
			 var placeholder=inputs[i].getAttribute("placeholder");
			 if (placeholder.length>0) {
				inputs[i].value=placeholder;
				inputs[i].onclick=function() {
				   if (this.value==this.getAttribute("placeholder")) {
					  this.value="";
				   }
				   return false;
				}
				inputs[i].onblur=function() {
				   if (this.value.length<1) {
					  this.value=this.getAttribute("placeholder");
				   }
				}
			 }
		  }
		}
	}
	
	this.closeOpenNode = function(groupID,imgSource,isEndNode){
		this.showHideLayer(groupID);
		if(!isEndNode){
			openImg		= this.urlbase+'img/plus.gif';
			closeImg	= this.urlbase+'img/minus.gif';
		}else{
			openImg		= this.urlbase+'img/plusend.gif';
			closeImg	= this.urlbase+'img/minusend.gif';
		}
		try{
			if(imgSource!=null) imgSource.src	= imgSource.src==openImg ? closeImg : openImg;
		}catch(e){
			//alert(imgSource+' - '+e.value);
		}
	}
}