function CalcSize(normsrc,largersrc) {
	var frmWidth = getElementWidth('__aspnetForm');
	//alert("form width: " + frmWidth);
	var imgWidth = getElementWidth('imgTopBanner');
	//alert("Topbanner image width: " + imgWidth);			
	var divHMenuWidth = getElementWidth('Horizontalmenu');
	//alert("Horizontalmenu width: " + divHMenuWidth);
	
	//Window size: 1024 - form size: 926 - image size: 916
	//Window size: 1280 - form size: 1162 - image size: 1152
	var normsize = 916;
	var largersize = 1152;
	
	//if ((frmWidth-10) >= largersize) {
	if ((divHMenuWidth+6) >= largersize) {
		if (imgWidth != largersize) {
			var img = getElement('imgTopBanner');
			if (img) img.src = largersrc;
		}				
	}
	else {
		if (imgWidth != normsize) {
			var img = getElement('imgTopBanner');
			if (img) img.src = normsrc;
		}							
	}
}

function CalcSize_obsolete(normsrc,largersrc) {
	var frmWidth = getElementWidth('__aspnetForm');		
	var imgWidth = getElementWidth('imgTopBanner');		
	
	//Window size: 1024 - form size: 926 - image size: 916
	//Window size: 1280 - form size: 1162 - image size: 1152
	var normsize = 916;
	var largersize = 1152;
	
	if ((frmWidth-10) >= largersize) {
		if (imgWidth != largersize) {
			var img = getElement('imgTopBanner');
			if (img) img.src = largersrc;
		}				
	}
	else {
		if (imgWidth != normsize) {
			var img = getElement('imgTopBanner');
			alert("img.src: " + img.src);
			if (img) img.src = normsrc;
		}							
	}
}

function ShowSize() {
	var aW = self.screen.availWidth;
	var aH = self.screen.availHeight;
	//alert('aW: ' + aW + ' - aH: ' + aH);
	var WW = getWindowWidth();
	var WH = getWindowHeight();				
	alert('WW: ' + WW + ' - WH: ' + WH);
	var frmWidth = getElementWidth('__aspnetForm');
	alert("form width: " + frmWidth);
	var imgWidth = getElementWidth('imgTopBanner');
	alert("image width: " + imgWidth);
}

function getElementWidth( elementID ) {
	var w = 0;
	var e = getElement(elementID);
	return getWidth(e);
}; //end getElementWith( elementID )

function getWidth( e ) {
	if (e) {
		if (e.innerWidth) {			
			return e.innerWidth;
		}
		if (e.clientWidth) {
			return e.clientWidth;
		}
	}
	return 0;
}; //end getWith( e )

function setWidth( e, width ) {
	if (e) {
		if (e.innerWidth) {			
			e.innerWidth = width;
		}
		if (e.clientWidth) {
			e.clientWidth = width;
		}
	}
}; //end setWith( e )

/**
 * Returns the specified computed style on an object.
 * @param {HTMLObject} obj HTML Object
 * @param {String} styleProp Property name.
 * @return {Mixed} Computed style on object.
 */
function getStyle(obj, styleProp)
{
  if (obj.currentStyle)
    return obj.currentStyle[styleProp];
  else if (window.getComputedStyle)
    return document.defaultView.getComputedStyle(obj,null).getPropertyValue(styleProp);
}

function getElement( nameStr ) {
  if ( document.getElementById ) return document.getElementById( nameStr ); // DOM
  if ( document.all ) return document.all[ nameStr ];  // IE4
  return null;  // sorry, no NS4.
}; //end getElement( string ) -> HTML element


String.prototype.format = function()
{
	var pattern = /\{\d+\}/g;
	var args = arguments;
	return this.replace(pattern, function(capture){ return args[capture.match(/\d+/)]; });
}




// PreloadImages
function PreloadImages() 
{
	var d = document; 
	if (d.images) { 
	if(!d._p) d._p = new Array();
	var i, j=d._p.length, a=PreloadImages.arguments; 
	for (i=0; i<a.length; i++)
		if (a[i].indexOf("#") != 0) {
    		d._p[j] = new Image; 
    		d._p[j++].src = a[i];
		}
	}
}

// Waits ms milliseconds
function wait(ms)
{
	if (ms > 0) setTimeout('wait(0)', ms);
}
