var browser = navigator.userAgent;

var availwidth = new Number(0);
var availheight = new Number(0);

var isIE = false;
var isIE7 = false;
var isSafari = false;
var isFireFox = false;
var isOpera = false;

if (browser.indexOf("Opera") >= 0) 
{
    isOpera = true;
    isIE = false;
    isSafari = false;
    isFireFox = false;
}
else if (browser.indexOf("MSIE") >= 0) 
{
    isIE = true;
    isOpera = false;
    isSafari = false;
    isFireFox = false;
    if (browser.indexOf("MSIE 7") >= 0) {
        isIE7 = true;
    }
}
else if (browser.indexOf("Safari") >= 0) 
{
    isSafari = true;
    isIE = false;
    isOpera = false;
    isFireFox = false;
}
else if (browser.indexOf("Firefox") >= 0) 
{
    isFireFox = true;
    isSafari = false;
    isIE = false;
    isOpera = false;
}

if (isIE==true)
{
	availwidth=new Number(screen.width);
	availheight=new Number(screen.height);
}
else
{
	availwidth=new Number(screen.availWidth);
	availheight=new Number(screen.availHeight);
}

// Opens Modal dialog window
function OpenModalWindow(WinName,Url,iewidth,ieheight,nswidth,nsheight,scroll,status,resizable)
{
	if (isIE==true)
	{
		var objVal=window.showModalDialog("IFrameloader.aspx?url=" + Url + "&scroll=" + scroll + "&width=" + iewidth + "&height=" + ieheight + "","","scroll:" + scroll + ";status:" + status + ";resizable:" + resizable + ";center:yes;" + "dialogWidth:" + iewidth + "px;dialogHeight:" + ieheight + "px;edge:sunken");
	}
	else
	{	
		var ileft=(availwidth-nswidth)/2
		var itop=(availheight-nsheight)/2
		var objVal=window.open(Url,WinName,"toolbars=no,scrollbars=" + scroll + ",resizable=" + resizable + ",modal=yes,center=1," + "width=" + nswidth + ",height=" + nsheight + ",left=" + ileft + ",top=" + itop + "",true)
		if ((ileft + nswidth)>availwidth)
		{
			ileft=(ileft + nswidth)-(availwidth+5);
		}
		objVal.moveTo(ileft,itop-25);
	}
	return objVal;
}

function OpenModalWindowEx(WinName,Url,sArgs,nsArgsName,iewidth,ieheight,nswidth,nsheight,scroll,status,resizable)
{
	if (isIE==true)
	{
		var objVal=window.showModalDialog("IFrameloader.aspx?url=" + Url + "&scroll=1&width=" + iewidth + "&height=" + ieheight + "",sArgs,"scroll:" + scroll + ";status:" + status + ";resizable:" + resizable + ";center:yes;" + "dialogWidth:" + iewidth + "px;dialogHeight:" + ieheight + "px;edge:sunken");
	}
	else
	{	
		var ileft=(availwidth-nswidth)/2
		var itop=(availheight-nsheight)/2
		var objVal=window.open(Url + "&" + nsArgsName + "=" + sArgs,WinName,"toolbars=no,scrollbars=" + scroll + ",resizable=" + resizable + ",modal=yes,center=1," + "width=" + nswidth + ",height=" + nsheight + ",left=" + ileft + ",top=" + itop + "",true)
		if ((ileft + nswidth)>availwidth)
		{
			ileft=(ileft + nswidth)-(availwidth+5);
		}
		objVal.moveTo(ileft,itop-25);
	}
	return objVal;
}

function OpenCalendarWindow(WinName,Url,iewidth,ieheight,nswidth,nsheight,scroll,status,resizable,ileft,itop)
{
	if (isIE==true)
	{
		if ((ileft + iewidth)>availwidth)
		{
			ileft=availwidth-(iewidth+10)
		}
		if ((itop + ieheight)>availheight)
		{
			itop=availheight-(ieheight+10)
		}		
		var objVal=window.showModalDialog("IFrameloader.aspx?url=" + Url + "&scroll=" + scroll + "&width=" + iewidth + "&height=" + ieheight + ",left=" + ileft + ",top=" + itop + "","","scroll:" + scroll + ";status:" + status + ";resizable:" + resizable + ";" + "dialogWidth:" + iewidth + "px;dialogHeight:" + ieheight + "px;edge:sunken;help:0;dialogHide:1;dialogLeft:" + ileft + "px;dialogTop:" + itop + "px" + "");
	}
	else
	{	
		if ((ileft + nswidth)>availwidth)
		{
			ileft=availwidth-(nswidth+10)
		}
		if ((itop + nsheight)>availheight)
		{
			itop=availheight-(nsheight+10)
		}
		var objVal=window.open(Url,WinName,"toolbars=no,help=no,scrollbars=" + scroll + ",resizable=" + resizable + ",modal=yes," + "width=" + nswidth + ",height=" + nsheight + ",left=" + ileft + ",top=" + itop + "",true)
		
	}
	return objVal;
}

