﻿var GiapUtility=new Object();GiapUtility.StringaRandom=function(lungMin,lungMax){var randomstring="";if(lungMin<lungMax&&lungMin>0&&lungMax<1024){var chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";var string_length=Math.floor(Math.random()*(lungMax-lungMin))+lungMin;for(var i=0;i<string_length;i++){var rnum=Math.floor(Math.random()*chars.length);randomstring+=chars.substring(rnum,rnum+1);}};return randomstring;};GiapUtility.GetAbsoluteTop=function(oElement){var iMaxLoop=100;var absoluteTop=oElement.offsetTop;while(oElement.tagName!="BODY"&&iMaxLoop>0){if(typeof(oElement.parentNode)!="undefined"){oElement=oElement.parentNode;absoluteTop+=oElement.offsetTop;};iMaxLoop--;};return absoluteTop;};GiapUtility.GetAbsoluteCoord=function(oElement){var absoluteCoord=new Object();var iMaxLoop=100;absoluteCoord.top=oElement.offsetTop;absoluteCoord.left=oElement.offsetLeft;while(oElement.tagName!="BODY"&&iMaxLoop>0){if(typeof(oElement.parentNode)!="undefined"){oElement=oElement.parentNode;absoluteCoord.top+=oElement.offsetTop;absoluteCoord.left+=oElement.offsetLeft;};iMaxLoop--;};return absoluteCoord;};GiapUtility.GetAbsoluteArea=function(oElement){var absoluteArea=GiapUtility.GetAbsoluteCoord(oElement);absoluteArea.width=oElement.offsetWidth;absoluteArea.height=oElement.offsetHeight;return absoluteArea;};GiapUtility.FindItemIndexFromValue=function(oCollection,valueToSearch){var itemIndex=-1;if(oCollection&&valueToSearch!=undefined){for(var i=0;i<oCollection.length&&itemIndex==-1;i++){if(oCollection[i].value==valueToSearch){itemIndex=i;}}};return itemIndex;};GiapUtility.GetElementsByAttribute=function(oElementRoot,nomeAttributo,opzTag,opzValoreAttributo){var resultElements=[];if(oElementRoot){var domElements;var oBaseElement=document;if(typeof(oElementRoot.getElementsByTagName)!="undefined"){oBaseElement=oElementRoot;};if(opzTag!=undefined&&opzTag!=null&&opzTag!=""){domElements=oBaseElement.getElementsByTagName(opzTag);}else{domElements=oBaseElement.getElementsByTagName("*");};if(domElements!=null&&domElements.length>0){for(var i=0;i<domElements.length;i++){var attributo=domElements[i].getAttribute(nomeAttributo);if(attributo!=null&&attributo!=""){if(opzValoreAttributo===undefined||opzValoreAttributo==attributo){resultElements.push(domElements[i]);}}}}};return resultElements;};GiapUtility.ImportStylesheet=function(sheetUrl){var isGiaCaricato=false;if(document.styleSheets){for(var i=0;i<document.styleSheets.length&&!isGiaCaricato;i++){isGiaCaricato=(document.styleSheets[i].href==sheetUrl);}};if(!isGiaCaricato){var ss=document.createElement("link");ss.rel="stylesheet";ss.href=sheetUrl;ss.type="text/css";document.getElementsByTagName("head")[0].appendChild(ss);};return;};


