bodyOnReady(function(){})

function bodyOnReady(func){
	if(getCurrentUrl()) {
		var usernamePF = getCookie("ck_mh_info");
		var usernameCMB = getCookie("ck_cb_info");
		
		if(usernamePF != null && usernameCMB != null) {
			window.location = "/1/2/portal/pt/para-sua-empresa";
		}else if(usernamePF!=null) {
			window.location = "/1/2/portal/pt/para-voce";
		}else if(usernameCMB!=null) {
			window.location = "/1/2/portal/pt/para-sua-empresa";
		}else 
			window.location = "/1/2/portal/pt/para-voce";
	}
}


function getCurrentUrl() {
	var arrayUrl = new Array("http://www.hsbc.com.br/1/2", "http://www.hsbc.com.br/1/2/", "http://www.hsbc.com.br/1/2/1/2", "http://gp.brazil.bde.us.dotcom.hsbc/1/2/", "http://gp.brazil.bde.us.dotcom.hsbc/1/2", "http://brazil.bde.us.dotcom.hsbc/1/2/","http://brazil.bde.us.dotcom.hsbc/1/2", "http://www.na051.p2g.netd2.hk.hsbc/1/2/", "http://www.na051.p2g.netd2.hsbc.com.hk/1/2/", "http://www.na051.p2g.netd2.hk.hsbc/1/2", "http://www.na051.p2g.netd2.hsbc.com.hk/1/2","http://161.113.0.57/1/2/","http://161.113.4.57/1/2/");
	var i;
	for(i = 0; i < arrayUrl.length; i++) {
		if(arrayUrl[i] == window.location) 
			return true;		
	}
	return false;
}


function getCookie(c_name) {
	var i,x,y,ARRcookies = document.cookie.split(";");
	
	for(i=0;i<ARRcookies.length;i++) {
  		x = ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  		y = ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		x = x.replace(/^\s+|\s+$/g,"");
		if(x==c_name)
			return unescape(y);
	}
	return null;
}