function GetQueryString()
{
	var qs = location.search.substring(1).split("&");
	var Querystring = new Array()
	for(i=0;i<qs.length;i++)
	{
		t = qs[i].split("=")
		if(t[0] && t[1])
		{
			
			Querystring[t[0]] = unescape(t[1]);
		}
		
	}
}

function OpenWindow(surl,nwidth,nheight)
{
	var nleft=(availwidth-nwidth)/2;
	var ntop=(availheight-nheight)/2;
	window.open(surl,"endsession","toolbars=0,scrollbars=0,resizable=0,width=" + nwidth + ",height=" + nheight + ",left=" + nleft + ",top=" + ntop);
}

function OpenWindowEx(surl,wname,nwidth,nheight,resizeable,scrollable,fullscreen,showtoolbars,showmenu,showaddresbar)
{
	var dwidth=parseInt(nwidth);
	var dheight=parseInt(nheight);
	if (dwidth<=0 || isNaN(dwidth))
	{
		dwidth=(availwidth * 65)/100;
		dwidth=parseInt(dwidth)
	}
	if (dheight<=0 || isNaN(dheight))
	{
		dheight=(availheight * 65)/100;
		dheight=parseInt(dheight)
	}
	
	var nleft=(availwidth-dwidth)/2;
	var ntop=(availheight-50-dheight)/2;
	nleft=parseInt(nleft);
	ntop=parseInt(ntop);
	var sfeatures="";
	if (isIE==true)
	{
		sfeatures="toolbar=" + showtoolbars + ",scrollbars=" + scrollable + ",resizable=" + resizeable + ",width=" + dwidth + ",height=" + dheight + ",left=" + nleft + ",top=" + ntop + ",menubar=" + showmenu + ",location=" + showaddresbar + ",fullscreen=" + fullscreen;
	}
	else
	{
		if (fullscreen=="1")
		{
			sfeatures="toolbar=" + ((showtoolbars=='1')?"yes":"no") + ",scrollbars=" + ((scrollable=='1')?"yes":"no") + ",resizable=" + resizeable + ((fullscreen=='1')?",fullscreen":"") + ",menubar=" + showmenu + ",location=" + ((showaddresbar=='1')?"yes":"no");
		}
		else
		{
			sfeatures="toolbar=" + ((showtoolbars=='1')?"yes":"no") + ",scrollbars=" + ((scrollable=='1')?"yes":"no") + ",resizable=" + resizeable + ",menubar=" + showmenu + ",location=" + ((showaddresbar=='1')?"yes":"no") + ",width=" + dwidth + ",height=" + dheight + ",left=" + nleft + ",top=" + ntop;
		}
	}
	window.open(surl,wname,sfeatures);
}

