var currency = "";
var currencyDecimalSep="";
var currencyThousandSep="";
var ot_last_tab = 'offertab1';

var validateTextMsgLine1 = "";
var validateTextMsgLine2 = "";
var zeroNotAllowedText = "Zero not allowed";
var savingText = "";

Encoder.EncodeType = "entity";

function alertInvalidField(field, fieldName, strMessage, layer, layerFunction) {
    var msgDesc = "Invalid value for " + fieldName;
    if (validateTextMsgLine1.length > 0)
        msgDesc = Encoder.htmlDecode(validateTextMsgLine1.replace("xxxx",fieldName));

    alert(msgDesc + ".\n" + Encoder.htmlDecode(strMessage));
    //alert("Invalid value for " + fieldName + ".\n" + strMessage);
    if ( layerFunction ) layerFunction(layer);
    if ( field.select ) field.select();
    field.focus();
}

function isLong(strVal, bAllowZero)
{
	str = new String(strVal);

	len = str.length;

	if (len == 0)
		return false;

	for (i = 0; i < len; i ++)
	{
		c = str.charAt(i);
		if ((c < '0' || c > '9') && c != ',')
			return false;
	}

	if (isLong.length > 1 && bAllowZero == false && strVal == 0)
		return false;

	return true;
}

function isCurrency(strVal, bAllowZero)
{
	str = new String(strVal);

	len = str.length;

	if (len == 0)
		return false;

	decimalCount = 0;
	dollarCount = 0;
	bNonZero = false;

	for (i = 0; i < len; i ++)
	{
		c = str.charAt(i);
		if (c == '.')
		{
			if (decimalCount ++ > 0)
				return false;
		}
		else if ((c < '0' || c > '9') && c != ',')
		{
			if (c != '$' || i > 0)
				return false;
		}
		else if (c >'0')
			bNonZero = true;
	}

	if (isNumber.length > 1 && bAllowZero == false && bNonZero == false)
		return false;

	return true;
}

function isNumber(strVal, bAllowZero)
{
	str = new String(strVal);

	len = str.length;

	if (len == 0)
		return false;

	decimalCount = 0;

	for (i = 0; i < len; i ++)
	{
		c = str.charAt(i);
		if (c == '.')
		{
			if (decimalCount ++ > 0)
				return false;
		}
		else if ((c < '0' || c > '9') && c != ',')
			return false;
	}

	if (isNumber.length > 1 && bAllowZero == false && strVal == 0)
		return false;

	return true;
}


function isEmpty(obj)
{
    if (obj) {

        str = new String(obj.value);
        len = str.length;

        for (i = 0; i < len; i ++)
        {
            if (str.charAt(i) != ' ')
                return false;
        }
    } else {
        return false;
    }

    return true;
}

function formatButton(id,label) {
    document.write("<input type=\"button\" name=\"" + id + "\" id=\"" + id + "\" value=\"" + label + "\" class=\"pbutton pbuttonOff\"" +
				"onmouseover=\"this.className='pbutton pbuttonOn'\" onmouseout=\"this.className='pbutton pbuttonOff'\">");
    setOnClick(id,eval(id));
}

function formatButtonStd(id,label) {
    document.write("<input type=\"button\" name=\"" + id + "\" id=\"" + id + "\" value=\"" + label + "\" class=\"pbutton pbuttonOff\"" +
				"onmouseover=\"this.className='pbutton pbuttonOn'\" onmouseout=\"this.className='pbutton pbuttonOff'\">");
}

function formatButtonStdOrange(id,label) {
    document.write("<input type=\"button\" name=\"" + id + "\" id=\"" + id + "\" value=\"" + label + "\" class=\"pbuttonorange pbuttonOff\"" +
				"onmouseover=\"this.className='pbuttonorange pbuttonOn'\" onmouseout=\"this.className='pbuttonorange pbuttonOff'\">");
}

function formatInputCurrency(txtbox)
{
    txtbox.value = formatCurrency(txtbox.value,2,false);
}

