﻿// JScript File
var glbFooterPos = 580;
var glbArticleID = 0;
var strCaptureType = "";
var strCaptureSource = "";

function GetSummaryByNodeData(strNodeId,strType) {    
    
    glbArticleID  = strNodeId;          
    if (strType == 1) {             
        ResourcesService.GetDetailsByNode(strNodeId,strType,radTipsSuccess, radTipsFail);
    } else {
        ResourcesService.GetDetailsByNode(strNodeId,strType,radTipsEditSuccess, radTipsFail);
    }
    
}


function radTipsSuccess(e) {

	if (e != null) {
        document.getElementById("videogallery").style.display ="none";  
        document.getElementById("articles1").style.display = "";
        document.getElementById("articles1").innerHTML = "";
	    document.getElementById("articles1").innerHTML = e;
	    
	    //Lead Capture the Article just viewed
	    var strBrowserData = readCookie("MIM_BRowserInfo");
	    	        
	    RunLeadCaptureScripts(strCaptureType,strCaptureSource,glbArticleID, strBrowserData);
	    
	    glbFooterPos = FindAbsolutePosition(document.getElementById("divHdnPosition"));
	    
	    var intPosition = glbFooterPos;
	    //if (intPosition < 544) intPosition  = 544;
	    
	    if (intPosition < 580) intPosition  = 584;
        
        var node= $find("radTrvArticles").get_selectedNode().get_parent().get_value();       
        //alert("node =" + node + ";intPosition=" + intPosition );
        if (node =="H6"  && intPosition  < 600 ) intPosition  = 630 ;
        if (node =="H3"  && intPosition  < 760 ) intPosition  = 760 ;
        if (node =="H5"  && intPosition  < 690) intPosition  = 670 ;
            
        //alert ("glbArticleID=" + glbArticleID + ";" + intPosition);
        
        
        switch (glbArticleID) {
            case "L28":
                if (varBrowser !="IE") {
                    if (intPosition <900) intPosition = 1120;
                }
                break; 
            case "L29":
                if (varBrowser !="IE") {
                    if (intPosition <800) intPosition = 840;
                }
                break;
            case "L30":
                if (varBrowser !="IE") {
                    if (intPosition <700) intPosition = 890;
                }
            
                break;
        }
        
	    //alert("node=" + node + ";glbFooterPos=" + glbFooterPos );
	    //alert("divFW pos=" + FindAbsolutePosition(document.getElementById("divFW")));

        
        intPosition = intPosition + 25;//25 ;
        //alert(intPosition);
        //setTimeout("", "100");
        
        //setTimeout("", "100");
        
        
        //document.getElementById("divPageFooter").style.top=intPosition + "px";
        //document.getElementById("divPageFooter").style.right="0px";
	    
	}    	
}

function radTipsEditSuccess(e) {

	if (e != null) {        
        $find("radEditorTips").set_html(e);
    }    	
}

function radTipsFail(e) {
	
	alert("Error fetching Tips/Resources: " + e);
	
}

function SaveEditorContent(){
    
    var strHTMLContent = $find("radEditorTips").get_html();
    
    strNodeId = document.getElementById ("hidSelectedNode").value;
    alert(strNodeId);
    ResourcesService.UpdateContentByNode(strNodeId,strHTMLContent,radTipsUpdateSuccess, radTipsUpdateFail);
    	    
}

function radTipsUpdateSuccess(e) {
alert(e);
	if (e != null) {        
        //$find("radEditorTips").set_html(e);
    }    	
}

function radTipsUpdateFail(e) {
	
	alert("Error fetching Tips/Resources: " + e);
	
}




