


function focusPage(strField)
{
	eval('document.'+ strField +'.focus()')
}

function validDate(lngYear, lngMonth, lngDay) {
	var aryMonthNormal	= new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	var aryMonthLeap	= new Array(31,29,31,30,31,30,31,31,30,31,30,31);

	var blnIsValid		= true;

	if (lngYear % 4 == 0 && (lngYear % 100 != 0 || lngYear % 400 == 0)) {
		if (lngDay < 1 || lngDay > aryMonthLeap[lngMonth - 1]) { blnIsValid = false; }
	} else {
		if (lngDay < 1 || lngDay > aryMonthNormal[lngMonth - 1]) { blnIsValid = false; }
	}

	if (blnIsValid) {
		var dteNow	= new Date();
		var dteToday	= new Date(dteNow.getYear(), dteNow.getMonth(), dteNow.getDate());
		var dteParam	= new Date(lngYear, lngMonth - 1, lngDay);

		if (dteToday > dteParam) { blnIsValid = false; }
	}

	return blnIsValid;
}

var whitespace = " tnr";

function isWhitespace (s) {
	var i;
		for (i = 0; i < s.length; i++)
		{
				var c = s.charAt(i);
				if (whitespace.indexOf(c) == -1) return false;
		}
		return true;
}

function isEmail (strEmail) {
	var re = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
	if (!re.test(strEmail)) {
		return true;
	} else {
		return false;
	}
}

function fnReplaceChars(strString, strReplace, strWith) {
	temp = '' + strString;

	while (temp.indexOf(strReplace)>-1) {
		pos = temp.indexOf(strReplace);
		temp = '' + (temp.substring(0, pos) + strWith + temp.substring((pos + strReplace.length), temp.length));
	}
	return temp;
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function fnIsDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	
	if (pos1==-1 || pos2==-1){
		return "Please enter a valid date. The date format should be : dd/mm/yyyy"
	}
	if (strMonth.length<1 || month<1 || month>12){
		return "Please enter a valid month in the date"
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return "Please enter a valid day in the date"
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return "Please enter a valid 4 digit year in the date between "+minYear+" and "+maxYear
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return "Please enter a valid date"
	}
	return ""
}

function fnIsValidTime(timeStr, strDescription) {
	// Checks if time is in HH:MM:SS AM/PM format.
	// The seconds and AM/PM are optional.

	var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

	var matchArray = timeStr.match(timePat);
	if (matchArray == null) {
		return "Please enter a valid format for the " + strDescription + ".";
	}
	hour = matchArray[1];
	minute = matchArray[2];
	second = matchArray[4];
	ampm = matchArray[6];

	if (second=="") { second = null; }
	if (ampm=="") { ampm = null }

	if (hour < 0  || hour > 23) {
		return "The hour in the " + strDescription + " must be between 0 and 23";
	}

	if  (hour > 12 && ampm != null) {
		return "You can't specify AM or PM for military time.";
	}
	if (minute<0 || minute > 59) {
		return "The minute in the " + strDescription + " must be between 0 and 59.";
	}
	if (second != null && (second < 0 || second > 59)) {
		return "The second in the " + strDescription + " must be between 0 and 59.";
	}
return ""
}

function fnChecked(objCheckbox, lngNo) {
	var lngCheckCount = 0;
	for (var i = 0; i < lngNo; i++) {
		if (eval(objCheckbox + i + '.checked')) {
			lngCheckCount++;
		}
	}
	if (lngCheckCount > 0) {
		return true;
	} else {
		return false;
	}
}

function fnHighlightDataLabel(strCell, strClassType) {


	var objCell = document.getElementById('cell' + strCell);
	objCell.className = 'DataLabel' + strClassType;
}


function fnFormatCurrency(num) 
{
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		decs = num%100;
		num = Math.floor(num/100).toString();
	if(decs<10)
	decs = "0" + decs;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + decs);
}



function fnNumbersOnly(myfield, e, decAllowed)
{
	var key;
	var keychar;
	if (window.event)
				key = window.event.keyCode;
	else if (e)
				key = e.which;
	else
	return true;
	keychar = String.fromCharCode(key);


	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
		return true;

		// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
		return true;

	// decimal point jump
	else if (decAllowed==true && (keychar == "."))
	{
		return true;
				//myfield.form.elements[dec].focus();
		//return false;
	}
		else
	return false;
}



function mOvr(src,clrOver){
	// non-Netscape
	if (!src.contains(event.fromElement)){
	
		src.style.cursor = 'hand';
		src.bgColor = clrOver;
		
	}
}
function mOut(src,clrIn){
	if (!src.contains(event.toElement)){
		src.style.cursor = 'default';
		src.bgColor = clrIn;
	
	
	}
}
function mClk(src){
	if(event.srcElement.tagName=='td')
	alert("here");
		src.children.tags('A')[0].click();
}

			
function launchUPSTracking(strCode) {
	var popup = window.open('http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1=' + strCode + '&track.x=0&track.y=0', 'popupUPS','width=900,height=600,left='+(window.screen.availWidth-900)/2+', top='+(window.screen.availHeight-600)/2+',scrollbars=1');
}
			
function launchJonathanKelsey() {
	var popup = window.open('/shoes/', 'popupJK','width=788,height=584,left='+(window.screen.availWidth-788)/2+', top='+(window.screen.availHeight-584)/2+',scrollbars=0');
}

function fnSetCountrySite() {
	document.location = "/setCountrySite.asp?countryCode=" + document.getElementById("cmoCountryCode").value;
}

function fnPromo(strLoc) {
	fnOmnitureTrackLink(this, "", "PromoIconClick", "Promo Icon: Click")
	document.location = strLoc
}

function fnGetUserFriendlyFieldName(strFieldName) {
	switch (strFieldName) {
		case 'Address1':
			return 'Address';
			break;
		case 'Address2':
			return 'Address';
			break;
		case 'DayPhone':
			return 'Daytime Telephone';
			break;
		case 'EvePhone':
			return 'Evening Telephone';
			break;
		default:
			return strFieldName;
	}
}