function formatCurrency(number, decimals, bIgnoreCommas)
{
    //if (parseDouble(number) == "")
    //    number = "0";
    if (parseCurrency(number,currencyDecimalSep,currencyThousandSep) == "")
        number = "0";

    /*
    if (currency.length > 1)
        return currency + ' ' + formatGenericNumber(parseDouble(number), decimals, bIgnoreCommas);
    else
        return currency + formatGenericNumber(parseDouble(number), decimals, bIgnoreCommas);
    */

    if (currency.length > 1)
        return currency + ' ' + formatGenericNumber(parseCurrency(number,currencyDecimalSep,currencyThousandSep), decimals, bIgnoreCommas,currencyDecimalSep,currencyThousandSep);
    else
        return currency + formatGenericNumber(parseCurrency(number,currencyDecimalSep,currencyThousandSep), decimals, bIgnoreCommas,currencyDecimalSep,currencyThousandSep);
}

function formatGenericNumber(number, decimals, bIgnoreCommas,decimalSep,thousandSep) {

    if ( number.length - number.indexOf(".") > decimals && number.indexOf(".") > -1 ) {
        num = parseFloat(number);
        num2 = num * Math.pow(10, decimals);
        num3 = Math.round(num2);
        num4 = num3 / Math.pow(10, decimals);

        number = "" + num4
    }

    output = new String ("");
    len = number.length;
    period = number.indexOf(".");

    if (period == 0) {
        output = "0";
    } else {

//form the pre period

        pos = period > - 1 ? period - 1: len - 1;
        comma = 0;

        while (pos > - 1) {
            c = number.charAt(pos);

            if (c >= '0' && c <='9') {

                if (comma == 3 && ! bIgnoreCommas){
                    //output = ',' + output;
                    output = thousandSep + output;
                    comma = 0;
                }

                output = c + output;
                comma ++;
            }

            pos --;
        }
    }

    //output += ".";
    output += decimalSep;

    if (period == - 1) {
        for ( x=0; x<decimals; x++ ) output += "0";
    } else {
        precision = 0;

        for (ui = period + 1; ui < len && precision < decimals; ui ++) {
            output += number.charAt(ui);
            precision ++;
        }

        while (precision ++ < decimals)
            output += "0";
    }

    if (number.indexOf("-") > - 1) output = "-" + output;

    return output;
}

function formatMoney(currency)
{
	output = new String ("");

	len = currency.length;

	period = currency.indexOf(".");

	if (period == 0)
	{
		output = "0";
	}
	else
	{

		//form the pre period
		pos = period > - 1 ? period - 1: len - 1;
		comma = 0;

		while (pos > - 1)
		{
			c = currency.charAt(pos);
			if (c >= '0' && c <='9')
			{
				if (comma == 3)
				{
					output = ',' + output;
					comma = 0;
				}
				output = c + output;
				comma ++;
			}

			pos --;
		}
	}

	output += ".";

	if (period == - 1)
	{
		output += "00";
	}
	else
	{
		precision = 0;
		for (i = period + 1; i < len && precision < 2; i ++)
		{
			output += currency.charAt(i);
			precision ++;
		}
		while (precision ++ < 2)
			output += '0';
	}

	if (currency.indexOf("-") > - 1)
		output = "-" + output;

	return output;
}


function formatNumber(value)
{
	output = new String ("");

	len = value.length;

	period = value.indexOf(".");

	if (period == 0)
	{
		output = "0";
	}
	else
	{

		//form the pre period
		pos = period > - 1 ? period - 1: len - 1;
		comma = 0;

		while (pos > - 1)
		{
			c = value.charAt(pos);
			if (c >= '0' && c <='9')
			{
				if (comma == 3)
				{
					output = ',' + output;
					comma = 0;
				}
				output = c + output;
				comma ++;
			}

			pos --;
		}
	}

	if (period == - 1)
	{
		//output += "00";
	}
	else
	{

		output += ".";

		precision = 0;
		for (i = period + 1; i < len && precision < 2; i ++)
		{
			output += value.charAt(i);
			precision ++;
		}
		while (precision ++ < 2)
			output += '0';
	}

	if (value.indexOf("-") > - 1)
		output = "-" + output;

	return output;
}


