var browser = navigator.appName;
//alert(browser);
var b_version = navigator.appVersion;
var version = parseFloat(b_version);

function whatchemo() {
	if (browser == "Netscape") {
		tb_open_new('what_chemoready.jsp?TB_iframe=true&height=530&width=707&modal=true');	
    }
    else {		
		tb_open_new('what_chemoready.jsp?TB_iframe=true&height=525&width=707&modal=true');
    }	
}
function sideeffect() {
	if (browser == "Netscape") {
		tb_open_new('side_effects.jsp?TB_iframe=true&height=517&width=707&modal=true');	
    }
    else {
		tb_open_new('side_effects.jsp?TB_iframe=true&height=524&width=707&modal=true');
    }	
}
function chemoprepare() {
	if (browser == "Netscape") {
		tb_open_new('chemo_prepare.jsp?TB_iframe=true&height=510&width=707&modal=true');
    }
    else {
		tb_open_new('chemo_prepare.jsp?TB_iframe=true&height=513&width=707&modal=true');	
    }	
}
function askdoctor() {
	if (browser == "Netscape") {
		tb_open_new('ask_doctor.jsp?TB_iframe=true&height=535&width=707&modal=true');
    }
    else {
		tb_open_new('ask_doctor.jsp?TB_iframe=true&height=538&width=707&modal=true');	
    }
}
function viewchemo() {
	if (browser == "Netscape") {
		tb_open_new('viewchemoplan.jsp?TB_iframe=true&height=528&width=707&modal=true');
    }
    else {
		tb_open_new('viewchemoplan.jsp?TB_iframe=true&height=530&width=707&modal=true');	
    }	
}

function email(){    	
	if (browser == "Netscape") {
		tb_open_new('emailplan.jsp?TB_iframe=true&height=322&width=625&modal=true');			
    }
    else {
		tb_open_new('emailplan.jsp?TB_iframe=true&height=310&width=630&modal=true');		
    }
}
function email1(msg) {
	if (browser == "Netscape") {
		tb_open_new('emailplan.jsp?msg='+msg+'&TB_iframe=true&height=322&width=625&modal=true');
    }
    else {
		tb_open_new('emailplan.jsp?msg='+msg+'&TB_iframe=true&height=310&width=630&modal=true');
    }
}
function emailStatus(msg) {
	if (browser == "Netscape") {
		tb_open_new('emailstatus.jsp?msg='+ msg+'&TB_iframe=true&height=143&width=473&modal=true');
    }
    else {
		tb_open_new('emailstatus.jsp?msg='+msg+'&TB_iframe=true&height=143&width=473&modal=true');
    }
}
function exit(){    
	if (browser == "Netscape") {		
		tb_open_new('exit.jsp?TB_iframe=true&height=206&width=473&modal=true');
    }
    else {		
		tb_open_new('exit.jsp?TB_iframe=true&height=206&width=473&modal=true');
    }
}

function preview(){
    window.location = "previewplan.jsp";
}

function save(){    
	if (browser == "Netscape") {
		tb_open_new('save.jsp?TB_iframe=true&height=206&width=500&modal=true');
    }
    else {
		tb_open_new('save.jsp?TB_iframe=true&height=206&width=500&modal=true');
    }
}

function plansaved(){    
	if (browser == "Netscape") {
		tb_open_new('yourplansaved.jsp?TB_iframe=true&height=124&width=473&modal=true');
    }
    else {
		tb_open_new('yourplansaved.jsp?TB_iframe=true&height=124&width=473&modal=true');
    }
}
function forgot() {
	if (browser == "Netscape") {
		tb_open_new('forgot.jsp?TB_iframe=true&height=208&width=473&modal=true');
    }
    else {
		tb_open_new('forgot.jsp?TB_iframe=true&height=208&width=473&modal=true');
    }
}
 
function saveexit() {	
	if (browser == "Netscape") {
		tb_open_new('yourplansaved.jsp?exit=yes&TB_iframe=true&height=124&width=473&modal=true');
    }
    else {
		tb_open_new('yourplansaved.jsp?exit=yes&TB_iframe=true&height=124&width=473&modal=true');
    }
}
function printPage(){
    //alert("hi");
    window.print();
}