function OpenWindowEx1(surl,wname,nwidth,nheight,nleft,ntop,resizeable,scrollable,fullscreen,showtoolbars,showmenu,showaddresbar)
{
	var dwidth=parseInt(nwidth);
	var dheight=parseInt(nheight);
	var dleft=parseInt(nleft);
	var dtop=parseInt(ntop);
	if (dwidth<=0 || isNaN(dwidth))
	{
		dwidth=(availwidth * 65)/100;
		dwidth=parseInt(dwidth)
	}
	if (dheight<=0 || isNaN(dheight))
	{
		dheight=(availheight * 65)/100;
		dheight=parseInt(dheight)
	}
	
	if (dleft<=0 || isNaN(dleft))
	{
		dleft=(availwidth-dwidth)/2;
	}
	
	if (dtop<0 || isNaN(dtop))
	{
		dtop=(availheight-50-dheight)/2;
	}
	var sfeatures="";
	if (isIE==true)
	{
	    sfeatures = "toolbar=" + showtoolbars + ",scrollbars=" + scrollable + ",resizable=" + resizeable + ",width=" + dwidth + ",height=" + dheight + ",left=" + 
		dleft + ",top=" + dtop + ",menubar=" + showmenu + ",location=" + showaddresbar + ",fullscreen=" + fullscreen;
	}
	else
	{
		if (fullscreen=="1")
		{
		    sfeatures = "toolbar=" + ((showtoolbars == '1') ? "yes" : "no") + ",scrollbars=" + ((scrollable == '1') ? "yes" : "no") + ",resizable=" + resizeable + 
		    ((fullscreen == '1') ? ",fullscreen" : "") + ",menubar=" + showmenu + ",location=" + ((showaddresbar=='1')?"yes":"no");
		}
		else
		{
		    sfeatures = "toolbar=" + ((showtoolbars == '1') ? "yes" : "no") + ",scrollbars=" + ((scrollable == '1') ? "yes" : "no") + ",resizable=" + resizeable + 
		    ",menubar=" + showmenu + ",location=" + ((showaddresbar=='1')?"yes":"no") + ",width=" + dwidth + ",height=" + dheight + ",left=" + dleft + ",top=" + dtop;
		}
	}

	window.open(surl,wname,sfeatures);
}

function validatesize(frm,sthis,nsize,sdesc)
{
	var sVal=new String(eval("document." + frm + "." + sthis + ".value"));
	if (sVal.length>nsize)
	{
		alert(sdesc + " length cannot exceed " + nsize + " characters.")
		eval("document." + frm + "." + sthis + ".focus()");
		return false;
	}
}

function validatesizeonkeypress(frm,sthis,nsize,sdesc,e)
{
	if (e.ctrlKey==true)
	{
		return false;
	}

	if (isIE==false)
	{
		if (e.which<=0 || e.which==8)
		{
			return false;
		}
	}

	var sVal=new String(eval("document." + frm + "." + sthis + ".value"));
	if ((sVal.length+1)>nsize)
	{
		//alert(sdesc + " length cannot exceed " + nsize + " characters.")
		alert(sdesc);
		if (isIE==true)
		{
			e.keyCode=0;
		}
		else
		{
			e.stopPropagation(); 
			e.preventDefault();					
		}
		return false;
	}
}

function round (n) {
	n = Math.round (n * 100) / 100;
	n = (n + 0.001) + '';
	return n.substring(0, n.indexOf('.') + 3);
}

function isDate(dateStr,fieldName) 
{
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?

	if (matchArray == null) 
	{
		alert("Please enter " + fieldName + " date as either mm/dd/yyyy or mm-dd-yyyy.");
		return false;
	}

	month = matchArray[1]; // parse date into variables
	day = matchArray[3];
	year = matchArray[5];

	if (month < 1 || month > 12) 
	{ 
		// check month range
		alert("Month" + ((fieldName.length>0)?" of " + fieldName + " date ":" ") + "must be between 1 and 12.");
		return false;
	}

	if (day < 1 || day > 31) 
	{
		alert("Day" + ((fieldName.length>0)?" of " + fieldName + " date ":" ") + "must be between 1 and 31.");
		return false;
	}

	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
	{
		alert("Month "+month+ ((fieldName.length>0)?" of " + fieldName + " date ":"") + " doesn't have 31 days!")
		return false;
	}

	if (month == 2) 
	{ 
		// check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day > 29 || (day==29 && !isleap)) 
		{
			alert("February " + year + ((fieldName.length>0)?" of " + fieldName + " date ":"") + " doesn't have " + day + " days!");
			return false;
		}
	}
	return true; // date is valid
}

function SetTableSize(stable)
{
	var otable=document.getElementById(stable);
	var browser=navigator.userAgent;
	var otdMiddle=document.getElementById("tdMiddle");
	if (otable!=null)
	{
		if (browser.indexOf("MSIE")>=0)
		{
			if (availwidth<=800 && otable.width>1000)
			{
				otable.width=778;
			}
		}
		else if (browser.indexOf("Netscape")>=0)
		{
			if (window.innerWidth>800 && otable.width>1000)
			{
				otable.style.width="778px";
				otable.width=778;
			}
		}
		else if (browser.indexOf("Firefox")>=0)
		{
			if (window.innerWidth<=800 && otable.width>1000)
			{
				otable.width=778;
			}
		}
		else if (browser.indexOf("Safari")>=0)
		{
			if (window.innerWidth<=800 && otable.width>1000)
			{
				otable.width=778;
			}
		}
		
		if(otdMiddle!=null)
		{
			otdMiddle.width=otable.width-111
		}
	}	
	
}

