var cancerTypes;
//Search function starts
function lookup(inputString){
	var dispcontrn="autoSuggestionsList";

	if(inputString.length < 3){
		$('#'+dispcontrn).html("");
		$("#error_ctype").hide();
	}
     if(inputString.length == 3) {
	 var notFirst=false;
	 $.ajax({
		   type: "POST",
		   url: "/navigatorAutoSuggest.htm",
		   data: "key="+inputString,
		   success: function(JSONdata){
				$('#'+dispcontrn).html("");
				cancerTypes=JSONdata;
				if(JSONdata.length==0)
				{
					$("#error_ctype").css("top","120px");
			    $("#error_ctype").show();
				} else {
					$("#error_ctype").hide();
				}
				for (var i = 0; i < JSONdata.length; i++){
				if(notFirst) $('#'+dispcontrn).append(",&nbsp;");
		    else notFirst=true;
				$('#'+dispcontrn).append('<a href="javascript:;" onclick="fill(this,\'crtxtbx\',\'autoSuggestionsList\')" style="font-size:13px">' +JSONdata[i].name+'</a>');	
				$('#'+dispcontrn).css('display','block');
				}
		   },
		   error: function (request, status, error) {
			   //alert("Error : navigatorAutoSuggest.htm");
			  // window.location='error.htm';
		    }

		 });
     }
	
	}

function fill(thisValue,cancrType,dispcontnr) {
	document.getElementById(cancrType).value=thisValue.innerHTML;
//	document.getElementById(dispcontnr).style.display="none";
}
//Search function ends


//ToolTip starts
function toolTip(targt)
{
	var toltp=$("#toolTip");
	toltp.html("");
	toltp.append('<div class="tooltip_arrow"><img src="/images/toolTip/img_tooltip_pointer.gif" alt="" title="" /></div><div class="tooltip_top"><div class="tooltip_bot"><div class="tooltip_left"><div class="tooltip_right"><div class="tooltip_curveTL"><div class="tooltip_curveTR"><div class="tooltip_curveBL"><div class="tooltip_curveBR"><div id="tip"><div style="height:60px;padding-left:75px;padding-top:25px"><img src="/images/toolTip/loader.gif" alt="" title="" border="0"/></div></div></div></div></div></div></div></div></div></div>');
	
	var dataForSer=$(targt).html();
	toltp.css('display','block');
	var offset = $(targt).offset();
	toltp.css('left',offset.left);
	toltp.css('top',offset.top+14+"px");
	 $.ajax({
		   type: "POST",
		   url: "/glossaryToolTip.htm",
		   data: "id="+dataForSer,
		   success: function(respData){
			$('#tip').html(respData);
			},
		   error: function (request, status, error) {
			   //alert("Debug : Error getting definition ");
			  // window.location='error.htm';
		    }
		 });
}
//ToolTip ends
	
