// Free for any type of use so long as original notice remains unchanged.
// Report errors to feedback@ashishware.com
//Copyrights 2006, Ashish Patil , ashishware.com
//////////////////////////////////////////////////////////////////////////
var imagetype = "";
var videotype = "";
function getWindowWidth()
{
	return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
}


function getposOffset(overlay, offsettype){
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent; 
	}
	return totaloffset;
}


function ToolTip(id,isAnimated,aniSpeed)
{
	
	var isInit = -1;
  var div,divWidth,divHeight;
  var xincr=10,yincr=10;
  var animateToolTip =false;
  var html;
  
  function Init(id)
  {
   div = document.getElementById(id);
  // alert(div);
   if(div==null) return;
   
   if((div.style.width=="" || div.style.height==""))
   {alert("Both width and height must be set");
   return;}
   
   divWidth = parseInt(div.style.width);
   divHeight= parseInt(div.style.height);
   if(div.style.overflow!="hidden")div.style.overflow="hidden";
   if(div.style.display!="none")div.style.display="none";
   if(div.style.position!="absolute")div.style.position="absolute";
   
   if(isAnimated && aniSpeed>0)
   {xincr = parseInt(divWidth/aniSpeed);
    yincr = parseInt(divHeight/aniSpeed);
    animateToolTip = true;
	
    }
   isInit++; 
   
  }
  
    
  this.Show =  function(e,strHTML)
  {
	  
	var type;
	//var image_popup;
	var speakerheadingctrl = "hidspeakerheading" +strHTML ;
	var speakerheading     = document.getElementById(speakerheadingctrl).value;
	
	var speakernamectrl = "hidspeakername" +strHTML ;
	var speakername     = document.getElementById(speakernamectrl).value;
	
	var speakernameurlctrl = "hidspeakernameurl" +strHTML ;
	var speakernameurl     = document.getElementById(speakernameurlctrl).value;

	
	var speakerimagectrl = "hidspeakerimage" +strHTML ;
	var speakerimage     = document.getElementById(speakerimagectrl).value;
	var speakerdescctrl = "hidspeakerdesc" +strHTML ;
	var speakerdesc     = document.getElementById(speakerdescctrl).value;
	var imagetypectrl = "hidspeakerimagetype" +strHTML ;
	imagetype     = document.getElementById(imagetypectrl).value;
	var videotypectrl = "hidspeakervideo" +strHTML ;
	videotype     = document.getElementById(videotypectrl).value;
	//alert(newtitle);
	//alert(newdesc);
	//alert(newimage);
	//type = newimage.split("#");
	//alert(newdesc);
	/*if(type[1] == "image")
	{
		image_popup = '<img src="images/main_'+type[0]+'" alt='+newtitle.replace("#"," ")+' title='+newtitle.replace("#"," ")+' />';
	}else{
		image_popup = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="192" height="160" id="playVideo" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="true" /><param name="movie" value="playVideo.swf?movie_name = http://pro-motivate.com/v1/images/'+type[0]+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="playVideo.swf?movie_name = http://pro-motivate.com/v1/images/'+type[0]+'" allowfullscreen="true" quality="high" bgcolor="#ffffff" width="192" height="160" name="playVideo" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	}*/
	//alert(image_popup);
     if(isInit<0) return;
    
    var newPosx,newPosy,height,width;
    if(typeof( document.documentElement.clientWidth ) == 'number' ){
    width = document.body.clientWidth;
    height = document.body.clientHeight;}
    else
    {
    width = parseInt(window.innerWidth);
    height = parseInt(window.innerHeight);
    
    }
    var curPosx = (e.x)?parseInt(e.x):parseInt(e.clientX);
    var curPosy = (e.y)?parseInt(e.y):parseInt(e.clientY);
	//alert(imagetype);
	var newhtml = '<div class="popupOverall"><div class="popupTop"><div class="close" title="Close"> <a style="cursor:pointer" onclick = t1.Hide(event)>Close</a> X</div></div><div class="popupContent"><div class="popup"><div class="popup-left"><div class="video" id="speaker_uploads">'+speakerimage+'</div><div class="gotoprofile"><a href="http://www.pro-motivate.com/'+speakernameurl+'/speaker_profile" title="Go to Profile"><img src="GotoProfile.gif" alt="Go to Profile" title="Go to Profile" width="75" height="17" border="0" /></a></div></div><div class="popup-right"><div class="popup-right-heading"><a href="http://www.pro-motivate.com/'+speakernameurl+'/speaker_profile" title="Go to Profile">'+speakername+'</a></div><h2>'+speakerheading+'</h2><p>'+speakerdesc+'</p></div></div></div><div class="popupBottom">&nbsp;</div></div>';
	//strHTML = newhtml;
	//document.getElementById("txtcomment").value = strHTML;
    if(newhtml!=null)
    {html = newhtml;
     div.innerHTML=newhtml;
 	 }   
   

	var curobj=document.getElementById(strHTML);		
	var browserName = navigator.appName;
	/*if (browserName=="Microsoft Internet Explorer") {
		xpos= curobj.clientWidth;
		ypos= curobj.clientHeight;

	}else {*/
		/*var xpos= curobj.offsetLeft;
		var ypos= curobj.offsetTop;*/
	var posarray = Array();
	var posarray = findPosition(curobj);

	 var xpos  = posarray[0];
  	 var ypos = posarray[1];
	 
	/*}
	
	
	//alert("x="+xpos+" y="+ypos);
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body

	var dsocleft=document.all? iebody.scrollLeft : pageXOffset
	var dsoctop=document.all? iebody.scrollTop : pageYOffset*/
	 
	
	
	div.style.display='block';
	div.style.top= ypos + "px";
    div.style.left= xpos+ "px";
	

    div.focus();
    if(animateToolTip){
    div.style.height= "0px";
    div.style.width= "0px";
    ToolTip.animate(div.id,divHeight,divWidth);}

	 


	
	/*if(imagetype == "video"){
		//speakerimage = videotype;
		//alert(speakerimage);
		//document.getElementById("speaker_uploads").innerHTML = videotype
		//showpopup();
	}*/	
    }

    	

	
   this.Hide= function(e)
    {div.style.display='none';
    if(!animateToolTip)return;
    div.style.height= "0px";
    div.style.width= "0px";
	}
    
   this.SetHTML = function(strHTML)
   {html = strHTML;
    div.innerHTML=html;} 
    
    ToolTip.animate = function(a,iHeight,iWidth)
  { a = document.getElementById(a);
         
   var i = parseInt(a.style.width)+xincr ;
   var j = parseInt(a.style.height)+yincr;  
   
   if(i <= iWidth)
   {a.style.width = i+"px";}
   else
   {a.style.width = iWidth+"px";}
   
   if(j <= iHeight)
   {a.style.height = j+"px";}
   else
   {a.style.height = iHeight+"px";}
   
    if(!((i > iWidth) && (j > iHeight)))  {     
   		setTimeout( "ToolTip.animate('"+a.id+"',"+iHeight+","+iWidth+")",1);
    } else {
		if(imagetype == "video"){
		 //speaker_uploads = videotype;
		 //setTimeout( "showpopup("+videotype+")",1000);
		 showpopup(videotype);
	   } 	
	}
	 
    }   
   Init(id);
   
}

function findPosition( oElement ) {
  if( typeof( oElement.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
      posX += oElement.offsetLeft;
      posY += oElement.offsetTop;
    }
    return [ posX, posY ];
  } else {
    return [ oElement.x, oElement.y ];
  }
  
}
function showpopup(videotype)
{
document.getElementById("speaker_uploads").innerHTML = videotype;
}