function SetDivSize(sDiv)
{
	var oDiv=document.getElementById(sDiv);
	if (oDiv!=null)
	{
		if (browser.indexOf("MSIE")>=0)
		{

			if (availwidth<=800 && oDiv.style.width>1000)
			{
				oDiv.style.width=778;
			}
		
		}
		else if (browser.indexOf("Netscape")>=0)
		{
			if (window.innerWidth<=800 && oDiv.style.width>1000)
			{
				oDiv.style.width="778px";
			}
		}
		else if (browser.indexOf("Firefox")>=0)
		{
			if (window.innerWidth<=800 && oDiv.style.width>1000)
			{
				oDiv.style.width=778;
			}
		}
		else if (browser.indexOf("Safari")>=0)
		{
			if (window.innerWidth<=800 && oDiv.style.width>1000)
			{
				oDiv.style.width=778;
				oDiv.width=778;
			}
		}
	}	
	
}

function IsScriptFound(sval)
{
	if (sval==null || sval=='undefined')
	{
		return false;
	}
	var bSF=false;
	if (sval.indexOf("&amp;lt;",0)>=0 || sval.indexOf("&amp;gt;",0)>=0)
	{
		bSF=true;
	}
	else if (sval.indexOf("&lt;",0)>=0 || sval.indexOf("&gt;",0)>=0)
	{
		bSF=true;
	}				
	else if (sval.indexOf("<script",0)>=0)
	{
		bSF=true;
	}
	else if (sval.indexOf("&lt;script",0)>=0)
	{
		bSF=true;
	}
	else if (sval.indexOf("&amp;lt;script",0)>=0)
	{
		bSF=true;
	}				
	else if (sval.indexOf("/script",0)>=0)
	{
		bSF=true;
	}
	else if (sval.indexOf("script>",0)>=0)
	{
		bSF=true;
	}
	else if (sval.indexOf("script&gt;",0)>=0)
	{
		bSF=true;
	}
	else if (sval.indexOf("script&amp;gt;",0)>=0)
	{
		bSF=true;
	}
	else if (sval.indexOf("<" + "%",0)>=0 || sval.indexOf("%" + ">",0)>=0)
	{
		bSF=true;
	}
	else if (sval.indexOf("&lt;%",0)>=0 || sval.indexOf("%&gt;",0)>=0)
	{
		bSF=true;
	}
	else if (sval.indexOf("&amp;lt;%",0)>=0 || sval.indexOf("%&amp;gt;",0)>=0)
	{
		bSF=true;
	}
	return bSF;			
}

//Opens large image page from product details page
function OpenLargeImage(itemid)
{
	
	var dwidth=725;
	var dheight=(availheight*90)/100;	
	dheight=parseInt(dheight);
	if (isNaN(dheight) || dheight<=0)
	{
		var dheight=467;
	}
	var dleft=(availwidth*3)/100;
	var dtop=0;
	if (isIE==false)
	{
		dheight=dheight+18;
	}
	OpenWindowEx1('LargeImageView.aspx?ItemID=' + itemid + "&wwidth=" + dwidth.toString() + "&wheight=" + dheight.toString() + "&wleft=" + dleft.toString(),'_blank',dwidth,dheight,dleft,dtop,1,1,false,0,0,0);
}

function OpenLargeCatalogImage(itemid)
{
	var dwidth=725;
	var dheight=(availheight*90)/100;	
	dheight=parseInt(dheight);
	if (isNaN(dheight) || dheight<=0)
	{
		var dheight=467;
	}
	var dleft=(availwidth*3)/100;
	var dtop=0;
	if (isIE==false)
	{
		dheight=dheight+18;
	}
	OpenWindowEx1('ZoomedImageView.aspx?ItemID=' + itemid + "&wwidth=" + dwidth.toString() + "&wheight=" + dheight.toString() + "&wleft=" + dleft.toString(),'_blank',dwidth,dheight,dleft,dtop,1,1,false,0,0,0);

}