//Interstitial Popup starts
function winpopup(pop)
{ 
	var localUrl;
 $("a").live("click",function(event){

  var curLnk=$(this);
  var localmainUrl=$(this).attr("href");
  localmain=localmainUrl.split(":")[0];
  if(localmain == 'mailto'){
localUrl=''
  }else{
localUrl=localmainUrl;

  }


  //var localUrl = "www.breakawayfromcancer.com";


  var urlCheck=localUrl.split("/")[2]; 
  var urlCheck1=localUrl.split("/")[0]; 
  var urlFirstPara=localUrl.split(".")[0]; 

  var urlChk2 = "null";
  try {
		urlChk2 = localUrl.split("//")[1];
		urlChk2 = urlChk2.split(".")[0];
  } catch (error) {
	  urlChk2 = "null";
	  //alert(error);
  }

  
//alert("localurl: "+localUrl);
//alert("urlCheck: "+urlCheck);
//alert("urlCheck1: "+urlCheck1);
//alert("urlFirstPara: "+urlFirstPara);

  var objpop=$("#"+pop);
  var winH=$(window).height();
  var winW=$(window).width();
  var popH=objpop.outerHeight();
  var popW=objpop.outerWidth();
  var poptop=(winH-popH)/2+"px";
  var popleft=(winW-popW)/2+"px";
  
	if($(this).parent(".res_fistcol").length){
		//alert("Advance serach: urlCheck: "+urlCheck);
		//alert("Advance serach: urlCheck1: "+urlCheck1);
		//alert("Advance serach: urlChk2: "+urlChk2);
		//alert("Advance serach: localUrl: "+localUrl);

		if ( (urlCheck == "10.249.15.31:40178" ||urlCheck == "10.249.15.32:40156" || urlCheck == "10.249.15.32:40178" || urlCheck == "170.225.23.128" || urlCheck == "129.41.206.121" || urlCheck == "170.225.21.11") || urlCheck == "www.breakawayfromcancer.com" || urlCheck == "wwwext.amgen.com" || (urlChk2 != "null" && urlChk2 == "breakawayfromcancer" && urlChk2 == "amgen") )
		{
			window.open(localUrl,"NewWindow");
			return false;
		} else {
		 $('a#clicklink').removeAttr('id');
      if($(this).parent(".res_fistcol").length==0){   
        $(this).attr('id', 'clicklink');
	     }
			 event.preventDefault();
			 objpop.css("display","block");
			 objpop.css({"left":popleft,"top":poptop});
             scroll(0,0); 
		}
	} else if (urlFirstPara=="http://www" || urlFirstPara=="https://www" || urlFirstPara=="http://wwwext")
	{
		if ((urlCheck!="10.249.15.31:40178" && urlCheck!="10.249.15.32:40156" && urlCheck!="10.249.15.32:40178" && urlCheck!="170.225.23.128" && urlCheck!="129.41.206.121" && urlCheck!="170.225.21.11") && urlCheck!="www.breakawayfromcancer.com" && urlCheck!="wwwext.amgen.com" )
		{
		 $('a#clicklink').removeAttr('id');
      if($(this).parent(".res_fistcol").length==0){   
        $(this).attr('id', 'clicklink');
	     }
			 event.preventDefault();
			 objpop.css("display","block");
			 objpop.css({"left":popleft,"top":poptop});
             scroll(0,0);  
        }
   } else if (urlFirstPara=="www")
   {
		if ((urlCheck1!="10.249.15.31:40178" && urlCheck1!="10.249.15.32:40156" && urlCheck1!="10.249.15.32:40178" && urlCheck1!="170.225.23.128" && urlCheck1!="129.41.206.121" && urlCheck1!="170.225.21.11") && urlCheck1!="www.breakawayfromcancer.com" && urlCheck1!="wwwext.amgen.com")
		{
		 $('a#clicklink').removeAttr('id');
      if($(this).parent(".res_fistcol").length==0){   
        $(this).attr('id', 'clicklink');
	     }
		    //alert("urlCheck1: "+urlCheck1);
			event.preventDefault();
			objpop.css("display","block");
			objpop.css({"left":popleft,"top":poptop});
			scroll(0,0); 
		}
   } else if ((urlCheck !="10.249.15.31:40178" && urlCheck !="10.249.15.32:40156" && urlCheck !="10.249.15.32:40178" && urlCheck!="170.225.23.128" && urlCheck!="129.41.206.121" && urlCheck!="170.225.21.11") &&  urlChk2 != "null" && urlChk2 != "breakawayfromcancer" && urlChk2 != "amgen" )
   {
    $('a#clicklink').removeAttr('id');
      if($(this).parent(".res_fistcol").length==0){   
        $(this).attr('id', 'clicklink');
	     }
	   	// if your here it means the url doesnt contain www, lets split and find the domain
	    //alert("urlChk2: "+urlChk2);
			event.preventDefault();
			objpop.css("display","block");
			objpop.css({"left":popleft,"top":poptop});
			scroll(0,0); 
	}


   
   $("#continue").live('click',function(){

    window.open(localUrl,"NewWindow");
	 objpop.css("display","none"); 
	return false;
     
   });//end continue click
   
 });//end click
$('.pop_close a span, .orgbtn_mdl a span').click(function(){
  $('.pop_close a, .orgbtn_mdl a').attr('href','#clicklink');
  $('#popup').css('display','none');
  }) 
 
}


//Interstitial Popup ends

//horzAccordian starts
function horzAccordian(obj)
{
	for (i=0;i<=4 ;i++ )
	{  

	  $("#mainCat_"+i+" .catMain").removeClass('up');
	  $("#mainCat_"+i+" .catMain").addClass('down');
	 	$("#mainCatRes_"+i).css("display","none");
	 
	}	
	var tmp= "mainCat_"+obj.charAt(11);
	$("#"+tmp+" .catMain").removeClass('down');
	$("#"+tmp+" .catMain").addClass('up');
	$("#"+obj).slideDown("slow");
}
//horzAccordian ends

function validateCancerType(ctype){
	if(cancerTypes!=null && cancerTypes.length>0){
		for (var i = 0; i < cancerTypes.length; i++){
			if(cancerTypes[i].name.toLowerCase() == ctype.toLowerCase()){
				return false;
			}
		}
		return true;
	} else
		return true;
}

   
  
/*
$(document).ready(function() { 
$("a").click(function() { 
 var link = $(this).attr('href');
 var linktar = $(this).attr('target'); 
 if(linktar!=''){ 
     $('<div>You are currently leaving our site, and headed towards: <br /> '+(link)+' <br /> are you sure you want to proceed?</div>').dialog({
      title: "",
      modal : true,
      overlay: {
        backgroundColor: '#000',
        opacity: 0.5
      },
      buttons: {
        'Yes, Leave breakawycancer.com': function() {
          $(this).dialog('close').remove();
          window.open(link);
        },
        'No, Return to breakawycancer.com': function() {
          $(this).dialog('close').remove();
          return false;
        }
      }
    }); 
      
 } 
  
    return false;

 });  

 }); 
 
  */
  
  /* Fix for IE as String.trim is not implemented
  *  - start
  */
  
  if (!('trim' in String.prototype)) {   
	String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); };    
}
/* --end--*/