function makeNumber(value)
{
	output = new String ("");

	len = value.length;

	period = value.indexOf(".");

	if (period == 0)
	{
		output = "0";
	}
	else
	{

		//form the pre period
		pos = period > - 1 ? period - 1: len - 1;
		//comma = 0;

		while (pos > - 1)
		{
			c = value.charAt(pos);
			if (c >= '0' && c <='9')
			{
				//if (comma == 3)
				//{
				//	output = ',' + output;
				//	comma = 0;
				//}
				output = c + output;
				//comma ++;
			}

			pos --;
		}
	}

	if (period == - 1)
	{
		//output += "00";
	}
	else
	{

		output += ".";

		precision = 0;
		for (i = period + 1; i < len && precision < 2; i ++)
		{
			output += value.charAt(i);
			precision ++;
		}
		while (precision ++ < 2)
			output += '0';
	}

	if (value.indexOf("-") > - 1)
		output = "-" + output;

	if (output.length == 0)
	{
		output = "0";
	}

	return output;

}

    //parseDouble
	//returns a double value without the comma's, dollar sign, pct, etc.
function parseDouble(strVal)
{
    if (null == strVal)
    {
        return  "";
    }

    var strTemp = new String(strVal);
    var strReturn = "";

    for (i = 0; i < strTemp.length; i ++)
    {
        var c = strTemp.charAt(i);

        if ((c >= '0' && c <= '9') || c == '.' || ((i == 0 || i == 1) && c == '-'))
        {
            strReturn += c;
        }
    }

    return strReturn;

}

    //parseCurrency
	//returns a double value without the comma's, dollar sign, pct, etc.
function parseCurrency(strVal,decimalSep,thousandSep)
{
    if (null == strVal)
    {
        return  "";
    }

    var strTemp = new String(strVal);
    var strReturn = "";

    strTemp = strTemp.replace(thousandSep,'');
    strTemp = strTemp.replace(decimalSep,'.');

    for (i = 0; i < strTemp.length; i ++)
    {
        var c = strTemp.charAt(i);

        if ((c >= '0' && c <= '9') || c == '.' || ((i == 0 || i == 1) && c == '-'))
        {
            strReturn += c;
        }
    }

    return strReturn;

}

function setCurrency(curr)
{
    currency = curr;
}

function setCurrencyDecimalSep(c)
{
    currencyDecimalSep = c;
}

function setCurrencyThousandSep(c)
{
    currencyThousandSep = c;
}

function setOnClick(buttonid,func)
{
    if (document.getElementById(buttonid))
        document.getElementById(buttonid).onclick = func;
}

//called from input select boxes with "other.." selection
function dispOther(toggle,obj1,obj2)
{
    //obj2 = eval("document.Form." + obj2);
    obj2 = document.getElementById(obj2);

    if (toggle == 2)
    {
        if (obj1.value == "OTHER")
        {
            document.getElementById(obj2.name).style.visibility = "visible";
            document.getElementById(obj1.name).style.visibility = "hidden";
            obj2.focus();
        }
    }
    else if (toggle == 1)
    {
        if (obj1.value != "")
        {
            obj2.options[obj2.length-1] = null
            obj2.options[obj2.length] = new Option(obj1.value,obj1.value);
            obj2.options[obj2.length] = new Option("Other...","OTHER");
            obj2.selectedIndex = obj2.length-2;
        }
        else
        {
            obj2.selectedIndex = 0;
        }

        document.getElementById(obj1.name).style.visibility = "hidden";
        document.getElementById(obj2.name).style.visibility = "visible";
    }
}

//called from input select boxes with "other.." selection
function initDispOther(obj)
{
    document.getElementById(obj).style.position = "absolute";
    document.getElementById("_"+obj).style.visibility = "hidden";
    document.getElementById("_"+obj).style.position = "relative";
}


function cleanPhone(phone) {
    var str= "";
    if (phone.length > 0) {
        for (i=0;i<phone.length;i++ ) {
            if ( !isNaN(phone.charAt(i))) {
                str += phone.charAt(i);
            }
        }
    }
    return str;
}

function newWindow(urlPage,wName)
{
  plain_window = window.open(urlPage,wName,"width=310,height=350,scrollbars=no");
	  if (plain_window.opener == null) plain_window.opener= window;
	  plain_window.opener.name = "w_opener";
}

function newUploadWindow(urlPage,wName)
{
  plain_window = window.open(urlPage,wName,"width=500,height=450,scrollbars=no");
	  if (plain_window.opener == null) plain_window.opener= window;
	  plain_window.opener.name = "w_opener";
}