function OpenSuperLargeImage(imagename)
{
	var dwidth=725;
	var dheight=(availheight*90)/100;
	dheight=parseInt(dheight)
	if (isNaN(dheight) || dheight<=0)
	{
		var dheight=467;
	}
	var dleft=(availwidth*3)/100
	var dtop=0
	OpenWindowEx1('SuperLargeImageView1.aspx?imagename=' + imagename+ "&wwidth=" + dwidth.toString() + "&wheight=" + dheight.toString() + "&wleft=" + dleft.toString(),'_blank',dwidth,dheight,dleft,dtop,1,1,false,0,0,0)
}

function textkeydown(e,buttonname)
{
	if(e.keyCode==13)
	{
		__doPostBack(buttonname,'');
		return false
	}
}

function SetRMTDWidth(stable)
{
	var otable=document.getElementById(stable);
	var browser=navigator.userAgent;

	if (otable!=null)
	{

		if (browser.indexOf("MSIE")>=0)
		{
			if (availwidth<=800 && otable.width>1000)
			{
				otable.width=778;
			}
		
		}
		else if (browser.indexOf("Netscape")>=0)
		{
			if (window.innerWidth<=800 && otable.width>1000)
			{
				otable.style.width="778px";
				otable.width=778;
			}
		}
		else if (browser.indexOf("Firefox")>=0)
		{
			if (window.innerWidth<=800 && otable.width>1000)
			{
				otable.width=778;
			}
		}
		else if (browser.indexOf("Safari")>=0)
		{
			if (window.innerWidth<=800 && otable.width>1000)
			{
				otable.style.width=778;
				otable.width=778;
			}
		}
	}	
	
}

function ContinueTo(strUrl)
{
	if (strUrl.length>1)
	{
		window.location.href=strUrl;
		DataValidated=false;
	}
	else
	{
		DataValidated=true;
	}
}

function GetDivElementForBrowser(divname)
{
	var divObject=new Object();
	
	if (document.layers)
	{
		divObject=eval("document." + divname);
	}
	else if (isIE==true)
	{
		divObject=eval("document.all." + divname);
	}
	else if (document.getElementById)
	{
		divObject=eval("document.getElementById('" + divname + "')");
	}
	return divObject
}


