//INC starts
document.include = function (url)
{
        //alert("common.js"+url);
        if ('undefined' == typeof(url)) return false;
        var p,rnd;
        if (document.all){
        // For IE, create an ActiveX Object instance
        p = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else {
        // For mozilla, create an instance of XMLHttpRequest.
        p = new XMLHttpRequest();
        }
        // Prevent browsers from caching the included page
        // by appending a random  number
        //rnd = Math.random().toString().substring(2);
        //url = url.indexOf('?')>-1 ? url+'&rnd='+rnd : url+'?rnd='+rnd;
        // Open the url and write out the response
        //var proto ="http"+(window.location.protocol.indexOf('https:')==0?'s':'');
        //proto = proto+"://";
        //var host = window.location.host;
        //url=proto+host+"/"+url;
        //alert('Debug Msg : '+ url);
        p.open("GET",url,false);
        p.send("");             
        document.write( p.responseText );
}
//INC ends


//Interstitial Popup starts
function winpopup(pop)
{ 
 $("a").live("click",function(event){
  var curLnk=$(this);
  var localUrl=$(this).attr("href");

  //var localUrl = "www.vectibix.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(urlChk2 == "pi"){
    window.open(localUrl,"NewWindow");
			return false;
  }
  
	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:40080" ||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.vectibix.com" || urlCheck == "wwwext.amgen.com" || (urlChk2 != "null" && urlChk2 == "vectibix" && 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:40080" && 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.vectibix.com"  && urlCheck!="wwwext.amgen.com" && urlCheck!="www.amgenmedinfo.com"   /*//// uncomment "&& urlCheck!="wwwext.amgen.com"  condition as url starting with wwwext doesnt need external link popup alert*/)
		{
		 $('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:40080" && 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.vectibix.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:40080" && 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 != "vectibix" && 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");   
   });//end continue click
   
 });//end click
$('.pop_close span, .orgbtn_mdl a span, .pop_close img, #cancelBtn span').click(function(){
  $('.pop_close a, .orgbtn_mdl a').attr('href','#clicklink');

  $('#popup').css('display','none');
  }) 
 
}


//Interstitial Popup ends


//Text Sizer Start version 1

/*$(function(){
	$('#plus, #minus').click(function(){
		//alert($('#content *').length);
		var ourText = $('#content');
		var currFontSize = $('#content').css('font-size');
		var finalNum = parseFloat(currFontSize, 10);
		var stringEnding = currFontSize.slice(-2);
		if(this.id == 'plus') {
			if(finalNum < 14){
				finalNum += 1;
			}
		}
		else if (this.id == 'minus'){
			if(finalNum > 10){
				finalNum -=1;
			}
		}
		ourText.css('fontSize', finalNum + stringEnding);
	});
});*/



//Text Sizer End


//Text Sizer Start version 2

$(function(){
	$('#userActions #plus, #userActions #minus').click(function(){
		var ourElements = $('#theStuff').children();
		var finalNum = $('#theStuff > p').css('font-size');
		//alert(finalNum);
		if(this.id == 'plus' && finalNum < "14px" ){

			ourElements.each(function(index) {
				//alert(index + ': ' + $(this).text());
				var elemntCurrFontSize = $(this).css('font-size');

				var elemntFinalNum = parseFloat(elemntCurrFontSize, 10);
				var elemntStringEnding = elemntCurrFontSize.slice(-2);
				elemntFinalNum += 1;
				$(this).css('fontSize', elemntFinalNum + elemntStringEnding);

			});

		
		}else if (this.id == 'minus' && finalNum > "10px" ){
			ourElements.each(function(index) {
				//alert(index + ': ' + $(this).text());
				var elemntCurrFontSize = $(this).css('font-size');

				var elemntFinalNum = parseFloat(elemntCurrFontSize, 10);
				var elemntStringEnding = elemntCurrFontSize.slice(-2);
				elemntFinalNum -= 1;
				$(this).css('fontSize', elemntFinalNum + elemntStringEnding);
			});
		}
	});
});



//Text Sizer End
function printFunc(){
	window.print();
}
//common functions called in all pages
$(document).ready(function() {	
	winpopup("popup");
	$('#searchInput').addClass('searchcolor');	

	$('#searchInput').focus(function(){
		$(this).removeClass('searchcolor');
		var searchval = $(this).val();
		if(searchval == 'Search')
		$(this).val('');
	})
	$('#searchInput').blur(function(){
		var searchval = $(this).val();
		if(searchval == '' || searchval == null){  
		$(this).val('Search');
		$(this).addClass('searchcolor');
		}
	})
});

function openPIWindowHome(){
	PIHTMLWindow=window.open("interactiveprescribinginfo/ipi/ipi.html", "PIHTMLWindow", "status=1,toolbar=0, menubar=0,resizable=0,width=1015,height=747");
}
function openPIWindowInner(){
	PIHTMLWindow=window.open("../interactiveprescribinginfo/ipi/ipi.html", "PIHTMLWindow", "status=1,toolbar=0, menubar=0,resizable=0,width=1015,height=747");
}