function startNew(){    
	if (browser == "Netscape") {
		tb_open_new('personalize_plan.jsp?TB_iframe=true&height=430&width=472&modal=true');
    }
    else {
		tb_open_new('personalize_plan.jsp?TB_iframe=true&height=444&width=472&modal=true');
    }
}
function eraseStart(){    
	window.location.hash = "chemo";
	if (browser == "Netscape") {
		tb_open_new('erace.jsp?TB_iframe=true&height=182&width=472&modal=true');
    }
    else {
		tb_open_new('erace.jsp?TB_iframe=true&height=185&width=472&modal=true');
    }
}
function login(){    
	if (browser == "Netscape") {
		tb_open_new('login.jsp?TB_iframe=true&height=252&width=550&modal=true');
    }
    else {
		tb_open_new('login.jsp?TB_iframe=true&height=253&width=550&modal=true');
    }
}
function register(){    
	if (browser == "Netscape") {
		tb_open_new('register.jsp?TB_iframe=true&height=288&width=472&modal=true');
    }
    else {		
		tb_open_new('register.jsp?TB_iframe=true&height=298&width=472&modal=true');
    }
}
function updateorsave(){    
	if (browser == "Netscape") {
		tb_open_new('updateorsave.jsp?TB_iframe=true&height=206&width=472&modal=true');
    }
    else {
		tb_open_new('updateorsave.jsp?TB_iframe=true&height=206&width=472&modal=true');
    }
}
function quickdemo(URL){    
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=810,height=632');");
}
function sessionRemoved() {
	window.location = "index.jsp";
	tb_remove();
	//alert("called sessionRemoved")
}
function addAsk(){
	window.location.hash="chemo";    
	if (browser == "Netscape") {
		tb_open_new('additional-ask.jsp?TB_iframe=true&height=520&width=650&modal=true');
    }
    else {
		tb_open_new('additional-ask.jsp?TB_iframe=true&height=520&width=650&modal=true');
    }
    
}
function addTips(){
	window.location.hash="chemo";    
	if (browser == "Netscape") {
		tb_open_new('additional-tips.jsp?TB_iframe=true&height=201&width=559&modal=true');
    }
    else {
		tb_open_new('additional-tips.jsp?TB_iframe=true&height=201&width=559&modal=true');
    }
}
function addTodo(){
	window.location.hash="chemo";    
	if (browser == "Netscape") {
		tb_open_new('additional-todo.jsp?TB_iframe=true&height=170&width=472&modal=true');
    }
    else {
		tb_open_new('additional-todo.jsp?TB_iframe=true&height=170&width=472&modal=true');
    }
}
function referaFriend() {
    window.location.hash = "chemo";    
	if (browser == "Netscape") {
		tb_open_new('referafriend.jsp?TB_iframe=true&height=342&width=472&modal=true');
    }
    else {
		tb_open_new('referafriend.jsp?TB_iframe=true&height=343&width=472&modal=true');
    }
}
function referaFriend1(msg) {
    window.location.hash = "chemo";    
	if (browser == "Netscape") {
		tb_open_new('referafriend.jsp?msg='+msg+'&TB_iframe=true&height=342&width=472&modal=true');
    }
    else {
		tb_open_new('referafriend.jsp?msg='+msg+'&TB_iframe=true&height=343&width=472&modal=true');
    }
}
function heared() {
    window.location.hash = "chemo";   
	if (browser == "Netscape") {
		tb_open_new('heared.jsp?TB_iframe=true&height=356&width=472&modal=true');
    }
    else {
		tb_open_new('heared.jsp?TB_iframe=true&height=381&width=472&modal=true');
    }
}
function heared1(msg) {
    window.location.hash = "chemo";     
	if (browser == "Netscape") {
		tb_open_new('heared.jsp?msg='+msg+'TB_iframe=true&height=356&width=472&modal=true');
    }
    else {
		tb_open_new('heared.jsp?msg='+msg+'TB_iframe=true&height=381&width=472&modal=true');
    }
}
var ajax;
var arr;
var result;
var add;
function MyObject(){
    if (window.XMLHttpRequest) {
		ajax = new XMLHttpRequest();
	}
	else {
		if (window.ActiveXObject) {
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else {
			ajax = new ActiveXObject("MSXML2.XMLHTTP");
		}
	}
}

function Hello(u,res,a){	
	result = res;
	add = a;
    MyObject();
    ajax.onreadystatechange = helloCallback;    
    //alert("from hello  "+u+"\n\n"+result.innerHTML+"\n\n"+add);
    var m = Math.random();
    ajax.open("GET", "../common/"+u + "&" + m, true);
    ajax.send(null);
}

function helloCallback(){
    var serverData;
    if (ajax.readyState == 4) {
        if (ajax.status == 200) {
            serverData = ajax.responseText;
            arr = serverData.split(",");
           // alert(arr[0]+"  --"+arr[1]+"--");			
			//alert("from Hellocallback: "+add + document.getElementById(add));
			//alert(arr[0]);
			if (arr[0].toString() == "fail") {				
				document.location = "index.jsp";
			}
			else {
				//document.getElementById(add).innerHTML = arr[0];
				document.getElementById(add).innerHTML = "Actualiser le plan";				
				result.innerHTML = arr[1];				
			}
			//alert(add + "  " + result.innerHTML);			
            ajex = null;
        }
    }
    else {
        document.getElementById(add).innerHTML = "<img src='images/usercheck.gif' height=20 width=20 />";
    }
}
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());
}
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 "";
}
