﻿var 	targetObject , URL,ResultListDiv,loc,  CurValue , Ratio , scorp , objinnerDiv , WindowTitle;
var 	targetObject , URL,ResultDiv, coords, CurValue;

function ShowZoomDescription(pID, obj, pType)
{
var url;

url = 'getDescription.aspx?id=' + pID + '&type=' + pType + '&r=' + Math.floor(Math.random() * 10000001); 


WindowTitle ="Description";
loc = WindowSize();
CreateListDiv(loc);


new Ajax.Request(url, 
		{ method: 'get',   
			onSuccess: function(transport) 
			{ 
			
				ResultListDiv.className = 'ResultListDiv';
				ResultListDiv.innerHTML = makewindow(transport.responseText);
				objinnerDiv = document.getElementById("innerdiv"); 				
				CurValue =0;	
				
				ZoomIt();
			}	 
		}
		
	); 


return false;

}


function ShowDescription(pID, obj, pType)
{
var url;

url = 'getDescription.aspx?id=' + pID + '&type=' + pType + '&r=' + Math.floor(Math.random() * 10000001); 


WindowTitle ="Description";
targetObject =obj; 

coords = GetCoordinates(targetObject);
CreateDiv(coords);


new Ajax.Request(url, 
		{ method: 'get',   
			onSuccess: function(transport) 
			{ 
				ResultDiv.innerHTML =  transport.responseText;
				ResultDiv.className = 'ResultDiv';
				CurValue =0;			
				ShowResultWithEffect();
			}	 
		}
		
	); 


return false;

}


function ShowDescriptionWindow(pID, obj, pType)
{
var url;

url = 'getDescription.aspx?id=' + pID + '&type=' + pType + '&r=' + Math.floor(Math.random() * 10000001); 


WindowTitle =obj.innerHTML;
targetObject =obj; 

coords = GetCoordinates(targetObject);

CreateWindowDiv(coords);


new Ajax.Request(url, 
		{ method: 'get',   
			onSuccess: function(transport) 
			{ 
				//ResultListDiv.className = 'ResultWDiv';
				ResultListDiv.innerHTML = makewindow(transport.responseText);
				objinnerDiv = document.getElementById("innerdiv");
			    ExpandWindowEffect();
			}	 
		}
		
	); 


return false;

}



function CreateDiv(coords)
{
	


	if (ResultDiv != null)
		document.body.removeChild(ResultDiv);
		
	coordinates = coords.split(",");
	ResultDiv = document.createElement ("DIV"); 
	ResultDiv.id= "ResultDivID";		



	ResultDiv.style.left= parseInt(coordinates[0])  + 10 ;
	ResultDiv.style.top=  parseInt(coordinates[1]) + targetObject.offsetHeight+ 15;
	ResultDiv.innerHTML =  '<img src="Ajax/35.gif" width="66" height="66">';
	ResultDiv.className = 'ResultWait';
	document.body.appendChild(ResultDiv);			


}

function ShowResultWithEffect()
{

ResultDiv.style.filter ="filter: alpha(opacity=" + CurValue + ");";



if (CurValue < 100)
setTimeout ( "ShowResultWithEffect()", 50 );

CurValue =  CurValue +10;



}





function makewindow(strData)
{
	var strwindow;

	strwindow = '<table width="100%"  height="100%" border="0" cellspacing="0" cellpadding="0">';
	strwindow += ' <tr>' ;
	strwindow += '  <td  class="ResultListDivHeading"  bgcolor="#18799C">' + WindowTitle + '</td>' ;
	strwindow += '  <td  height="21" bgcolor="#18799C" align="right"><img src="Ajax/close2.gif" width="18" height="18" onClick="CloseListDiv()" border="1" style="cursor: hand ;border-color:#18799C;	 "></td>' ;
	strwindow += ' </tr>' ;
	strwindow += ' <tr>' ;
	strwindow += '  <td colspan="2"  >' ;
	strwindow += ' 	<div id="innerdiv" style="overflow:scroll;height:100%;width:100%">' ;
	strwindow += strData ;
	strwindow += '  </div>' ;
	strwindow += ' 	</td>' ;
	strwindow += ' </tr>' ;
	strwindow += '</table>' ;
	
	
	return strwindow;	
}





