/* Default Physician Directory setting */
var specialty=13;

/* Default Newsletter settings */
var moduletype=3;
var newsletter=24;

/* brings in date for header */
var now = new Date();
var days = new Array('Pazar','Pazartesi','Salı','Çarşamba','Perşembe','Cuma','Cumartesi');
var months = new Array('Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','A?ustos','Eylül','Ekim','Kasım','Aralık');
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
function fourdigits(number)	{
	return (number < 1000) ? number + 1900 : number;
}
wmd_today =  months[now.getMonth()] + " " + date + ", " + (fourdigits(now.getYear()));

/* function to change a class */
function setClass(objectID,newClass) {
	var object = document.getElementById(objectID);
	if (object) {
		object.className = newClass;
	}
}

/* function to toggle visibility */
function toggle( targetId ) {
   if ( document.getElementById ) {
    target = document.getElementById( targetId );
    if ( target.style.display == "none" ) {
     target.style.display = "";
    } else {
     target.style.display = "none";
    }
   }
}

/* function to add an onload event */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') 
  {
    window.onload = func;
  } else 
    {
       window.onload = function() 
    {
      oldonload();
      func();
    }
  }
}	

/* function to go back to previous page */
function timedReturn()
	{
	var t=setTimeout("history.go(-1)",60000)
	}

/* function to check e-mail address validity on a form */
 function checkEmailAddr() 
 {
  illegal = /[^\w._\-]/;
  email = document.newsletterForm.EmailAddr.value;

  if (email.length<6 || email.indexOf("@")==-1 || email.indexOf('.')==-1)
  { email=""; }
  else 
  {
   At = email.indexOf("@");
   Period = email.lastIndexOf('.');
   DNS1 = email.substring(0,At);
   if (DNS1.length<1 || DNS1.match(illegal)!=null) email="";
   DNS2 = email.substring(At+1,Period);
   if (DNS2.length<1 || DNS2.match(illegal)!=null) email="";
   DNS3 = email.substring(Period+1,email.length);
   if (DNS3.length<2 || DNS3.match(illegal)!=null) email="";
  }

  if (email.length==0) 
  {
   alert("Lütfen mail adresinizi kontrol edin.\n");
   document.newsletterForm.eMail.focus();
   return false;
  }
  
  return true;
 }
 
/* function for omniture tracking */
function sl(url, link_type, bi_tag)
{
	// used for Omniture Tracking
	ctrs(bi_tag);

	var status,toolbar,width,height,resizable,scrollbars,menubar;
	
	var left = 0;
	var top = 0;

	var href = new String(url.href);

	if (href.indexOf("/video/") != -1) {
		width=860;
		height=730;
		top=10;
		left=10;
		scrollbars="no";
		resizeable="no";
		status="yes";
		left = 25;
		top = 25;
	}
	else 
		if (href.indexOf("/healthmanager.") != -1) {
			return openAssessPopup(url);			
		}
		else
			if ((href.indexOf("/content/article") != -1 || href.indexOf("/content/pages") != -1 || href.indexOf("/solutions") != -1 || href.indexOf("/content/Article") != -1 || href.indexOf("/content/Pages") != -1) && (link_type != 'sp')) {
				return true; // don't do anything
			}
			else 
				if(link_type == '' || link_type == 'normal' || link_type == 'regular')
				{
					return true; // don't do anything
				}
				else if(link_type == 'sp')
					{
					   width = 590;
					   height = 400;
					   toolbar = 0;
					   resizable = 1;
					   status = 0;
					   scrollbars = 1;
					   left = 25;
					   top = 25;
					}
					else
						if(link_type == 'ai')
						{
						   width = 715;
						   height = 600;
						   scrollbars = 1;
						   toolbar = 0;
						   resizable = 1;
						   status = 0;
						   left = 25;
						   top = 25;
						}
						else
							if(link_type == 'nw')
							{
								// just open a new window
								//window.open(url);
								//return false;
							   width = 1000;
							   height = 600;
							   scrollbars = 1;
							   toolbar = 1;
							   resizable = 1;
							   status = 1;
							   left = 25;
							   top = 25;
							}
							else
								if(link_type == 'hw')
								{
							   		width = 526;
							   		height = 626;
							   		scrollbars = 1;
							   		toolbar = 1;
							   		resizable = 1;
							   		status = 1;
							   		left = 25;
							   		top = 25;
								}
								else
									{
									return true;
									}

	//alert(url);

	var newWindow = window.open(url,"","width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",resizable=" + resizable + ",status=" + status + ",menubar=" + menubar);
	
	//if(	moveWindow == true)
	//	newWindow.moveTo(XPosition,YPosition);

	return false;
}

//For the search bar
function  DoSearch()
{
	var query;
	var sourceType;
	var url;
	//get the query
	query = escape(document.getElementById("txtQuery").value);
	
	if(query.length > 0)
	{
		try
		{
			ctr('Search_landingSearch');	//omniture function
		}
		catch(err)
		{
		}
		sourceType = document.getElementById("sourceType").value;
		if(sourceType == "web_search")
		{
			window.location.href = "results.asp?query=" + query + "&sourceType=" + sourceType;
		}
		else
		{
			window.location.href = "default.asp?query=" + query + "&sourceType=" + sourceType;
		}
	}
	return false;
}

function submitSearchBoxLanding(ev)
{
	if((ev.which && ev.which == 13) || (ev.keyCode && ev.keyCode == 13))
	{
		return DoSearch();
	}
	else
	{
		return	true;
	}
}

// slider for the shared health tools module thats all over the site
function SwitchSlideHT(obj, pID){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var sign = document.getElementById(pID);
	var sign_ar = ['htsign0','htsign1'];
	var el_ar = ['htsub0','htsub1'];
		if(el.style.display == "none"){
			for (var i=0; i<el_ar.length; i++){
				document.getElementById(el_ar[i]).style.display = "none";
			}
			el.style.display = "block";
			for (var j=0; j<sign_ar.length; j++){
				document.getElementById(sign_ar[j]).src = "../images/todaysNews_plusSign.gif";
			}
			sign.src = "../images/todaysNews_minusSign.gif";
		}
		else{
			el.style.display = "none";
			sign.src = "../images/todaysNews_plusSign.gif";
		}
	}
}

