// Start moreinfowindow script
//
function moreinfowindow(url,h,w,t,l,n) {
	if (h==undefined) { h=400 }
	if (w==undefined) { w=500 }
	if (t==undefined) { t=50 }
	if (l==undefined) { l=50 }
	if (n==undefined) { n='moreinfo'}
	var options = 'height=' + h + ',width=' + w + ',top=' + t + ',left=' + l + ',status=no,resizable=yes,scrollbars=yes';
	window.open(url, n , options);
}
//
// End moreinfowindow script

// Start moreinfowindowfull script
//
function moreinfowindowfull(url,h,w,t,l,n) {
	if (h==undefined) { h=480 }
	if (w==undefined) { w=640 }
	if (t==undefined) { t=0 }
	if (l==undefined) { l=0 }
	if (n==undefined) { n='moreinfofull'}
	var options = 'height=' + h + ',width=' + w + ',top=' + t + ',left=' + l + ',status=yes,resizable=yes,scrollbars=yes,menubar=1,titlebar=1,toolbar=1';
	window.open(url, n , options);
}
//
// End moreinfowindowfull script

// Start moreinfowindow2 script - from old system for compatibility
//
function moreinfowindow2(url) {
	window.open(url, 'moreinfo', 'height=600, width=525, status=yes, resizable=yes, scrollbars=yes, top=50, left=50, menubar=1, titlebar=1, toolbar=1');
}
//
// End moreinfowindow2 script

// Start print page
//
function printpage() {
	if (window.print) {
		window.print();
	}
}
//
// End print page


// Start clear input value
//
function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}
//
// End clear input value

// Start - Check whether string s is empty.
//
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}
//
// End - Check whether string s is empty.

// Start Check if field is all whitespace
//
function isWhitespace (s) {
	// whitespace characters
	var whitespace = " \t\n\r";
	var i;
    // Is s empty?
    if (isEmpty(s)) return true;
    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    // All characters are whitespace.
    return true;
}
//
// End Check if field is all whitespace


// Start - Removes all characters which appear in string bag from string s.
//
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++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
//
// End - Removes all characters which appear in string bag from string s.


// Start - Removes all characters which do NOT appear in string bag from string s.
//
function stripCharsNotInBag (s, bag) {
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }
    return returnString;
}
//
// End - Removes all characters which do NOT appear in string bag from string s.

// Useage:
//  IsRadioChecked( <The name of the field and form>);
//	Script will return 1 or 0 depending on if it fails or sux
// <Example>
//	if (IsRadioChecked(document.MyForm.F_1)) {
//		alert('Something Sent')
//	} else {
//		alert('Nothing Sent')
//	}
// <End of Example>

function IsRadioChecked(theForm) {
	for (i=0, n=theForm.length; i<n; i++) {
		if (theForm[i].checked) {
			var checkvalue = theForm[i].value;
			break;
		}
	}
	if (!(checkvalue)) {
		return 0;
    }
	return 1;
}

function EmailCheck(theForm) {
//	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
//	if (theForm.match(illegalChars)) {
//		return 0;
//    }
	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(emailFilter.test(theForm))) {
		return 0;
	}
	return 1;
}

function DropDownCheck(theForm) {
    var error = "";
    if (theForm.selectedIndex == 0) {
		return 0;
	}
	return 1;
}

function TextCheck (theForm)
{
	var whitespace = " \t\n\r";
	var i;
    // Is s empty?
    if (isEmpty(theForm)) return 0;
    for (i = 0; i < theForm.value.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = theForm.value.charAt(i);
        if (whitespace.indexOf(c) == -1) return 1;
    }
    // Data Present
    return 0;
}

function ModelChange(x) {
	if (x == 1) {
		document.getElementById("changemodel").style.display="none";
		document.getElementById("changemodelbox").style.display="block";
	} else {
		document.getElementById("changemodelbox").style.display="none";
		document.getElementById("changemodel").style.display="block";
	}

}
function ChangeTitleRegion() {
	i = document.TITLEREGION.region_id.options[document.TITLEREGION.region_id.options.selectedIndex].value;
	if (i==undefined) {
		return 0;
	} else {
		y = AdjustRegion(i);
		if (y==0) return 0;
	}
	document.TITLEREGION.submit();
}
function ChangeSelectRegion(i) {
//	i = document.TITLEREGION.region_id.options[document.TITLEREGION.region_id.options.selectedIndex].value;
	if (i==undefined) {
		return 0;
	} else {
		y = AdjustRegion(i);
		if (y==0) return 0;

	}
	for (var x = 0; x <= document.TITLEREGION.region_id.length-1; x++) {
		if (document.TITLEREGION.region_id.options[x].value == i) {
			document.TITLEREGION.region_id.options.selectedIndex = x;
		}
	}
//	document.TITLEREGION.region_id.options.selectedIndex = i-1
	document.TITLEREGION.submit();
}

function AdjustRegion(z) {
	if (z==1) {
		document.TITLEREGION.action = "/US"+actioninfo;
		document.TITLEREGION.Change_Template.value = "1";
	} else if (z==2) {
		document.TITLEREGION.action = "/LA"+actioninfo;
		document.TITLEREGION.Change_Template.value = "2";
	} else if (z==3) {
		document.TITLEREGION.action = "/CA"+actioninfo;
		document.TITLEREGION.Change_Template.value = "1";
	} else if (z==8) {
		document.TITLEREGION.action = "/BR"+actioninfo;
		document.TITLEREGION.Change_Template.value = "4";
	} else {
		return 0;
	}
	return 1;
}



// if(self!=top) {
// 	url=self.location.href;
// 	topurl=top.location.href;
// 	if (topurl.match("/reflib/")) {
// 		topurl=top.location.href;
// 	} else {
// 		if(document.images) {
// 			top.location.replace(url);
// 		} else {
// 			top.location.href=url;
// 		}
// 	}
// }





