var Cookie = {
	set: function(name, value, daysToExpire) {
		var expire = '';
		if(daysToExpire != undefined) {
			var d = new Date();
			d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
			expire = '; expires=' + d.toGMTString();
		}
		return (document.cookie = escape(name) + '=' + escape(value || '') + expire);
	},
	get: function(name) {
		var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
		return cookie ? unescape(cookie[2]) : null;
	},
	erase: function(name) {
		var cookie = Cookie.get(name) || true;
		Cookie.set(name, '', -1);
		return cookie;
	},
	accept: function() {
		if(typeof navigator.cookieEnabled == 'boolean') {
			return navigator.cookieEnabled;
		}
		Cookie.set('_test', '1');
		return Cookie.erase('_test') === '1';
	}
};

//  code added by Sergey Zubtsovskiy (2008-06-19)
/**
 * Strips leading and trailing white spaces from the string.
 * @param str String to trim.
 * @return String with leading and trailing whitespaces removed.
 */
function trim(str) {
	if ( str != null ) {
		var i;
		for ( i = 0; i < str.length; i++ ) {
			if ( !isWhitespace(str.charAt(i)) ) {
				str = str.substring(i, str.length);
				break;
			}
		}

		for ( i = str.length - 1; i >= 0; i-- ) {
			if ( !isWhitespace(str.charAt(i)) ) {
				str = str.substring(0, i + 1);
				break;
			}
		}

		if ( isWhitespace(str.charAt(0)) ) {
			return "";
		} else {
			return str;
		}
	} else {
		return null;
	}
}

/**
 * Return true if given character is either space or \t or \n or \r character.
 * @param c Character to test.
 */
function isWhitespace(c) {
	return c == " " || c == "\t" || c == "\n" || c == "\r";
}

/**
 * Tests is string is valid URL.
 * @param s String to test
 * @return True if string is valid URL, false otherwise.
 */
function isValidURL(s) {
	if ( s != null ) {
		return /^((https?|ftp)\:\/\/((\[?(\d{1,3}\.){3}\d{1,3}\]?)|(([-a-zA-Z0-9]+\.)+[a-zA-Z]{2,5}))(\:\d+)?(\/[-a-zA-Z0-9._?,'+&amp;%$#=~\\]+)*\/?)$/.test(trim(s));
	} else {
		return false;
	}
}

// end of added code

function getAllInputInForm(f,excludes){
	var temp = "";
	var allInputValue = "";
	for (var i=0;i<f.length;i++){
		var name = f.elements[i].name;
		var type = f.elements[i].type;
		var value = f.elements[i].value;
		var ok = false;
		// to check NOT undefined
		if (type){
			if (type =='radio'){
				if (f.elements[i].checked){
					ok = true;
				}
			}else if (type =='checkbox'){
				if (f.elements[i].checked){
					ok = true;
				}
			}else{
				ok = true;
			}
			
		}
		
		if(ok){
			//check excludes
			for (var i2=0;i2<excludes.length;i2++){
				if (f.elements[i].name==excludes[i2]){
					ok = false;
				}
			}
		}	
		
		if (ok){
			temp = temp + f.elements[i].name+": "  + f.elements[i].type+": "+f.elements[i].value+"\n";
			allInputValue = allInputValue + f.elements[i].name+"="+ encodeURIComponent(f.elements[i].value) +"&";
		}

	}
//	alert(temp);
//	alert(allInputValue);
	return allInputValue;
}
