function SetValue(obj,checkvalue){	
	if (obj.value == ""){
		obj.value = checkvalue;
    }
}	
function ClearValue(obj,checkvalue){
	if (obj.value == checkvalue){
		obj.value="";
	}
}
function TabNext(obj,len,next_field){
	if (obj.value.length == len){
		next_field.focus();
	}
}
function checkDOB(sender, args){
	var temp = sender.id.split('_');
	var prefix = "";
	for(var i=0; i<temp.length-1;++i){
		prefix += temp[i] + "_";
	}
	args.IsValid = false;
	var month = document.getElementById(prefix+'txbDOBMonth').value;
	var day = document.getElementById(prefix+'txbDOBDay').value;
	var year = document.getElementById(prefix+'txbDOBYear').value;
	
	tempRegExp = new RegExp("[^0-9]");
	if (!tempRegExp.test(month) && !tempRegExp.test(day) && !tempRegExp.test(year)){
		if(month>0 && month<13 && day>0 && year>999){
			var maxDays = daysInMonth(month, year);
			if(day<=maxDays){
				args.IsValid = true;
			}
		}
	}
}
function daysInMonth(month, year){
	if (month == 1) return 31;
	if (month == 2){
		if ((year % 4) == 0)
			return 29;
		else
			return 28;
	}
	if (month == 3) return 31;
	if (month == 4) return 30;
	if (month == 5) return 31;
	if (month == 6) return 30;
	if (month == 7) return 31;
	if (month == 8) return 31;
	if (month == 9) return 30;
	if (month == 10) return 31;
	if (month == 11) return 30;
	if (month == 12) return 31;
	return 0;
}
function isValidCharacter(s){
	var tempRegExp;
	tempRegExp = new RegExp("^\u007E|\u00D1|\u00F1|\u00B4|\u00C1|\u00C9|\u00CD|\u00D3|\u00DA|\u00DD|\u00E1|\u00E9|\u00ED|\u00F3|\u00FA|\u00FD");
	if (tempRegExp.test(s)){
		return false;
	}
	return true;
}
function trackRetrieve(btn){
    var validationGroup = btn.id.substring(0,btn.id.lastIndexOf('_'));
    var groupId = validationGroup.substring(validationGroup.lastIndexOf('_')+1);
    if(!Page_ClientValidate(validationGroup)){
        return false;
    }
    if(typeof pageTracker == "object"){
        var category = "RetrieveQuote";
        var eventName = "";
        var selectElems = document.getElementsByTagName("select");
        var ddProductList = null;
        //Need this section to get exact selection group on page
        //Complicated DOM parsing to solve automatic ASP.Net ID insertion problems
        for(var i=0;i<selectElems.length;i++){
            if(!selectElems[i].id) continue;
            var sections = selectElems[i].id.split("_");
            var found = false;
            for(var j=0;j<sections.length;j++){
                if(sections[j] === groupId){    //Group ID should be part of the list's ID
                    found = true;
                    ddProductList = selectElems[i];
                    break;
                }
            }    
            if(found) break;        
        }
        if(ddProductList == null) return;
	    var selectedItemValue = ddProductList.value.toUpperCase();
	    switch(selectedItemValue){
	        case "AU":
			    eventName = "Auto";
			    break;
		    case "H":
			    eventName = "Homeowners";
			    break;
		    case "C":
			    eventName = "Condo";
			    break;
		    case "R":
			    eventName = "Renter"
			    break;
		    case "CA":
			    eventName = "Commercial-Auto";
			    break;
		    case "MC":
			    eventName = "Motorcycle";
			    break;
		    case "BT":
			    eventName = "Boat";
			    break;
		    case "TT":
			    eventName = "Travel-Trailer";
			    break;
		    case "MT":
			    eventName = "Motor-Home";
			    break;
		    case "SM":
			    eventName = "Snowmobile";
			    break;
		    case "RV":
			    eventName = "RV";
			    break;
			case "SW":
			    eventName = "Segway";
			    break;			
	    }
	    pageTracker._trackEvent(category,eventName,location.href);
    }
}