function getPageName(){
	
	var page_title = String( document.title );
	var index = page_title.lastIndexOf('-');
	var aux = "";
	
	if( index != -1 ){
		if( page_title.indexOf('-') != index ){
			aux = String( page_title ).substring( index + 1 );
		} else{
			aux = String( page_title ).substring( index + 2 );
		}		
	}else{
		index = page_title.lastIndexOf('®');
		if( index != -1 ){
			aux = String( page_title ).substring( index + 2 );
		}else{
			aux = page_title;
		}
	}
	
	return aux;
}

function getHTTPObject() { 			
		if (typeof XMLHttpRequest != 'undefined') {				
			return new XMLHttpRequest(); 
		} 
		try { 		
			return new ActiveXObject("Msxml2.XMLHTTP"); 
		} catch (e) { 
			try { 			
				return new ActiveXObject("Microsoft.XMLHTTP"); 
			} catch (e) {} 
		} 
		return false; 
}

function redirectTellFriendPage(){
			var pageName = getPageName();
			var xmlHttpMenu = getHTTPObject();
	    	if (xmlHttpMenu != null) { 
			    var varNoCacheMenu = new Date().getTime();
			    
			    var varParametersMenu = '?pn=' + escape(pageName) + '&noChache=' + varNoCacheMenu;			    
			    
			    var varPageMenu = "/saveLastPage.do" + varParametersMenu;
			    
			    xmlHttpMenu.onreadystatechange = function() {
			        if (xmlHttpMenu.readyState == 4) {
			        	if (xmlHttpMenu.status != 500) {
			        		window.location.href = window.location.protocol + '//' + window.location.host + '/tell_friend.jsp';
						}
			        }
			    }
			   
			    var urlMenu=varPageMenu;
			    xmlHttpMenu.open("GET",urlMenu,true);
			    xmlHttpMenu.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			    xmlHttpMenu.send(null);	
		    
		    } else {
		    	window.location.href = window.location.protocol + '//' + window.location.host + '/tell_friend.jsp';
		    }	
}
