 dojo.require("dojox.image.Lightbox"); 
   function windowsize()
   {
   	var w = 0;
   	var h = 0;

   	//IE
   	if(!window.innerWidth)
   	{
   		//strict mode
   		if(!(document.documentElement.clientWidth == 0))
   		{
   			w = document.documentElement.clientWidth;
   			h = document.documentElement.clientHeight;
   		}
   		//quirks mode
   		else
   		{
   			w = document.body.clientWidth;
   			h = document.body.clientHeight;
   		}
   	}
   	//w3c
   	else
   	{
   		w = window.innerWidth;
   		h = window.innerHeight;
   	}
   	return {width:w,height:h};
   }
    
   var imagesMask = [['Images', '*.jpg;*.jpeg;']];
   
  

function getObjectByID(aID){
 
  return ((document.getElementById) ? document.getElementById(aID) : eval("document.all[\'" + aID + "\']"));
 
}

function hslIsNumeric(v) {return dojo.number.format(v)!==null};
var alertDlg;
dojo.addOnLoad(function() {
    // create the dialog:
	   alertDlg = new dijit.Dialog({
		   id: "alertDlg",
        title: "Confirmacion",
        style: "width: 300px; "
    });
	   
	  // dojo.number.locale.format(d, {selector:'date', formatLength:'short', locale:'es-mx'});
		   
});

function showAlertDlg(aTitle,aContent) {
    // set the content of the dialog:
	   alertDlg.attr("content", '<br><br><br><br>'+aContent+'<br><br><button dojoType="dijit.form.Button" type="submit">Aceptar</button>');
	   alertDlg.attr("title", aTitle);
	   //dijit.byId('alertDlg').show();
	   dojo.style(alertDlg.containerNode, {
	        position:'relative'    
	   });	   
	   alertDlg.show();
}

function showNotificationDlg(aTitle,aContent,aBtnClose) {
    // set the content of the dialog:
	   alertDlg.attr("content", '<br><br><br><br>'+aContent+'<br><br><center><button dojoType="dijit.form.Button" type="submit">'+aBtnClose+'</button></center>');
	   alertDlg.attr("title", aTitle);
	   //dijit.byId('alertDlg').show();
	   dojo.style(alertDlg.containerNode, {
	        position:'relative'
	   });	   
	   alertDlg.show();
	 
}   
function ObjectHtmlEncode(it){
		if(it === undefined){
			return "undef";
		}
		var objtype = typeof it;
		if(objtype == "number" || objtype == "boolean"){
			return it;
		}
		if(it === null){
			return "null";
		}
		if(dojo.isString(it)){ 
			return dojox.html.entities.encode(it); 
		}
		// recurse
		var recurse = arguments.callee;
		// short-circuit for objects that support "json" serialization
		// if they return "self" then just pass-through...
		var newObj;

	
		var tf = it.__json__||it.json;
		if(dojo.isFunction(tf)){
			newObj = tf.call(it);
			if(it !== newObj){
				return recurse(newObj);
			}
		}
		if(it.nodeType && it.cloneNode){ // isNode
			// we can't seriailize DOM nodes as regular objects because they have cycles
			// DOM nodes could be serialized with something like outerHTML, but
			// that can be provided by users in the form of .json or .__json__ function.
			throw new Error("Can't serialize DOM nodes");
		}



		// array
		if(dojo.isArray(it)){
			var res = dojo.map(it, function(obj){
				return recurse(obj); 				
			});
			return res;
		}
		/*
		// look in the registry
		try {
			window.o = it;
			newObj = dojo.json.jsonRegistry.match(it);
			return recurse(newObj, prettyPrint, nextIndent);
		}catch(e){
			// console.log(e);
		}
		// it's a function with no adapter, skip it
		*/
		if(objtype == "function"){
			return null; // null
		}
		// generic object code path
		var output = new Object, key;
		for(key in it){
			var  val = recurse(it[key]);

			output[key]=val;
		}
		return output;
}

function postAjaxRPC(aUrl,aSource,aMethod,aQuery,aOnLoadOk,aOnError,aParseHTML){
	   var lParseHTML = (aParseHTML == null) ? false : aParseHTML;
	   var tQuery = aQuery;

	   if (aParseHTML===true){
		   tQuery = ObjectHtmlEncode(tQuery);
		   tQuery.sys_HTMLparsed = true;
	   }
	      
	   dojo.mixin(tQuery,{kindRequest:"RPC","hslSource":aSource,"hslMethod":aMethod});
	   var deferred = dojo.xhrPost({url:aUrl, handleAs:"json-comment-optional", content:tQuery, error:aOnError, load:function(data){  if(data.resultCode=='ok'){ aOnLoadOk(data); } else {aOnError(data); } }});
}

