jQuery.ajaxSettings.traditional = true;
jQuery.ajaxSettings.cache = false;

function addFocusHandlers(elements) {
    for (i=0; i < elements.length; i++) {
        if (elements[i].type != "button" && elements[i].type != "submit" &&
            elements[i].type != "reset" && elements[i].type != "checkbox" && elements[i].type != "radio") {
            if (!elements[i].getAttribute('readonly') && !elements[i].getAttribute('disabled')) {
            	$(elements[i]).bind('focus', function() {
            		this.style.backgroundColor='#ffd';this.select();
				});
            	$(elements[i]).bind('mouseover', function() {
            		this.style.backgroundColor='#ffd';
				});
            	$(elements[i]).bind('blur', function() {
            		this.style.backgroundColor='';
				});
            	$(elements[i]).bind('mouseout', function() {
            		this.style.backgroundColor='';
				});
            }
        }
    }
}
jQuery(document).ready(function(){
	addFocusHandlers(document.getElementsByTagName("input"));
    addFocusHandlers(document.getElementsByTagName("textarea"));
});

String.prototype.trim = function () {
    return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};
// Show the document's title on the status bar
window.defaultStatus=document.title;

Array.prototype.in_array = function(e){
	for(var i=0;i<this.length;i++){
		if(this[i] == e) return true;
	}
	return false;			
};

function getMainDomain(){
	var mainDomain = null;
	segment = document.domain.split(".");
	if(segment.length>2){
		mainDomain=segment[segment.length-2]+'.'+segment[segment.length-1];
	}
	return mainDomain;
}
Request = {
	QueryString : function(item) {
		var svalue = location.search.match(new RegExp("[\?\&]" + item
				+ "=([^\&]*)(\&?)", "i"));
		return svalue ? svalue[1] : svalue;
	}
};
var salespersonMark = Request.QueryString("s");
if (salespersonMark) {
	var expires = new Date();
	expires.setTime(expires.getTime() + 604800000); // sets it for approx 7days.24 * 7 * 60 * 60 * 1000
	setCook("salespersonMark", salespersonMark, expires, '/', getMainDomain());
}

function isNumber(n) {return !isNaN(parseFloat(n)) && isFinite(n);}
function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
/* This function is used to set cookies */
function setCook(name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}
function getCookie(c_name){
	if (document.cookie.length>0) {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1){ 
	    c_start=c_start + c_name.length+1 ;
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	  } 
	}
	return "";
}

