﻿function disablePaste(e){

    var pressedKey;

    if(window.event) // IE
    {
    pressedKey = String.fromCharCode(e.keyCode).toLowerCase();
          if (e.ctrlKey && pressedKey == "v") {
            e.returnValue = false;
          }
    }
    else if(e.which) // Netscape/Firefox/Opera
    { 
        
    }
}

function rightclickcheck(keyp){ 
    if (navigator.appName == "Netscape" && keyp.which == 3){return false; } 
    if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) {alert("Please type your E-mail Address");return false; } 
} 

function change(id, newClass) 
{
    identity=document.getElementById(id);
    identity.className=newClass;
}

function bookmarksite(url){
    var title = "Crohn's Online";
    if (document.all){
        window.external.AddFavorite(url, title);
    }
    else if (window.sidebar){
        window.sidebar.addPanel(title, url, "")
    }
}

function MM_openBrWindow_(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openDisclaimer(url) {
	MM_openBrWindow_( applicationRoot + '/Leaving.aspx?url=' + url,'winDisclaimer','width=370,height=342');
}

function goToRequested(url) {
    window.open(url, "_newWin", 'toolbar,menubar,scrollbars,resizable,location');    
    window.close();
}

 function on_tip(evt,val) {
	var offX = 20;	// how far from mouse to show tip
	var offY = 2;

    var posx = 0;
    var posy = 0;
    if (!evt) var evt = window.event;
    if (evt.pageX || evt.pageY)
    {
        posx = evt.pageX;
        posy = evt.pageY;
    }
    else if (evt.clientX || evt.clientY)
    {
        posx = evt.clientX;
        posy = evt.clientY;
    }


	var txtDiv = document.getElementById("TP"+val);

	document.getElementById("innerDIV").innerHTML = txtDiv.innerHTML;
	var tmpDiv = document.getElementById("TmpDIV");

	posy += offY + document.body.scrollTop;
	posx += offX + document.body.scrollLeft;

    
	tmpDiv.style.top = posy + "px";
	tmpDiv.style.left = posx + "px";
	tmpDiv.style.visibility = "visible";

}

function off_tip(evt,val) {
  document.getElementById("innerDIV").innerHTML = '';
  document.getElementById("TmpDIV").style.visibility='hidden';
}

function showFact() {
    var question = "";
    var counter = 0;
    var score = 0;
    for (i=2;i<7;i++)
    {
        for (j=0;j<2;j++)
        {
            question = "ctl00_ContentPlaceHolder1_Q" + i + "_" + j;            
            if (document.getElementById(question).checked)
            {   
                document.getElementById("r" + i).style.color="green";
                document.getElementById("w" + i).style.color="red";
                
                if (document.getElementById(question).value == "r")
                {                           
                    document.getElementById("r" + i).style.display="block";
                    document.getElementById("w" + i).style.display="none";
                    score = score + 1;                                                                   
                }
                if (document.getElementById(question).value == "w")
                {
                    document.getElementById("r" + i).style.display="none";
                    document.getElementById("w" + i).style.display="block";
                }    
                counter = counter +1;
                document.getElementById("Fact" + i).style.display="block";
                document.getElementById("ctl00_ContentPlaceHolder1_Q" + i + "_" + (j+1)%2).disabled = true;                  
            }
        }    
    }
      if (counter==5)
        alert("Your score is "+score);
}       

function MM_openBrWindow_(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openBio(id){
	MM_openBrWindow_( applicationRoot + '/Living_with_Crohns/Bios/' + id,'Bio','scrollbars=yes,resizable=no,width=630,height=516');
}

function openTranscript(){
	MM_openBrWindow_( applicationRoot + '/Living_with_Crohns/Transcripts/' + episodeId + '.aspx','Transcript','scrollbars=yes,resizable=no,width=630,height=516');
}

function openVidTranscript(id){
	MM_openBrWindow_( applicationRoot + '/About/Transcripts/' + id, 'Transcript','scrollbars=yes,resizable=no,width=630,height=516');
}

function doFlashClose()
	{	    
		var t = getFlashMovieObject("castPlayer");
		t.SetVariable("pageState","onClose");
		
	}
	//
	function getFlashMovieObject(movieName)
	{
	  if (window.document[movieName]) 
	  {
		  return window.document[movieName];
	  }
	  if (navigator.appName.indexOf("Microsoft Internet")==-1)
	  {
		if (document.embeds && document.embeds[movieName])
		  return document.embeds[movieName]; 
	  }
	  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
	  {
		return document.getElementById(movieName);
	  }
	}