/* function for bookmarking */
function wmdDoBookmark() {
  /* quick check of the browser and OS */
  var agt=navigator.userAgent.toLowerCase();

  /*** PLATFORM ***/
  var is_win = (agt.indexOf('windows')!=-1);
  var is_mac = (agt.indexOf('mac')!=-1);

  /*** BROWSER ***/
  var is_ie     = (agt.indexOf('msie') != -1);
  var is_firefox = (agt.indexOf('firefox') != -1);
  var is_netscape  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('compatible') == -1));
  var is_safari = ((agt.indexOf('safari')!=-1)&&(is_mac));

  if (is_win) {
    if (is_ie && window.external) {
      window.external.AddFavorite(location.href,document.title);
    }
    else {
      if (is_firefox) {
        alert('Please press CTRL + D to bookmark this page.');
      }
      else {
        if (is_netscape) {
          alert('Please press CTRL + D to bookmark this page.');
        }
        else {
          alert('Please press CTRL + D to bookmark this page.');
        }
      }
    }
  }
  else {
    if (is_mac) {
      if (is_ie && window.external) {
        window.external.AddFavorite(location.href,document.title);
      }
      else {
        if (is_safari) {
          alert('Please press Command (Apple) + D to bookmark this page.');
        }
        else {
          alert('Please press UP arrow + Command (Apple) + D to bookmark this page.');
        }
      }
    }
    else {
      alert('Please press CTRL + D to bookmark this page.');
    }
  }
  return false;
}

/* function for health solutions footer */
function isSensTop (priTop,secTop) {
	var isSensTopBool = false;


	if (priTop.charAt(0) == '7') {
		isSensTopBool = true;
	} else {
		var secTopArray = secTop.split("|");
		var curSecTop = 0;

		for (curSecTop in secTopArray) {
			if (secTopArray[curSecTop].charAt(0) == '7') {
				isSensTopBool = true;
				break;		
			}
		}
	}
	
	return isSensTopBool;
}

/* function for healthmanager portland popup */
function openAssessPopup(theUrl) { 
	var win = window.open(theUrl, 'WebMDHealthManagerTool','resizable,scrollbars,width=705,height=600,left=25,top=25,screenX=25,screenY=25'); 
	if (win) { win.focus(); } 
	return false;
}


/* all functions below are for printer friendly articles */

/* Used to open a printer friendly window */
function printWindow() { 
var x = 805; var y = 600; 
	var url = location.href;

	if (url.search("[\\?]") != -1) {
	url = location.href + '&print=true';
	} else {
	url = location.href + '?print=true';
	}

	if (navigator.appVersion.indexOf("Mac") > 0) { 
	openWindow(url, "width=" + x + ",height=" + y + ",toolbar=yes,resizable=yes,scrollbars=yes"); 
	} else { 
	openWindow(url, "width=" + x + ",height=" + y + "toolbar=1,location=1,directories=0,status=0,menubar=0,scrollbars=1,resize=yes,copyhistory=0,top=10,left=10"); 
	} 
} 

/* opens a window */
function openWindow(url, optionString) { 
window.open(url, "printFriendly", optionString); 
} 

function getParam(name) {
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var tmpURL = window.location.href;
  var results = regex.exec( tmpURL );
  if( results == null )
    return "";
  else
    return results[1];
}

/* insert buttons and url */
function printButton() {
	var printDiv = document.createElement('div');
	printDiv.setAttribute('id','global-head-print');
	printDiv.innerHTML = '<div class=\"print-button\"><a class=\"button" href=\"#\" onclick=\"javascript:window.print();\">Print</a></div><div class=\"close-button\"><a class=\"button" href=\"#\" onClick=\"javascript:window.close();\">Close Window</a></div><div class=\"spacer\"><span></span></div>';
	
	if (!document.getElementById("page_area")) return false;
	var insert1 = document.getElementById("page_area");
	var parentDiv = insert1.parentNode;
	
	var split1 = window.location.href.split("?");
	var ArticleUrl = split1[0];
	
	var urlDiv = document.createElement('div');
	urlDiv.setAttribute('id','url-reference');
	urlDiv.innerHTML = '<div><strong>Article Link:</strong> '+ ArticleUrl +'</div>';
	
	if (!document.getElementById("header_ctr")) return false;
	var insert2 = document.getElementById("header_ctr");

	parentDiv.insertBefore(printDiv, insert1);
	insert2.appendChild(urlDiv);

}

/* execute if printerfriendly */
var pf_param = getParam("print");