function showHide(ID,vs){   //function to show/ hide an object
    document.getElementById(ID).style.display = Dis[vs];
}
function limitSize(txt, max)
{
    var str = txt.value;
    var result = 0;
    for (var i = 0; i < str.length; i++) {
        var c = str.charCodeAt(i);
        if ((c >= 0x0001) && (c <= 0x007F)) {
            result++;
        } else if (c > 0x07FF) {
            result += 3;
        } else {
            result += 2;
        }
        if (result >= max)
        {
            txt.value = str.substring(0, i);
            break;
        }
    }
}

function RemoveHTML( strText )
{
    var regEx = /<[^>]*>/g;
    return strText.replace(regEx, "");
}
//for escape character
function replace(str) 
{
    var comp="";
    var i = str.indexOf("&", 0);
    while (i > -1) {
        comp += str.substring(0, i+1) + "amp;";
        str = str.substring(i+1, str.length);
        i = str.indexOf("&", 0);
    }
    str = comp + str;
    
    while (str.indexOf("<", 0) > -1)
        str = str.replace("<", "&lt;");
    while (str.indexOf(">", 0) > -1)
        str = str.replace(">", "&gt;");
    while (str.indexOf('"', 0) > -1)
        str = str.replace('"', '&quot;');
    return str;
}



function replaceReverse(str) 
{
    while (str.indexOf("&amp;", 0) > -1)
        str = str.replace("&amp;", "&");
    while (str.indexOf("&gt;", 0) > -1)
        str = str.replace("&gt;", ">");
    while (str.indexOf("&lt;", 0) > -1)
        str = str.replace("&lt;", "<");
    while (str.indexOf("&quot;", 0) > -1)
        str = str.replace("&quot;", '"');
    while (str.indexOf("&nbsp;", 0) > -1)
        str = str.replace("&nbsp;", " ");
    return str;
}


<!-- Global Search --->
function get_code() {
    if (document.searchpro.searchbox.value) {
        deccode = uni2dec(document.searchpro.searchbox.value);
        document.searchpro.searchbox.value = deccode.list;
    //alert(deccode.list);
        document.write(deccode.list);
        return true;
    }
    return false;
}
<!-- Global Search --->



function initBrandSelect()
{
    var theSelect = document.getElementById("brandselector");

    if (theSelect != null) {
    theSelect.changed = false;
    theSelect.onfocus = selectFocussed;
    theSelect.onchange = selectBrandChanged;
    theSelect.onkeydown = selectKeyed;
    theSelect.onclick = selectClicked;
    }

    return true;
}

function chgBrand(brandid) {

    if (brandid != null) {
        location.replace('/productManu-detail.php?pro_brand_id='+brandid);
    } // end if

} 

function chgSubCat(subCatId) {

    if (subCatId != null) {
        location.replace('/bycat-listing.php?pro_cat_id='+subCatId);
    } // end if

} 



function selectBrandChanged(theElement)
{
    var theSelect;

    if (theElement && theElement.value)
    {
        theSelect = theElement;
    }
    else
    {
        theSelect = this;
    }

    if (!theSelect.changed)
    {
        return false;
    }

    //alert("The select has been changed to " + this.document.URL+'&pro_brand_id='+theSelect.value);
    location.replace('/productManu-detail.php?&pro_brand_id='+theSelect.value);

    return true;
}




<!------ login user change customer view ------->
function initSelect()
{
    var theSelect = document.getElementById("selector");
    

    if (theSelect != null) {
    theSelect.changed = false;
    theSelect.onfocus = selectFocussed;
    theSelect.onchange = selectChanged;
    theSelect.onkeydown = selectKeyed;
    theSelect.onclick = selectClicked;
    }
    
    return true;
}




function chgViewUser(uid)
{
    var theSelect;
    var urlStr = this.document.URL;
    var lastIndex = urlStr.lastIndexOf('&viewid');
    var newUrl = urlStr;

    if (lastIndex > 0) {
        newUrl = urlStr.substring(0, lastIndex);
    } 

    lastIndex = newUrl.lastIndexOf('#');
        
    if (lastIndex > 0) {
        newUrl = newUrl.substring(0, lastIndex);
    } 




    //alert("The select has been changed to " + this.document.URL+'&viewid='+uid);
    //alert(urlStr.lastIndexOf("viewid=")); 
    //alert(newUrl); 
    location.replace(newUrl+'&viewid='+uid);
    
    return true;
}


function chgViewUserGrp(uid)
{
    var theSelect;
    var urlStr = this.document.URL;
    var lastIndex = urlStr.lastIndexOf('&chgViewGrp');
    var newUrl = urlStr;

    if (lastIndex > 0) {
        newUrl = urlStr.substring(0, lastIndex);
    }

    lastIndex = newUrl.lastIndexOf('#');

    if (lastIndex > 0) {
        newUrl = newUrl.substring(0, lastIndex);
    }




    //alert("The select has been changed to " + this.document.URL+'&viewid='+uid);
    //alert(urlStr.lastIndexOf("viewid="));
    //alert(newUrl);
    location.replace(newUrl+'&chgViewGrp='+uid);

    return true;
}




function selectClicked()
{
    this.changed = true;
}




function selectFocussed()
{
    this.initValue = this.value;
    
    return true;
}




function selectKeyed(e)
{
    var theEvent;
    var keyCodeTab = "9";
    var keyCodeEnter = "13";
    var keyCodeEsc = "27";

    if (e)
    {
        theEvent = e;
    }
    else
    {
        theEvent = event;
    }

    if ((theEvent.keyCode == keyCodeEnter || theEvent.keyCode == keyCodeTab) && this.value != this.initValue)
    {
        this.changed = true;
        selectChanged(this);
    }
    else if (theEvent.keyCode == keyCodeEsc)
    {
        this.value = this.initValue;
    }
    else
    {
        this.changed = false;
    }
    
    return true;
}



