﻿// JScript File
 
window.onload= AddHover;
//To Add mouse over event to all images
function AddHover()
{
     var wrapper = document.getElementById('ImageWrapper');
     var imgArr = wrapper.getElementsByTagName('img');
     var i=0;
     for(i=0;i<imgArr.length; i++)
     {       
              if(document.getElementById(imgArr[i].id+"_profile")!=null)
              {
                    imgArr[i].onmouseover = function(){ShowRolloverPopUp(this);}
                    imgArr[i].className+=(imgArr[i].className.length>0? " ": "") + "pointer"; 
              }           
     }
  
}
//To Display PopUp block
function ShowRolloverPopUp(ctrl)
{
    var profileBlock = document.getElementById(ctrl.id + "_profile");

    if(profileBlock.style.left=='-9999px'||profileBlock.style.left=='')
    {
       
       var childElements = profileBlock.childNodes;
       var links = profileBlock.getElementsByTagName('a');
       var i=0;      
       var imgPos = FindPosition(ctrl);
       
        HideAllProfilePopup();
        
        //To Add Event to testimonial link
        for(i=0;i<links.length; i++)
        {
            if(links[i].className=='testimonial_link')
                links[i].onclick = function(){profileBlock.style.left='-9999px';ShowTestimonialPopUp(ctrl.id + "_testimonial");};
        }
        profileBlock.onmouseover = function(){ShowProfilePopUp(ctrl.id + "_profile",imgPos[0]-20+'px');}
        if(navigator.appName == 'Microsoft Internet Explorer')
        {
              profileBlock.onmouseleave = function(){HideProfilePopUp(ctrl.id + "_profile");}
        }
        else 
        {
            profileBlock.onmouseout = function(){HideProfilePopUp(ctrl.id + "_profile");}
            for(i=0;i<childElements.length;i++)
            {
                if(typeof(childElements[i].tagName)!='undefined')
                    childElements[i].onmouseout=function(){};
            } 
        }
        
        profileBlock.style.left = (imgPos[0] -20 )+ 'px';
        profileBlock.style.top = (imgPos[1] -20) + 'px';
        profileBlock.style.display = 'block';
    }
} 
//To find the position of the image
function FindPosition(obj)
{
    var curleft = curtop = 0;
    if (obj.offsetParent) {
    do {
	    curleft += obj.offsetLeft;
	    curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
    }
    return [curleft, curtop];    
}
//To Hide the Profile Popup block
function HideAllProfilePopup()
{
      var wrapper = document.getElementById('ImageWrapper');
      var imgArr = wrapper.getElementsByTagName('img');

    for(i=0;i<imgArr.length; i++)
        {
            if(document.getElementById(imgArr[i].id + "_profile")!= null)
            {
                var block =  document.getElementById(imgArr[i].id + "_profile");
                block.style.left = '-9999px';
            }
        }
}
function ShowTestimonialPopUp(blockId)
{
    var testContent= document.getElementById(blockId);
    var spanArr = testContent.getElementsByTagName('span');
    var testWrapper =document.getElementById('TestimonialWrapper');
    var imgWrapper = document.getElementById('ImageWrapper');
    var wrapperPos = FindPosition(imgWrapper);
    
    document.getElementById('TestimonialWrapper').style.left=wrapperPos[0]+'px';
    document.getElementById('TestimonialWrapper').style.top=wrapperPos[1]+8+'px';
    document.getElementById('TestimonialWrapper').style.display = 'block';
    document.getElementById(blockId).style.left= wrapperPos[0] + 70 +'px';
    document.getElementById(blockId).style.top=wrapperPos[1]+38+'px';
    document.getElementById(blockId).style.display = 'block';
     
     window.scroll(wrapperPos[0],wrapperPos[1]+8);
   
     for(i=0;i<spanArr.length; i++)
     {       
        if(spanArr[i].className == 'close')
            spanArr[i].onclick = function(){HideTestimonialPopUp(blockId)};
     }
}
function HideTestimonialPopUp(blockId)
{
    document.getElementById('TestimonialWrapper').style.left='-9999px';
    document.getElementById(blockId).style.left='-9999px';
     
 }
//To Hide the Pop up block
function HideProfilePopUp(blockId)
{
    var imgBlock = document.getElementById(blockId);
        imgBlock.style.left='-9999px';
}
function ShowProfilePopUp(blockId , leftpos)
{
    var imgBlock = document.getElementById(blockId);
        imgBlock.style.left=leftpos;
         imgBlock.style.display = 'block';
}

function PlayVideo()
{

   document.getElementById('displayImg').style.display='none';
   document.getElementById('vedio').style.display='block';
   
    /*document.getElementById('paramobj').value="../../_imgs/HultRedesign/flash/pocketMBA.swf";
    
    if(document.getElementById('embedobj')!=null)
    {
        document.getElementById('embedobj').src="../../_imgs/HultRedesign/flash/pocketMBA.swf";     
    }*/
   

    /* var movie=eval('window.document[\'stmovie\']');

  if (movie)
  {

    if (movie.PercentLoaded())
    {
      if (movie.PercentLoaded()==100)
      {
	alert(movie.IsPlaying());
	movie.Play();
	alert(movie.IsPlaying());

      }
      else
      {
  	    alert("movie is still loading, try again soon");
  	  }
  	}
  	else
  	{
	  alert("movie object found-but unable to send command");  	
  	}

	
  }
  else
  {
    alert("movie object not found");
  }*/
  
  

}
