﻿

function HideShowTDleftSideNav()
{
    if(document.getElementById('tdleftSideNav').style.display == 'none')
    {
        document.getElementById('tdleftSideNav').style.display='block';
        document.getElementById('tdLeftSideNavExpanded').style.display='none';
       
        //  This is for E-Learning page to expand and contract the Iframe. In the future, It would be better to convert all the pdfs to HTML and remove the Iframe
        if(document.getElementById('pdfELearningIframe') != null)
        {
            document.getElementById('pdfELearningIframe').width='760px';
        }

    }
    else
    {
        document.getElementById('tdLeftSideNavExpanded').style.display='block';  
        document.getElementById('tdleftSideNav').style.display='none';
              
        
        //  This is for E-Learning page to expand and contract the Iframe. In the future, It would be better to convert all the pdfs to HTML and remove the Iframe
        if(document.getElementById('pdfELearningIframe') != null)
        {
            document.getElementById('pdfELearningIframe').width='980px';
        }
    }
}

function HideShowSubMenuItems(tdId)
{
    if(document.getElementById(tdId) != null)
    {
        if(document.getElementById(tdId).style.display == 'none')
        {
            document.getElementById(tdId).style.display = '';
        }
        else
        {
            document.getElementById(tdId).style.display = 'none';
        }
    }    
}

function LoadIframe(iframeId,page)
{
    if(iframeId == null || page == null)
        return;
    
    if(document.getElementById(iframeId) != null)
    {
        document.getElementById(iframeId).src = page;        
    }    
}
function LoadFlashChart(swfFile,xmlFileName,divId,x,y)
{	
	var chart = new FusionCharts(swfFile, "ChartId", x, y, "0", "0");
    chart.setDataURL(xmlFileName);		   
	chart.render(divId);
}

function LoadMultipleFlashCharts(swfFile1,swfFile2,xmlFileName1,xmlFileName2,divId1,divId2,x1,x2,y1,y2)
{	
	var chart = new FusionCharts(swfFile1, "ChartId", x1, y1, "0", "0");
    chart.setDataURL(xmlFileName1);		   
	chart.render(divId1);
	
	if(document.getElementById(divId2) != null)
    {
        document.getElementById(divId2).style.visibility = 'visible';
	    var chart2 = new FusionCharts(swfFile2, "ChartId", x2, y2, "0", "0");
        chart2.setDataURL(xmlFileName2);		   
	    chart2.render(divId2);
	}
}

function SwitchAccordianImage(tagId,colapseImage, expandImage)
{
    var imageTag = document.getElementById(tagId);
    if(imageTag != null)
    {   
        if(imageTag.src.indexOf(colapseImage) != -1)
            imageTag.src = "Images/" + expandImage;
        else
            imageTag.src = "Images/" + colapseImage;
    }
}

function ShowPriceVolumeChart (xmlPrice, xmlVolume)
{
    if(xmlPrice != null)
	{ 
		var chart = new FusionCharts("Flash/Line.swf", "ChartPriceId", "730", "250", "0", "1");	    
		chart.setDataXML(xmlPrice);	
		chart.render("ChartPrice")
	}	
	
	
	if(xmlVolume != null)
	{
		var chart2 = new FusionCharts("Flash/barchart.swf", "ChartVolumeId", "730", "250", "0", "1");
		chart2.setDataXML(xmlVolume);
		chart2.render("ChartVolume");	
	}
}

function ShowPriceVolumeChart2(xmlPrice, xmlVolume) {
    if (xmlPrice != null) {
        var chart = new FusionCharts("Flash/Line.swf", "ChartPriceId", "730", "250", "0", "1");
        chart.setDataXML(xmlPrice);
        chart.render("ChartPrice")
    }


    if (xmlVolume != null) {
        var chart2 = new FusionCharts("Flash/Column2D.swf", "ChartVolumeId", "730", "250", "0", "1");
        chart2.setDataXML(xmlVolume);
        chart2.render("ChartVolume");
    }
}

function ShowPriceVolumeChart3(xmlPrice, xmlVolume) {
    if (xmlPrice != null) {
        var chart = new FusionCharts("../Flash/Line.swf", "ChartPriceId", "730", "250", "0", "1");
        chart.setDataXML(xmlPrice);
        chart.render("ChartPrice")
    }


    if (xmlVolume != null) {
        var chart2 = new FusionCharts("../Flash/Column2D.swf", "ChartVolumeId", "730", "250", "0", "1");
        chart2.setDataXML(xmlVolume);
        chart2.render("ChartVolume");
    }
}

function ShowVolumeChart1(xmlVolume) 
{
    if (xmlVolume != null)
     {
         var chart2 = new FusionCharts("http://www.stockresearchportal.com/Flash/barchart.swf", "ChartVolumeId", "730", "250", "0", "1");
        chart2.setDataXML(xmlVolume);
        chart2.render("ChartVolume");        
     }
}

function ShowPriceChart1(xmlPrice)
 {
     if (xmlPrice != null) 
    {
        var chart = new FusionCharts("http://www.stockresearchportal.com/Flash/Line.swf", "ChartPriceId", "730", "250", "0", "1");
        chart.setDataXML(xmlPrice);
        chart.render("ChartPrice")
    }
}

