function swapImage(iconObj, imageclick, iconValue,chkbx, search) {
   
    var chkObj = document.getElementById(chkbx);
    var icon = document.getElementById(iconObj);
    if (search == undefined) {
        search = "True";
    }

  

if (icon.src.indexOf("_Off") == -1) 
    {

        icon.src = icon.src.replace("_On", "_Off");
        var salt = icon.alt
        if (search == "True") {
            icon.alt = icon.alt.replace("You are currently", "You are not");
            icon.alt = icon.alt.replace(" press to remove", " press to prioritise");
            icon.title = icon.title.replace("You are currently", "You are not");
            icon.title = icon.title.replace(", press to remove", ", press to prioritise");
        }
        else {
            icon.alt = icon.alt.replace("You are currently", "You are not");
            icon.alt = icon.alt.replace(" press to remove", " press to add");
            icon.title = icon.title.replace("You are currently", "You are not");
            icon.title = icon.title.replace(", press to remove", ", press to add");
        }
    chkObj.checked = false;
    if (search == "True") {
        
        UpdateCookie(iconValue, 0)
    }
    else {
        UpdateCookieEnter(iconValue, 1)
    }
    }
else
    {
        icon.src = icon.src.replace("_Off", "_On");
        
    if (search == "True") {
        icon.alt = icon.alt.replace("You are not", "You are currently");
        icon.alt = icon.alt.replace(" press to prioritise", " press to remove");
        icon.title = icon.title.replace("You are not", "You are currently");
        icon.title = icon.title.replace(", press to prioritise", ", press to remove");
    }
    else {
        icon.alt = icon.alt.replace("You are not", "You are currently");
        icon.alt = icon.alt.replace(" press to add", " press to remove");
        icon.title = icon.title.replace("You are not", "You are currently");
        icon.title = icon.title.replace(", press to add", ", press to remove");
    }
    chkObj.checked = true;
    if (search == "True") {

        UpdateCookie(iconValue, 1)
    }
    else {
        UpdateCookieEnter(iconValue, 1)
    }
    }


}


function UpdateCookie(subkey, value) 
{

    var m_cookie = getcookie("SelectedIcons");

    if (m_cookie.indexOf(subkey) !== -1) {
        var curCookie = m_cookie.split("&");
        var curCookieVals;
        var m_UpdateCookie
        for (var i = curCookie.length - 1; i >= 0; --i) {
            curCookieVals = curCookie[i].split("=");
            if (curCookieVals[0] == subkey) {
                curCookie[i] = subkey + "=" + value
            }

            if (i == curCookie.length - 1) {
                m_UpdateCookie = curCookie[i]
            } else { m_UpdateCookie = m_UpdateCookie + "&" + curCookie[i] }
        }

        setcookie("SelectedIcons", m_UpdateCookie, 7)

    }
    else {
        m_cookie = m_cookie + "&" + subkey + "=" + value
    }
}

function UpdateCookieEnter(subkey, value) {
    var m_cookie = getcookie("EnteredIcons");

  
    if (m_cookie.indexOf(subkey) !== -1) {
        var curCookie = m_cookie.split("&");
        var curCookieVals;
        var m_UpdateCookie
        for (var i = curCookie.length - 1; i >= 0; --i) {
            curCookieVals = curCookie[i].split("=");
            if (curCookieVals[0] == subkey) {
                curCookie[i] = subkey + "=" + value
            }

            if (i == curCookie.length - 1) {
                m_UpdateCookie = curCookie[i]
            } else { m_UpdateCookie = m_UpdateCookie + "&" + curCookie[i] }
        }

        setcookie("EnteredIcons", m_UpdateCookie, 7)

    }
}


function chkJS()
{ 
   document.getElementById("divSymbols").className = "";
   document.getElementById("txtJSEnabled").value = "true";
}

function chkAdvSearchJS()
{
   document.getElementById("divSymbols").className = "";
   document.getElementById("txtJSEnabled").value = "true";
   callChangeImages();
}

function getexpirydate(nodays)
	{
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
	}

function getcookie(cookiename) 
	{
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="") return ""; 
	var index2=cookiestring.indexOf(';',index1);
	if (index2==-1) index2=cookiestring.length; 
		return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
	}

function setcookie(name,value,duration)
{
    cookiestring = name + "=" + value + ";EXPIRES=" + getexpirydate(duration) + "; path=/;";
	document.cookie=cookiestring;
	if(!getcookie(name))
	{
		return false;
	}
	else
	{
		return true;
	}
}

function erasecookie(name)
{
	cookiestring=name+"=; expires=Fri, 21 Dec 1976 04:31:24 GMT; path=/;";
	document.cookie=cookiestring;
}