function IsValidEmail(emailstring)
{
	var Epattern = /(@.*@)|(\.\.)|(@\.)|(^\.)/
	var Epattern1 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/
	
	Epattern.IgnoreCase = true
	Epattern1.IgnoreCase = true
	
	var bResult = Epattern.exec(emailstring)
	var bResult1 = Epattern1.exec(emailstring)

	if ((bResult==null) && (bResult1!=null))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function enforcekeyinteger(e)
{
	if (e.keyCode)
	{
		if (!(e.keyCode>=48 && e.keyCode<=57))
		{
			e.keyCode=0
		}
	}
	else if (e.which)
	{
		if (!(e.which>=48 && e.which<=57))
		{
			e.stopPropagation(); 
			e.preventDefault();
		}
	}
}

function enforcekeynumeric(e)
{
	if (e.keyCode)
	{
		if (!((e.keyCode>=45 && e.keyCode<=46) || (e.keyCode>=48 && e.keyCode<=57)))
		{
			e.keyCode=0
		}
	}
	else if (e.which)
	{
		if (!((e.which>=45 && e.which<=46) || (e.which>=48 && e.which<=57)))
		{
			e.stopPropagation(); 
			e.preventDefault();
		}
	}
}

function enforcekeydate(e)
{
	if (e.keyCode)
	{
		if (!(e.keyCode==47 || (e.keyCode>=48 && e.keyCode<=57)))
		{
			e.keyCode=0
		}
	}
	else if (e.which)
	{
		if (!(e.which==47 || (e.which>=48 && e.which<=57)))
		{
			e.stopPropagation(); 
			e.preventDefault();
		}
	}
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}

function OpenImage(imageName,replaceText,replaceWith,windowWidth,windowHeight)
{
	var strImg=new String(imageName);
	var targetImage=strImg.replace(replaceText,replaceWith);
	OpenWindowEx(targetImage,"Image",windowWidth,windowHeight,1,1,0,0,0,0)
}

function OpenImageEx(imageName,replaceText,replaceWith,windowWidth,windowHeight,windowtype,windowtitle,imagewidth,imageheight)
{
	var strImg=new String(imageName);
	var targetImage=strImg.replace(replaceText,replaceWith);
	
	if (windowtype==1)
	{
		OpenWindowEx("ShowImage.aspx?simg=" + targetImage + "&imagewidth=" + imagewidth + "&imageheight=" + imageheight + "&pagetitle=" + windowtitle,"Image",windowWidth,windowHeight,1,1,0,0,0,0)
	}
	else
	{
		OpenModalWindowEx("Image","ShowImage.aspx?simg=" + targetImage + "&imagewidth=" + imagewidth + "&imageheight=" + imageheight + "&pagetitle=" + windowtitle,'','',windowWidth,windowHeight,windowWidth,windowHeight,1,0,0);
	}
}

function setInnerDivWidth(divName)
{
	var objDiv=GetDivElementForBrowser(divName)
	var otdMiddle=document.getElementById("tdMiddle");
	if (objDiv!=null & otdMiddle!=null)
	{
		var nMiddleWidth=parseInt(otdMiddle.width);
		objDiv.style.width=nMiddleWidth;
	}
}

function right(e)
{
	var msg = "Sorry, you don't have permission to copy our images.";
	if (isIE==true)
	{
		if (event.button==2) 
		{
			alert(msg);
			return false;
		}
		else
		{ 
			return true;
		}
	}
	else	
	{
		if (e.which == 3) 
		{
			alert(msg);
			return false;
		}
		else
		{
			return true;
		}
	}
}

function traprightclick() 
{
	if(document.images)
	{
		for(i=0;i<document.images.length;i++)
		{
			document.images[i].onmousedown = right;
			document.images[i].onmouseup = right;
		}
	}
}

function imagerightclick(e)
{
	if (isIE==true)
	{
		if (e.button==2)
		{
			alert("Right click disabled.");
			return false;
		}
	}
	else
	{
		if (e.which==2 || e.which==3)
		{
			alert("Right click disabled.");
			return false;
		}
	}
}

function deleteLeadingSpaces(theStr)
{
var cntr=0

    theStr += ''

	//alert('theStr=' + theStr + '    The String Length=' + theStr)
	
	var leadingSpacesComplete=false
	var z = ''
	for (cntr=0;cntr<theStr.length;cntr++)
	{
	if (theStr.substring(cntr,cntr+1) != ' ')
		leadingSpacesComplete=true

	if (theStr.substring(cntr,cntr+1) != ' ' || leadingSpacesComplete)
		z+=theStr.substring(cntr,cntr+1)	  
	}	
	return z
}

function deleteLeadingZeros(theStr)
{
	//alert('theStr=' + theStr + '    The String Length=' + theStr)
	
	var leadingZeroesComplete=false
	var z = ''
	for (x=0;x<theStr.length;x++)
	{
	if (theStr.substring(x,x+1) != '0')
		leadingZeroesComplete=true

	if (theStr.substring(x,x+1) != '0' || leadingZeroesComplete)
		z+=theStr.substring(x,x+1)	  
	}	
	return z
}

function trim(strString)
{
	var strLead=deleteLeadingSpaces(strString)
	var strTrail=delTrailingSpaces(strLead)
	return strTrail
}


// Function will remove trailing zeroes 

function delTrailingZeros(theStr)
{
	var z = ''
	var trailingZeroesComplete=false
	for (var x=theStr.length; x>0;x--)
	{
	if (theStr.substring(x-1,x) != '0')
		trailingZeroesComplete=true

	if (theStr.substring(x-1,x) != '0' || trailingZeroesComplete)
		z = theStr.substring(x-1,x)	+ z  
	}	
	return z
}

function delTrailingSpaces(theStr)
{
	var z = ''
	var trailingSpacesComplete=false
	for (var x=theStr.length; x>0;x--)
	{
	if (theStr.substring(x-1,x) != ' ')
		trailingSpacesComplete=true

	if (theStr.substring(x-1,x) != ' ' || trailingSpacesComplete)
		z = theStr.substring(x-1,x)	+ z  
	}	
	return z
}

function loadImagesInBackground(imagesList) {
    var arList = imagesList.split('|');
    var objImg = null;
    var strImg = "";
    for (i = 0; i < arList.length; i++) {
        strImg = arList[i].toString();
        if (strImg.length > 0) {
            try {
                objImg = new Image();
                objImg.src = strImg;
            }
            catch (eRR) {
                //Do nothing
                objImg = null;
            }
            finally {
                objImg = null;
            }
        } //if (strImg.length > 0)
    } //for (i = 0; i < arList.length; i++)
}

function disableSelectAndDrag() {
    try {
        document.body.ondragstart = "return false";
        document.body.onselectstart = "return false";
    }
    catch (Err) { }
}