function newFullWindow(urlPage,wName) {
    window.open(urlPage,wName,'width=900,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
}

function openImageWin(currentImage)
{
    var picture = new Image();
    picture.src = currentImage;
    hgt = picture.height;
    wdth = picture.width;
    //hgt = 311;
    //wdth = 402;
    aWindow = window.open(currentImage,
                          "Auctions",
                          "toolbar=no,status=no,alwaysRaised=yes,height=" + hgt + ",width=" + wdth
                          + ",scrollbars=no,resize=no,menubar=no");
}

function validateCurrency(field, fieldName, bAllowZero)
{

    if (false == bAllowZero && (null == field || null == field.value || true == isEmpty(field)))
    {
        alertInvalidField(field, fieldName, zeroNotAllowedText);
        return false;
    }

    //var strVal = parseDouble(field.value);
    var strVal = parseCurrency(field.value,currencyDecimalSep,currencyThousandSep);

    //strip the commas
//    var strTemp = field.value;
//    var strVal = "";
//    for (i = 0; i < strTemp.length; i ++)
//    {
//     var c = strTemp.charAt(i);
//     if (c != ',')
//     {
//        strVal += c;
//     }
//    }

    if (true == isNaN(strVal))
    {
        alertInvalidField(field, fieldName, "Currency value required");
        return false;
    }

    n = new Number(strVal);

    //check for zero
    if (0 == n)
    {
        if (true == bAllowZero)
        {
            return true;
        }
        else
        {
            alertInvalidField(field, fieldName, zeroNotAllowedText);
            return false;
        }
    }

    return true;
}


function validateDate(field, fieldName, bTimeIncluded, layer, layerFunction) {

    var strValue = field.value;
    var dtTestDate = Date.parse(strValue)

    if ( isEmpty(field) ) {
        alertInvalidField(field, fieldName, "Missing date.", layer, layerFunction);
        return false;
    }

    if ( isNaN(dtTestDate) ) {
        alertInvalidField(field, fieldName, "Invalid date.", layer, layerFunction);
        return false;
    }

    dtDate = new Date(dtTestDate);
    dtNow = new Date();

    if ( ( (dtDate.getFullYear() < (dtNow.getFullYear() + 30)) && (dtDate.getFullYear() > (dtNow.getFullYear() - 30))) ||
            (dtDate.getFullYear() <= (dtNow.getFullYear() - 70))) {

        if (dtDate.getFullYear() <= (dtNow.getFullYear() - 70)) {
            dtDate.setYear(dtDate.getFullYear()+100);
        }

        if ( bTimeIncluded ) {

            alert(ampm(dtDate));
            var time = ampm(dtDate);

            if ( time.length == 0 ) {
                alertInvalidField(field, fieldName, "Invalid time.", layer, layerFunction);
                return false;
            }
        }

        field.value = formatDate(dtDate, bTimeIncluded);

    } else {

        alertInvalidField(field, fieldName, "Invalid year.", layer, layerFunction);
        return false;
    }

    return true;
}


function validateNumber(field, fieldName) {

    if ( field == null || field.value == null || isEmpty(field) ) {
        return true;
    }

    strVal = field.value;

    if ( isNaN(strVal) ) {
        alert("Number value is expected for " + fieldName + ".\n");
        field.focus();
        return false;
    }
}

function validateDouble(field, fieldName, bAllowZero, layer, layerFunction) {

    if ( field == null || field.value == null || isEmpty(field) ) {
        alertInvalidField(field, fieldName, "Field is empty.", layer, layerFunction);
        return false;
    }

    n = new Number(field.value);

//check for zero

    if ( n == 0 ) {
        if (bAllowZero) return true;
        alertInvalidField(field, fieldName, zeroNotAllowedText, layer, layerFunction);
        return false;
    }

    strVal = field.value;

    if ( isNaN(strVal) ) {
        alertInvalidField(field, fieldName, "Double value required.", layer, layerFunction);
        return false;
    }

    return true;
}


function validateEmail(field, fieldName, layer, layerFunction) {

    if ( isEmpty(field) )
    {
        alertInvalidField(field, fieldName, "Cannot be blank.", layer, layerFunction);
        return false;
    }
        else if (field.value.indexOf("@") == -1 ||
         field.value.indexOf("@") == 0 ||
         field.value.indexOf(".") == -1)
    {
        alertInvalidField(field, fieldName, "", layer, layerFunction);
        return false;
    }

    return true;
}


function validateLong(field, fieldName, bAllowZero, layer, layerFunction) {

    if ( field == null || field.value == null || isEmpty(field) ) {
        alertInvalidField(field, fieldName, "Field is empty.", layer, layerFunction);
        return false;
    }

    n = new Number(field.value);

//check for zero

    if ( n == 0 ) {
        if (bAllowZero) return true;
        alertInvalidField(field, fieldName, zeroNotAllowedText, layer, layerFunction);
        return false;
    }

    strVal = field.value;

    if ( isNaN(strVal) ) {
        alertInvalidField(field, fieldName, "Long value required.", layer, layerFunction);
        return false;
    }

    strVal = field.value;

//look for a decimal

    for ( ui=0; ui<strVal.length; ui++ ) {
        c = strVal.charAt(ui);

        if ( c == '.' ) {
            alertInvalidField(field, fieldName, "Whole number required.", layer, layerFunction);
            return false;
        }
    }

    return true;
}

function validatePhone(field, fieldName, bAllowBlank, layer, layerFunction) {

// If blanks allowed and blank, return nothing.

    if ( bAllowBlank && isEmpty(field) ) return true;

    phone = field.value;
    opPos = phone.indexOf("(");
    cpPos = phone.indexOf(")");
    dashPos = phone.indexOf("-");
    spacePos = phone.indexOf(" ");

// Leave if the phone is formatted properly.

    if ( opPos == 0 && cpPos == 4 && spacePos == 5 && dashPos == 9 &&
         isNumber(phone.substr(1,3) + phone.substr(6, 3) + phone.substr(11), false) ) return true;

// If the length is less than 10 then it must be invalid.

    if ( phone.length < 10 ) {
        alertInvalidField(field, fieldName, "Invalid format.", layer, layerFunction);
        return false;
    }

// Get last 4 digits & validate.

    wrkPhone = new String("");

    last4 = phone.substr(phone.length-4);
    if ( ! isNumber(last4, false) ) {
        alertInvalidField(field, fieldName, "Invalid format.", layer, layerFunction);
        return false;
    }
    wrkPhone = "-" + last4;

// Get the suffix & validate.

    wrkPos = 0;
    suffix = (isNumber(phone.substr(phone.length-5), 1)) ?
                phone.substr( (wrkPos = phone.length-7), 3) :
                phone.substr( (wrkPos = phone.length-8), 3);
    if ( ! isNumber(suffix, false) ) {
        alertInvalidField(field, fieldName, "Invalid format.", layer, layerFunction);
        return false;
    }
    wrkPhone = suffix + wrkPhone;

// Get area code, remove all non-numbers, validate, & format.

    ac = phone.substring(0, wrkPos);
    wrkAC = new String("");
    for ( ui=0; ui<ac.length; ui++ )
        if ( ac.charAt(ui) >= "0" && ac.charAt(ui) <= "9" ) wrkAC += ac.charAt(ui);
    if ( ! isNumber(wrkAC, false) || wrkAC.length != 3 ) {
        alertInvalidField(field, fieldName, "Invalid format.", layer, layerFunction);
        return false;
    }
    wrkPhone = "(" + wrkAC + ") " + wrkPhone;

    field.value = wrkPhone;
    return true;
}

function validateText(field, fieldName, layer, layerFunction) {

    if ( isEmpty(field) ) {

        if (validateTextMsgLine2.length == 0)
            validateTextMsgLine2 = "Cannot be blank."

        alertInvalidField(field, fieldName, validateTextMsgLine2, layer, layerFunction);
        return false;
    }

    return true;
}
/*
function validateEmail(field, fieldName, layer, layerFunction) {

    if ( isEmpty(field) ) {
        alertInvalidField(field, fieldName, "Cannot be blank.", layer, layerFunction);
        return false;
    }

    if (field.value=="" ||
        field.value.indexOf("@") == -1 ||
        field.value.indexOf("@") == 0 ||
        field.value.indexOf(".") == -1) {
        alert("Please enter a valid Email Address");
        field.focus()
        return false;
    }

    return true;
}
*/


function adsWindow(id)
{
    var w=750;
    if (!isBrowserIE()) w=472;
    plain_window = window.open('/main/support/readads.jsp?AdsID='+id,'news','location=no,status=no,width='+w+',height=522,scrollbars=yes');
    if (plain_window.opener == null) plain_window.opener= window;
    plain_window.opener.name = "w_opener";
}


function onRowHighlight(bOn,row)
{
    obj = row;

//    if ( (bOn == true) && (row != currow) )
//    {
//        obj.className = "allrowsOn";
//    }
//    else if ( (bOn == false) && (row != currow) )
//    {
//        obj.className = "allrows";
//    }

    if (bOn == true)
    {
        obj.className = "allrowsOn";
    }
    else if (bOn == false)
    {
        obj.className = "allrows";
    }
}

function gotoPageAjax(divId,url,param) {
    //  ajax_loadContent('mainContent',url + '?' + param);
    document.getElementById(divId).innerHTML = '<table class="loader" width="100%"><tr><td><img src="/main/includes/images/loading.gif" alt="Loading..."></td></tr></table>';
//alert("here1");
    new Ajax.Updater(
        divId,
        url,
        {   asynchronous: true,
            evalScripts: true,
            parameters: param
        });
}

function gotoPageAjax2(divId,url,param,page) {
//    alert(param);
    pagi.to(page, param)
}

function gotoPageAjaxForm(divId,url,form) {

//    document.getElementById(divId).innerHTML = '<table class="loader" width="100%"><tr><td><img src="/main/includes/images/loading.gif" alt="Loading..."></td></tr></table>';

    var param = Form.serialize(form);
    
    new Ajax.Updater(
        divId,
        url,
        {   asynchronous: true,
            evalScripts: true,
            parameters: param
        });
}

function gotoPageAjaxFormSave(divId,url,form) {
//alert("div[" + divId + "]....url[" + url + "]....form[" + form + "]");

    if (savingText.length > 0)
        document.getElementById(divId).innerHTML = '<table width="50%"><tr><td class="cellRedLabel">' + savingText + '</td></tr></table>';
    else
        document.getElementById(divId).innerHTML = '<table class="save" width="100%"><tr><td>&nbsp;</td></tr></table>';

    
    var param = Form.serialize(form);

    new Ajax.Updater(
        divId,
        url,
        {   asynchronous: true,
            evalScripts: true,
            parameters: param
        });

}


function gotoPage(url,param) {
    if (param != "")
        location.href = url + "?" + param;
    else
        location.href = url;
}

//tab display function
function ot_show(layerName) {
    document.getElementById(layerName).style.display = '';
}
//tab display function
function ot_hide(layerName) {
    document.getElementById(layerName).style.display = 'none';
}
//tab display function
function ot_show_next(tab_name) {
    document.getElementById(ot_last_tab).className = 'otab';
    document.getElementById(tab_name).className='otab_hover';
    ot_hide(ot_last_tab+'_data');
    ot_show(tab_name+'_data');
    ot_last_tab=tab_name;
}

function resizeFrame() {
    //do nothing
}


function showOrHideAllDropDowns(catId, newState) {

    //var elements = document.documentElement.getElementsByTagName('select');
    //for (var i=0; i<elements.length; i++) {
    //    elements[i].style.visibility = newState;
    //}

    var f;

    if (catId == 101 || catId == 102) {
        f = document.GenSearch;
    } else if (catId == 104) {
        f = document.Offers;
    }
    
    if (f) {
        var elements = f.getElementsByTagName('select');
        for (var i=0; i<elements.length; i++) {
            elements[i].style.visibility = newState;
        }
    }
}

function hideDropDowns(catId) {

    showOrHideAllDropDowns(catId,'hidden');

}

function showDropDowns(catId) {

    showOrHideAllDropDowns(catId,'visible');

}

function getCategories(divId,pid) {
    
    gotoPageAjax(divId,"/main/SundryServlet","Action=getcategories&ParentID="+pid);
}

function getMultipleSelectValues(sel) {
    var cval = "";
    if (sel) {
        for (var i=0; i<sel.length; i++) {
            if (sel.options[i].selected) {
                if (cval.length == 0)
                    cval = sel.options[i].value;
                else
                    cval += "," + sel.options[i].value;
            }
        }
    }
    return cval;
}

function replaceAll(text, strA, strB)
{
    while ( text.indexOf(strA) != -1)
    {
        text = text.replace(strA,strB);
    }
    return text;
}


function alertmsg(msg) {
    alert(msg.unescapeHTML());
}


function isBrowserIE() {

    if (navigator.userAgent.indexOf("MSIE") > 0)
        return true;
    else
        return false;
}