function setIconsVals()
{	
	document.getElementById("selIcons").value = getcookie("delsymbols");
	document.getElementById("selIcons2").value = getcookie("delsymbols2");
	document.getElementById("selIconsM").value = getcookie("delsymbolsM");

	callChangeImages();
	
}

function changeImages(icon,myvalue)
{

	document.getElementById(icon).alt = document.getElementById(icon).alt.replace("'","You are not looking for '");
    document.getElementById(icon).alt = document.getElementById(icon).alt.replace(".","', press to prioritise");
    document.getElementById(icon).title = document.getElementById(icon).title.replace("'", "You are not looking for '");
    document.getElementById(icon).title = document.getElementById(icon).title.replace(".","', press to prioritise");

	if ((document.getElementById("selIcons").value & myvalue) == myvalue)
	{ 
        document.getElementById(icon).src = document.getElementById(icon).src.replace("_Off","_On");
	    document.getElementById(icon).alt = document.getElementById(icon).alt.replace("You are not","You are currently");
        document.getElementById(icon).alt = document.getElementById(icon).alt.replace(", press to prioritise",", press to remove");
        document.getElementById(icon).title = document.getElementById(icon).title.replace("You are not","You are currently");
        document.getElementById(icon).title = document.getElementById(icon).title.replace(", press to prioritise",", press to remove");
    }  
}

function changeImages2(icon,myvalue) {

 

	if (document.getElementById(icon) == null || document.getElementById(icon) == "undefined") {
		null;
	}
	else {
	    document.getElementById(icon).alt = document.getElementById(icon).alt.replace("'", "You are not looking for '");
		document.getElementById(icon).alt = document.getElementById(icon).alt.replace(".","', press to prioritise");
		document.getElementById(icon).title = document.getElementById(icon).title.replace("'", "You are not looking for '");
		document.getElementById(icon).title = document.getElementById(icon).title.replace(".","', press to prioritise");

		if ((document.getElementById("selIcons2").value & myvalue) == myvalue)
		{ 
			document.getElementById(icon).src = document.getElementById(icon).src.replace("_Off","_On");
			document.getElementById(icon).alt = document.getElementById(icon).alt.replace("You are not","You are currently");
			document.getElementById(icon).alt = document.getElementById(icon).alt.replace(", press to prioritise",", press to remove");
			document.getElementById(icon).title = document.getElementById(icon).title.replace("You are not","You are currently");
			document.getElementById(icon).title = document.getElementById(icon).title.replace(", press to prioritise",", press to remove");
		}
    }
}

function changeImagesM(icon,myvalue)
{

	if (document.getElementById(icon) == null || document.getElementById(icon) == "undefined") {
		null;
	}
	else {
	    document.getElementById(icon).alt = document.getElementById(icon).alt.replace("'", "You are not looking for '");
		document.getElementById(icon).alt = document.getElementById(icon).alt.replace(".","', press to prioritise");
		document.getElementById(icon).title = document.getElementById(icon).title.replace("'", "You are not looking for '");
		document.getElementById(icon).title = document.getElementById(icon).title.replace(".","', press to prioritise");

		if ((document.getElementById("selIconsM").value & myvalue) == myvalue)
		{ 
			document.getElementById(icon).src = document.getElementById(icon).src.replace("_Off","_On");
			document.getElementById(icon).alt = document.getElementById(icon).alt.replace("You are not","You are currently");
			document.getElementById(icon).alt = document.getElementById(icon).alt.replace(", press to prioritise",", press to remove");
			document.getElementById(icon).title = document.getElementById(icon).title.replace("You are not","You are currently");
			document.getElementById(icon).title = document.getElementById(icon).title.replace(", press to prioritise",", press to remove");
		}  

	}
}


function callChangeImages()
{
   changeImages('VISI',1);
   changeImages('GDOG',2);
   changeImages('WHCA',4);
   changeImages('WHC',8);
   changeImages('WALK',16);
   changeImages('WC',67108864);
   changeImages('DWC',32);
   changeImages('SIGN',64);
   changeImages('HEAR',128);
   changeImages('ILOOP',131072);
   changeImages('CPARK',33554432);
   changeImages('PARK',256);
   changeImages('STAFF',8192);
   changeImages('COUNTER',2048);
   changeImages('PUSH',4194304);
   changeImages('BABY',8388608);
   changeImages('ABABY',16777216);
   
   changeImages2('ALTL',1);
      
   changeImages2('HOIST',8);
   changeImages2('ABATH',16);
   changeImages2('ASHOWER', 32);
   changeImages2('ABEDROOM', 64);
      
   changeImagesM('MHOME',1);
   changeImagesM('MMOT',2);
   changeImagesM('MCOLDEL',16);
   changeImagesM('MWASH',4);
   changeImagesM('MCOURT',8);

}