function ShowVolumeChart2(xmlVolume) {
    if (xmlVolume != null) {
        var chart2 = new FusionCharts("http://www.stockresearchportal.com/Flash/barchart.swf", "ChartVolumeId", "630", "250", "0", "1");
        chart2.setDataXML(xmlVolume);
        chart2.render("ChartVolume");
    }
}

function ShowPriceChart2(xmlPrice) {
    if (xmlPrice != null) {
        var chart = new FusionCharts("http://www.stockresearchportal.com/Flash/Line.swf", "ChartPriceId", "630", "250", "0", "1");
        chart.setDataXML(xmlPrice);
        chart.render("ChartPrice")
    }
}



function PopUp(url, width, height, scroll) 
{
    window.open(url, '_blank', 'width='+width+',height='+height+',scrollbars='+scroll);
}

function roll_over(img_name, img_src) {
    
    document.images[img_name].src = img_src;
}

function ImageButtonServerControlRollOver(controlName, img_src) {

    var serverControlImageButton = document.getElementById(controlName)

    if (serverControlImageButton != null) {
        serverControlImageButton.src = img_src;
    }
}

function SubscribeAlert(m) {
    alert("Links to " + m + " are available only to subscribers of StockResearchPortal.com. To Sign up, please click on the Subscription icon");
}

function ShowTab1() 
{
    if (document.getElementById("tdTab2") != null)
     {       
            document.getElementById("tdTab2").style.display = 'none';
     }
     if (document.getElementById("tdTab1") != null)
     {       
            document.getElementById("tdTab1").style.display = '';
     }

 }

 function ShowTab2() {
     
     if (document.getElementById("tdTab1") != null) {
         document.getElementById("tdTab1").style.display = 'none';
     }
     
     if (document.getElementById("tdTab3") != null) {
         document.getElementById("tdTab3").style.display = 'none';
     }

     if (document.getElementById("tdTab2") != null) {
         document.getElementById("tdTab2").style.display = '';
     }
 }

 function ShowTab3() {

     if (document.getElementById("tdTab1") != null) {
         document.getElementById("tdTab1").style.display = 'none';
     }

     if (document.getElementById("tdTab2") != null) {
         document.getElementById("tdTab2").style.display = 'none';
     }

     if (document.getElementById("tdTab3") != null) {
         document.getElementById("tdTab3").style.display = '';
     }
 }


 function RadioOnOff(id)
 {
     if (id == "radioPurchased") 
     {
         if (document.getElementById("tablePurchased") != null) 
         {
             document.getElementById("tablePurchased").style.display = '';
         }

         if (document.getElementById("tableSold") != null) {
             document.getElementById("tableSold").style.display = 'none';
         }
     }
     else if (id == "radioSold") 
     {
         if (document.getElementById("tableSold") != null) {
             document.getElementById("tableSold").style.display = '';
         }

         if (document.getElementById("tablePurchased") != null) {
             document.getElementById("tablePurchased").style.display = 'none';
         }
     }

 }

 function sI(currImg, currState) {
     if (currState == 'on') {
         document.getElementById(currImg).src = 'images/' + currImg + '_on.jpg';
     } else {
         document.getElementById(currImg).src = 'images/' + currImg + '_off.jpg';
     }
 }

 function ImageOffOn(tagId, offImage, onImage) {
     var imageTag = document.getElementById(tagId);
     if (imageTag != null) {
         if (imageTag.src.indexOf(offImage) != -1)
             imageTag.src = onImage;
         else
             imageTag.src = offImage;
     }
 }

 function imageRotater() {
     //Set Default State of each portfolio piece
     $(".paging").show();
     $(".paging a:first").addClass("active");

     //Get size of images, how many there are, then determin the size of the image reel.
     var imageWidth = $(".window").width();
     var imageSum = $(".image_reel img").size();
     var imageReelWidth = imageWidth * imageSum;

     //Adjust the image reel to its new size
     $(".image_reel").css({ 'width': imageReelWidth });

     //Paging + Slider Function
     rotate = function() {
         var triggerID = $active.attr("rel") - 1; //Get number of times to slide
         var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

         $(".paging a").removeClass('active'); //Remove all active class
         $active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)

         //Slider Animation
         $(".image_reel").animate({
             left: -image_reelPosition
         }, 500);

     };

     //Rotation + Timing Event
     rotateSwitch = function() {
         play = setInterval(function() { //Set timer - this will repeat itself every 3 seconds
             $active = $('.paging a.active').next();
             if ($active.length === 0) { //If paging reaches the end...
                 $active = $('.paging a:first'); //go back to first
             }
             rotate(); //Trigger the paging and slider function
         }, 7000); //Timer speed in milliseconds (3 seconds)
     };

     rotateSwitch(); //Run function on launch

     //On Hover
     $(".image_reel a").hover(function() {
         clearInterval(play); //Stop the rotation
     }, function() {
         rotateSwitch(); //Resume rotation
     });

     //On Click
     $(".paging a").click(function() {
         $active = $(this); //Activate the clicked paging
         //Reset Timer
         clearInterval(play); //Stop the rotation
         rotate(); //Trigger rotation immediately
         rotateSwitch(); // Resume rotation
         return false; //Prevent browser jump to link anchor
     });
 }
