﻿// JS for the specialists pages


jQuery(document).ready(function() { var MOt = setTimeout("addMouseOvers()", 100); });
var infoHover = false; //bool to stop info box from hiding when you hover on it 

function addMouseOvers() {
    jQuery('.DrBtn')
     .hover(function(e) {
         DrInfoDiv('show', jQuery(this).attr("DrKey"), e.pageX, e.pageY);
     }, function() {
         DrInfoDiv('hide');
     })
    ;
}
function DrInfoDiv(toggle, DrID, posX, posY) {


    jQuery('#DrInfoDisp').hover(function() { infoHover = true }, function() {
        infoHover = false;
        jQuery("#DrInfoDisp")
       .css("display", "none");
    });
    if (toggle == 'show') {

        jQuery("#DrInfoDisp")
      .html(getDrInfo(DrID))
        //.css("display","block")
      .css("top", (posY - 200) + "px")
      .css("left", posX + "px")
      .fadeIn(400)
      ;
    } else {
        hovOutT = setTimeout("hideDrInfo()", 1);
    }
}
function hideDrInfo() {
    if (!infoHover) {
        jQuery("#DrInfoDisp")
            .css("display", "none")
            ;
    }
}

function getDrInfo(docID) {
    // I have made a bit of a mess in the function as I was just exploring JQuery methods. Ignore the commented code I only left it as I might come back to  play around with it.

    var retStr = "";
    //var reXstr = "/^(\x3C\x3Fxml[\x20-\x7E]{1,}\x3F\x3E[\x20-\x7E]{0,}\x3Cstring[\x20-\x7E]{1,}\x3E)([\x20-\x7E]{1,})/m";
    //var cheatReX = new RegExp(reXstr);
    var drXML;
    drXML = jQuery.ajax({
        type: "POST",
        url: "../XML/IVFservice.asmx/Get_SpecialistTxt",
        data: "SpecialistId=" + docID,
        dataType: "xml",
        async: false
    });
    var XMLdoc = drXML.responseXML.documentElement;
    //var xResStr = drXML.responseText;
    try {
        retStr = "<h1>" + jQuery(XMLdoc).find("DrInfoName").text() + "</h1>";
        retStr += jQuery(XMLdoc).find("DrInfoTxt").text();
    }
    catch (ex) { }
    //alert(retStr);

    //alert(drXML.responseXML.getElementsByTagName("string")[0].nodeValue);

    return retStr; //getElementsByTagName("DrInfoTxt")[0].childNodes[0].nodeValue;//.getElementsByTagName("string")[0].childNodes[0].nodeValue;
    //return drInfoStr;
}



/*jQuery(document).ready(addMouseOvers());

function addMouseOvers(){

jQuery("input.DrClass")
var docID = jQuery(this).attr("title");
.hover(function(){
DrInfoDiv('show',docID);
},function(){
DrInfoDiv('hide',docID);
}) 
;
}
function DrInfoDiv(toggle,DrID){
//jQuery("body").append('<div class='DrInfoDiv'>'+ getDrInfo(DrID) +'</div>')
if(toggle=='show'){
jQuery("#DrInfoDisp").text(getDrInfo(DrID))
.css("display","block")
;
}else{
jQuery("#DrInfoDisp").text(getDrInfo(DrID))
.css("display","none")
;
}
}
function getDrInfo(docID){
var drInfoStr = "This is a test string for DrID" + docID;
return drInfoStr;
}*/

