
//UTIL FUNCTIONS

function hideDiv() {
	me = document.getElementById("hideshow");
	me.style.display="none";
}

function showDiv() {
	me = document.getElementById("hideshow");
	me.style.display="block";
}


function mailPage()
{
  mail_str = "mailto:?subject=REYATAZ.com Information: " + document.title;
  mail_str += "&body=Please see this important information about " + document.title;
  mail_str += " " + location.href + " from REYATAZ.com.";
  mail_str += "%0a%0dPersonal message:"; 
  location.href = mail_str;
}


function printPages() {
	if (!document.questionForm.considerTherapy.checked && !document.questionForm.considerTherapy.checked &&
	   !document.questionForm.switchTherapy.checked ) {
	 alert("You have not selected anything to print.");
 	return false;
	}
}



//LEAVING SITE

function leavingSite() {
	var dom = document.domain.toString();
	for ( var i = 0; i <= ( document.links.length - 1 ); i++ ) {
		if( ( document.links[i].href.indexOf( dom ) == -1 ) && 
		    ( document.links[i].href.indexOf( 'ftp:\/\/' ) == -1 ) &&
		    ( document.links[i].href.indexOf( 'javascript:' ) == -1 ) ) {
			
			// set the onclick
			document.links[i].onclick = function() {
				confirm("You are now leaving www.reyataz.com. This site may provide links or references to other Web sites not affiliated with Bristol-Myers Squibb Company. Bristol-Myers Squibb Company is not responsible for the content of such other sites and shall not be liable for any damages or injury arising from users' access to such sites. Links to other sites are provided only as a convenience to users of our site.");
				return false;
			};
		}
	}
}

window.onload = function() {
	leavingSite();
}



//FOR CHANGING TEXT SIZES

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);



DOMhelp={
	cssjs:function(a,o,c1,c2){
		switch (a){
			case 'swap':
				o.className=!DOMhelp.cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
			break;
			case 'add':
				if(!DOMhelp.cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
			break;
			case 'remove':
				var rep=o.className.match(' '+c1)?' '+c1:c1;
				o.className=o.className.replace(rep,'');
			break;
			case 'check':
				var found=false;
				var temparray=o.className.split(' ');
				for(var i=0;i<temparray.length;i++){
					if(temparray[i]==c1){found=true;}
				}
				return found;
			break;
		}
	}
}

// FOR TAB HOVERING

function tabHoverRed(){
	var tabLi = document.getElementsByTagName('li');
	for (i=0; i<tabLi.length; i++){
		if(tabLi[i].className.indexOf('off') != -1 /*&& tabLi[i].className.indexOf('home') == -1*/ ){
			tabLi[i].onmouseover = function(){
				if(this.hasChildNodes){							
					var liA = this.getElementsByTagName('a');					
					for(j=0; j<liA.length; j++){						
						DOMhelp.cssjs('add',liA[j],'tabHover_a');						
					}
				}
				DOMhelp.cssjs('add',this,'tabHover_li');
				
				// reset class for tab with 2 lines
				/*if(this.className.indexOf('doubleLine')!=-1 ){
					DOMhelp.cssjs('remove',this,'doubleLine');
					DOMhelp.cssjs('add',this,'doubleLine');
					// for IE, remove class 'tabHover_a' from <a> inside like, causes excess padding
					if(this.hasChildNodes){							
						var dblA = this.getElementsByTagName('a');					
						for(j=0; j<dblA.length; j++){						
						DOMhelp.cssjs('remove',dblA[j],'tabHover_a');						
						}
					}
				}*/			
			}
			tabLi[i].onmouseout = function(){
				if(this.hasChildNodes){							
					var liA = this.getElementsByTagName('a');					
					for(j=0; j<liA.length; j++){
						DOMhelp.cssjs('remove',liA[j],'tabHover_a');
					}
				}
				DOMhelp.cssjs('remove',this,'tabHover_li');
			}
		}
	}		
}


/*
 * object used to add onload functions for the body onload event
 * this way we can keep JS that needs to run onload unobtrusive
 *
 * usage: windowObject.addLoadFunction([pass function], [pass function]);
 * you can pass 1 or more functions, the number does not matter
 */
	WindowObject = function(win) {
		this._win = win;
		this.stack = [];
	};
	WindowObject.prototype = {
		"runFuncs": function() {
			for(var index = 0; index < this.stack.length; index++) {
				this.stack[index]();
			}
		},
		"addLoadFunction": function() {
			for(var index = 0; index < arguments.length; index++) {
				this.stack.push(arguments[index]);
			}
		}
	};
	var windowObject = new WindowObject(this);
	function runOnLoad() {
		windowObject.runFuncs();
	}
	window.onload = runOnLoad;

	
	windowObject.addLoadFunction(tabHoverRed);

