
	var globArray = Array();
	var jQueryPost = '';
	var xtime = '';
	var t_time = 1000;
	var err;
	var b;
	

	var errorMessages = ''; 
	var errorText = ''; 
	var errors = false;
	function addError(msg)
	{
		errorMessages += msg + "\r\n";
		errorText += msg + "\r\n";
		errors = true;
	}

function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];
 
  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
} 	

function callTimeInterval () {
	setTimeout("saveFormInfo()", 5000);
	//var exd = new Date();
	//jQuery('#div_info').append('save Cookie by calltimeinterval() ' + exd.toGMTString()+'<br />');
}

function removeErrorDiv (divname) 
{
	return;
	if (jQuery('#error_'+divname).val() != undefined )  {
		
		jQuery('#error_'+divname).remove();
		if (jQuery('#div_error div').length == 0 ) {
			jQuery('#div_error').remove();
		}
	}
}

function xss_ajax(url) 
{
	var script_id = null;
	var script = document.createElement('script');
	script.setAttribute('type', 'text/javascript');
	script.setAttribute('src', url);
	script.setAttribute('id', 'script_id');
	
	script_id = document.getElementById('script_id');
	if(script_id)
	{
		document.getElementsByTagName('head')[0].removeChild(script_id);
	}
	
	// Insert <script> into DOM
	document.getElementsByTagName('head')[0].appendChild(script);
}

function replaceSpace (name) {
	var str = jQuery (name).val();
	while (str.replace(/  /g, " ") != str) {
		str = str.replace(/  /g, " ");
	}
	return str;
}
	

function quoteInProgress() {
	alert("Submit in progress - Please wait");
}

function submitApplication() {
	validateFields();

}

function submitquoteform(doNotValidate, x){

	document.QuoteForm.doNotValidate.value = doNotValidate;

	if (doNotValidate){
		document.getElementById('btn_img').onclick=quoteInProgress;
		// submit without validation...
		document.QuoteForm.submit();
		return true;
	}
	
}	
function trim (str, charlist) {
	var whitespace, l = 0, i = 0;
	str += '';

	if (!charlist) {
		// default list
		whitespace = " \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";
	} else {
		// preg_quote custom list
		charlist += '';
		whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '$1');
	}

	l = str.length;
	for (i = 0; i < l; i++) {
		if (whitespace.indexOf(str.charAt(i)) === -1) {
			str = str.substring(i);
			break;
		}
	}

	l = str.length;
	for (i = l - 1; i >= 0; i--) {
		if (whitespace.indexOf(str.charAt(i)) === -1) {
			str = str.substring(0, i + 1);
			break;
		}
	}

	return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}

function ucwords(str) {
	return (str+'').replace(/^(.)|\s(.)/g, function ( $1 ) { return $1.toUpperCase( ); } );
}

function makeNumericFloaterFormatted(inNum){
	if (! IsNumeric(inNum.value)){
		inNum.value = 0.00;
	}
	inNum.value = FormatNumber(parseFloat(inNum.value),2);
	return;
}

function setCookieName(name) {
	Cookie.set(name, jQuery.toJSON(jQuery("#"+name).serializeObject()) );
	return;
}

function setPopulateName(name) {
	var obj = eval('('+Cookie.get(name)+')');
	jQuery("#"+name).populate(obj);
}

function showCookieName(name) {

}
jQuery.fn.serializeObject = function() {
    var o = {};
    var a = this.serializeArray();
    jQuery.each(a, function() {
        if (o[this.name]) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || "");
        } else {
            o[this.name] = this.value || "";
        }
    });
    return o;
};

function xxJSON (nameId) {
	var arr = jQuery('#'+nameId).serializeArray();
    var json = "";
    jQuery.each(arr, function(){
        jQuery.each(this, function(i, val){
                if (i=="name") {
                       json += '"' + val + '":';
                } else if (i=="value") {
                        json += '"' + val.replace(/"/g, '\\"') + '",';
                }
        });
    });
    json = "{" + json.substring(0, json.length - 1) + "}";
	return json;
}


function saveFormInfo()
{
	Cookie.set('QuoteForm', jQuery.toJSON(jQuery("#QuoteForm").serializeObject()),(20*60));
	Cookie.set('movingQuoteForm', jQuery.toJSON(jQuery("#movingQuoteForm").serializeObject()),(20*60));
	Cookie.set('international_quote', jQuery.toJSON(jQuery("#international_quote").serializeObject()),(20*60));
	return true;
}

   
var failedValidates = 0;
var failedValidateMessage = "";
function setFailedValidateMessage() 
{	    
	if (failedValidates > 2)
	{
		failedValidateMessage = "It looks like you are having some trouble with our form.\nFeel free to contact one of our representatives at 800.579.1523.";
	}
	else if (failedValidates > 0)
	{
		failedValidateMessage = "Valid contact information is required.\nFeel free to contact one of our representatives for a quote at 800.579.1523.";
	}
}

