﻿function showHomepageSection(sectionID, totalSection, buttonImage) {

            for(var iLoop=0; iLoop<=totalSection; iLoop++)
            {
                if (iLoop == sectionID)
                {
                    document.getElementById("section" + iLoop).style.display="block";
                    if (iLoop > 0)
                        document.getElementById("button" + iLoop).style.backgroundImage = "url('" + buttonImage + "')";
                }
                else
                {
                    document.getElementById("section" + iLoop).style.display="none";
                    if (iLoop > 0)
                        document.getElementById("button" + iLoop).style.backgroundImage = "url('/_img/home/spacer.gif')";
                }
            }
      }

function startCountDown(obj_id, rurl, time_in_sec)
{
    if (time_in_sec == null ||  time_in_sec == "")
        time_in_sec = 10;
        
    var obj = document.getElementById(obj_id);
    if (obj == null || obj == 'undefined')
        return;
    else
    {
        
        if (time_in_sec == 0)
        {
            document.location = rurl;
            return;
        }
        
        var secTxt = (time_in_sec == 1 ? "second" : "seconds");
        if (document.all)
            obj.innerText = time_in_sec + " " + secTxt ;
        else
            obj.textContent = time_in_sec + " " + secTxt ;
        
        var next_time_in_sec = time_in_sec - 1;
        setTimeout("startCountDown('" + obj_id + "', '" + rurl + "', '" + next_time_in_sec + "')", 1000);
    }   
}

function textCounter(field,cntfield,maxlimit) {
    if (field.value.length > maxlimit) 
        field.value = field.value.substring(0, maxlimit); // if too long...trim it!
    else
    {
        if (document.all)
            cntfield.innerText = field.value.length; // otherwise, update 'characters left' counter
        else
            cntfield.textContent = field.value.length;
    }
}

function iprOpenPicture(imgUrl, w, h, x, y, scrollable)
{
  if (w == null)
    w = 600;
  if (h == null)
    h = 550;
    
  w += 32;
  h += 96;
  
  if (x == null)
    x = (screen.width - w) / 2;
  if (y == null)
    y = (screen.height - w) / 2;
    
  if (scrollable == null)
    scrollable = "1";
    
  var positionSizeProperty = "width="+w+", height="+h+", left="+x+", top="+y;
  var imgWindow = window.open(imgUrl, "IprImgWin", "status=0, toolbar=0, menubar=0, scrollbars="+scrollable+", resizable=0," + positionSizeProperty);
  imgWindow.focus();
}


function mOver(butid, idx, status, siteid)
{
    if (siteid == null)
        siteid = "13";
	if (document.getElementById)
	{ 
		obj = document.getElementById(butid); 
		obj.src = "/data/sites/" + siteid + "/siteimages/lsa_btn_" + idx + "_" + status + ".gif";
	} 
}


function closeAfterDuration(url)
{
    window.opener.location.href = url;
    window.opener.focus();
    window.close()
}

function ToggleDiv(divName2Display, divName2Hide)
{
    var divObjs = divName2Display.split(',');
    for (i = 0; i < divObjs.length; i++)
    {
        var divObj = document.getElementById(divObjs[i]);
        if (divObj != null && divObj != "undefined")
            divObj.style.display = "";    
    }
    
    var divHideObjs = divName2Hide.split(',');
    for (j = 0; j < divHideObjs.length; j++)
    {
        var divHideObj = document.getElementById(divHideObjs[j]);
        if (divHideObj != null && divHideObj != "undefined")
            divHideObj.style.display = "none";    
    }
}

function stringTrim(strToTrim) {
	return(strToTrim.replace(/^\s+|\s+$/g, ''));
}