function ZoomIt()
{

	var tmpSl , tmpSt , tmpSw , tmpSh;
	tmpSl = parseInt(ResultListDiv.style.left) - 24 ;
	tmpSt = (tmpSl * Ratio) +  parseInt(scorp[1])  ;
	
	
	tmpSw =  parseInt(ResultListDiv.style.width) + 48;	
	tmpSh =  tmpSw  * Ratio;	

	ResultListDiv.style.left = tmpSl;
	ResultListDiv.style.top  = tmpSt ;
	ResultListDiv.style.width = tmpSw ;	
	ResultListDiv.style.height = tmpSh;	
	
	ResultListDiv.style.filter ="filter: alpha(opacity=" + CurValue + ");";

	

	


if (tmpSw < 500  ) 
	setTimeout ( "ZoomIt()", 3 );
else
	objinnerDiv.style.height = tmpSh - 22;

CurValue =  CurValue +50
}


function CreateListDiv(coords)
{
	


	if (ResultListDiv != null)
		document.body.removeChild(ResultListDiv);
	
	
	var location = coords.split(",");
	var scor =  ScrollingPosition();
	scorp = scor.split(",");
	

	Ratio	= parseInt(location[1]) / parseInt(location[0]) ;

	ResultListDiv = document.createElement ("DIV"); 
	ResultListDiv.id= "ResultListDivID";		
	ResultListDiv.style.left= (parseInt(location[0]) / 2) + parseInt(scorp[0]) ;
	ResultListDiv.style.top=  (parseInt(location[1]) /2 ) + parseInt(scorp[1])  ;
	ResultListDiv.style.width=  66;	
	ResultListDiv.style.height=  66;		
	ResultListDiv.innerHTML =  '<img src="Ajax\\35.gif" width="66" height="66">';
	ResultListDiv.className = 'ResultListDiv';
	document.body.appendChild(ResultListDiv);			


}


function CreateWindowDiv(coords)
{
	


	if (ResultListDiv != null)
		document.body.removeChild(ResultListDiv);
	
	
	var location = coords.split(",");

	coordinates = coords.split(",");




	ResultListDiv = document.createElement ("DIV"); 
	ResultListDiv.id= "ResultListDivID";		
	ResultListDiv.className = 'ResultWDiv';
	ResultListDiv.style.left=  parseInt(coordinates[0]) -2 ;  // - 238 
	ResultListDiv.style.top=  parseInt(coordinates[1]) -3;// - 3 ;
	ResultListDiv.style.width=  100;	
	ResultListDiv.style.height=  100;		
	ResultListDiv.innerHTML =  '<img src="Ajax\\35.gif" width="66" height="66">';
	
	document.body.appendChild(ResultListDiv);			


}


function ExpandWindowEffect()
{

	var tmpSl , tmpSt , tmpSw , tmpSh;


	
	tmpSw =  parseInt(ResultListDiv.style.width) + 11;	
	tmpSh =  parseInt(ResultListDiv.style.height) + 9;

	ResultListDiv.style.width = tmpSw ;	
	ResultListDiv.style.height = tmpSh;	
	



if (tmpSw < 286  ) 
	setTimeout ( "ExpandWindowEffect()", 3 );
else
{
	ResultListDiv.style.width=  286;	
	ResultListDiv.style.height=  261;	
}


}





function CloseListDiv()
{

	if (ResultListDiv != null)
	{
		ResultListDiv.className = 'hide';
		document.body.removeChild(ResultListDiv);
		ResultListDiv = null;
	}
}

function WindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
 

 
 
  return   myWidth  + ',' + myHeight;
  
  
}


function ScrollingPosition()
{
	
	         var scrOfX = 0, scrOfY = 0;
        var X = 0, Y = 0;		
		
		  if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		  }
 
 
 

	return  scrOfX + ',' + scrOfY;
	
}




function GetCoordinates(objItem){
        var scrOfX = 0, scrOfY = 0;
        var X = 0, Y = 0;		
		
		  if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		  }
		  //-----------------
		

			X = getLeft(objItem); //- scrOfX;
			Y = getTop(objItem); //- scrOfY;			
	
	
			return  X + ','	 + Y;
		
		
	}


function getLeft (objItem) {

    var oNode = objItem;
    var iLeft = 0;

    while(oNode.tagName != "BODY") {
        iLeft += oNode.offsetLeft;
        oNode = oNode.offsetParent; 
    }

    return iLeft;
}


function getTop  (objItem) {

    var oNode = objItem;
    var iTop = 0;

    while(oNode.tagName != "BODY") {
        iTop += oNode.offsetTop;
        oNode = oNode.offsetParent; 
    }

    return iTop;

}



function Hide()
{

	if (ResultDiv != null)
	{
		ResultDiv.className = 'hide';
		//document.body.removeChild(ResultDiv);
		//ResultDiv = null;
	}
}





