var from="";
var lang = "";
function clearNoNum(obj) {
    var thisValue = obj.value;
    thisValue = thisValue.replace(/[^\d.]/g, "");
    thisValue = thisValue.replace(/^\./g, "");
    thisValue = thisValue.replace(/\.{2,}/g, ".");
    thisValue = thisValue.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");

    if (thisValue != obj.value) {
        obj.value = thisValue;
    }
}
function clearNoNumComma(obj) {
    obj.value = obj.value.replace(/[^\d.,]/g, "");
    obj.value = obj.value.replace(/^\.,/g, "");
    obj.value = obj.value.replace(/\.{2,}/g, ".");
    obj.value = obj.value.replace(".,", "$#$").replace(/\.,/g, "").replace("$#$", ".,");
}
function MoneyFormat(obj) {
    obj.value = obj.value.replace(/[^\d\,]/g, '');
}   
function trim(s) {
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}

function ClareDefaultText(taget) {
    var defaultText = taget.getAttribute("defaultText");
    if (trim(taget.value) == defaultText) {
        taget.value = "";
    }
}

function SetDefaultText(taget) {
    var defaultText = taget.getAttribute("defaultText");
    if (trim(taget.value) == "") {
        taget.value = defaultText;
    }
}

function checkFormatEmail(name) {
    var target = $("#" + name);
    return trim(target.val()) != "";
}

function isShow() {
	$('#readmeDiv').slideDown('slow');
}

function hide() {
	var that=$('#readmeDiv');
	that.slideUp('slow');
}

function HideShow()
{
	var that=$('#tag');
	that.slideUp('slow');
}

function OnBlurEvent()
{
	$(':input').not($(':submit')).not($(':button')).each(function(){
		$(this)
			.bind('focus',function(){
				$(this).css({'background':'#FF9'});
			})
			.bind('blur',function(){
				$(this).css({'background':''});
			});
		if($(this).attr('type')=='text')
		{
		    $(this).addClass('global-textboxHeight');
		}
	});
}
function CloseLayer(arg) 
{
	if (arg) {
		$('#ctl00_ContentPlaceHolder1_rblPaymentInfo_' + arg).attr('checked', true).click();
	}
	self.parent.tb_remove('yes');
}

function LanguageFn()
{
    var that = $('#ctl00_ContentPlaceHolder1_rblYN_1');
	//if (lang=='fr')
	//{
	//	that.attr({'class':'thickbox','href':'#TB_inline?height=150&width=260&inlineId=french&modal=true'});
	//}
	//else if(from=='direct')
    if (from == 'direct')
	{
		that.attr({'class':'thickbox','href':'#TB_inline?height=135&width=265&inlineId=direct&modal=true'});
	}
    //else if(from=='retail')
    if (from == 'retail')
	{
		that.attr({'class':'thickbox','href':'#TB_inline?height=100&width=235&inlineId=retail&modal=true'});
	}
}
function jump() {
    window.location = "Landing.aspx";
}
function inputHeight() {
    $(':input').not($(':submit')).not($(':button')).each(function() {    
        if ($(this).attr('type') == 'text') {
            $(this).addClass('global-textboxHeight');
        }
    });
}

function UpdateProgressBoxPosition() {
    $("#UpdateProgressBox").css({ marginLeft: '-' + parseInt((208 / 2), 10) + 'px', width: 208 + 'px' });
    if (!(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
        $("#TB_window").css({ marginTop: '-' + parseInt((13 / 2), 10) + 'px' });
    }
}

function validTextAreaLen(target, indicatorID) {
    /*
    if (indicatorID) {
    var indicator = document.getElementById(indicatorID);
    indicator.innerHTML = target.value.length;
    }
    */
    //if (!indicatorID) return;

    var maxlen = Number(target.getAttribute("maxlen"));

    if (target.value.length > maxlen) {
        target.value = target.value.substr(0, maxlen);
        refreshTargetLength(target, indicatorID);

        if (jQuery.browser.mozilla) {
            var evt = arguments.callee.caller.arguments[0];
            var iKeyCode = evt.which;

            if (iKeyCode == 0 || iKeyCode == 8) {
                return true;
            }
        }
        return false;
    }
    else {
        refreshTargetLength(target, indicatorID);
        return false;

    }
}

function refreshTargetLength(target, indicatorID) {
    if (indicatorID) {
        var indicator = document.getElementById(indicatorID);
        indicator.innerHTML = target.value.length;
    }
}

