<?php
global $PLUGINS_DIRECTORY, $pref, $tp;
// 2) change the image path to reflect the path of your logo image
$flogo_img = SITEURL . $PLUGINS_DIRECTORY . "floating_logo/logos/" . $tp->toFORM($pref['flogo_logo']);

if (!empty($pref['flogo_link']))
{
    $flogo_image = "<a href=\"" . $pref['flogo_link'] . "\"><img src=\"" . $flogo_img . "\" style=\"width:" . $tp->toFORM($pref['flogo_width']) . ";height:\"+logoheight+\" border=0 title=\"" . $tp->toFORM($pref['flogo_alt']) . "\" alt=\"" . $tp->toFORM($pref['flogo_alt']) . "\"></a>";
}
else
{
    $flogo_image = "<img src=\"" . $flogo_img . "\" style=\"width:" . $tp->toFORM($pref['flogo_width']) . ";height:\"+logoheight+\" border=0 title=\"" . $tp->toFORM($pref['flogo_alt']) . "\" alt=\"" . $tp->toFORM($pref['flogo_alt']) . "\">";
}
$flogo_text .= "<div id=\"watermarklogo\" style=\"position: absolute;\">
<script type=\"text/javascript\">
<!--

///////////////////////////////////////////////////////////////////
/*Site Logo Script (Geocities Watermark)
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions,
100s more DHTML scripts, and TOS, visit http://www.dynamicdrive.com/ */
///////////////////////////////////////////////////////////////////

//edit the below 5 steps

// 1) substitute 116 and 42 with the width and height of your logo image, respectively
var logowidth=" . $tp->toFORM($pref['flogo_width']) . "
var logoheight=" . $tp->toFORM($pref['flogo_height']) . "
var logoimage=new Image(logowidth,logoheight)

// 2) Finally, below variable determines the duration the logo should be visible after loading, in seconds. If youd like the logo to appear for 20 seconds, for example, enter 20. Entering a value of 0 causes the logo to be perpectually visible.
var visibleduration=" . $tp->toFORM($pref['flogo_duration']) . "

// Optional parameters
var Hoffset=" . $tp->toFORM($pref['flogo_Hoffset']) . " //Enter logos offset from right edge of window (edit only if you dont like the default offset)
var Voffset=" . $tp->toFORM($pref['flogo_Voffset']) . " //Enter logos offset from bottom edge of window (edit only if you dont like the default offset)


///////////////////////////Do not edit below this line/////////////////////////

var ie=document.all&&navigator.userAgent.indexOf(\"Opera\")==-1

var watermark_obj=ie? document.all.watermarklogo : document.getElementById? document.getElementById(\"watermarklogo\") : document.watermarklogo

function insertimage()
{
	if (ie||document.getElementById)
		watermark_obj.innerHTML='" . $flogo_image . "'
	else if (document.layers)
	{
		watermark_obj.document.write('" . $flogo_image . "')
		watermark_obj.document.close()
	}
}";
switch ($pref['flogo_location'])
{
    case "cn":
        $flogo_text .= "function positionit()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
    	//Non-IE viz a proper browser
    	var window_width = window.innerWidth-20
		var window_height = window.innerHeight
		var dsocleft=pageXOffset
		var dsoctop = pageYOffset
  	}
	else if	(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
    	var dsocleft=ie? document.documentElement.scrollLeft : pageXOffset
		var dsoctop=ie? document.documentElement.scrollTop : pageYOffset
		var window_width=document.documentElement.clientWidth
		var window_height=document.documentElement.clientHeight
  	}
	else if	(document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
    	//IE 4 compatible
    	var dsocleft=document.body.scrollLeft
		var dsoctop=idocument.body.scrollTop
		var window_width=document.body.clientWidth
		var window_height=document.body.clientHeight
  	}
	if (ie||document.getElementById)
	{

		var wmleft=parseInt(dsocleft)+(parseInt(window_width)/2)-(logowidth/2)
		watermark_obj.style.left=wmleft+\"px\"
		var wmtop=parseInt(dsoctop)+(parseInt(window_height)/2)-(logoheight/2)
		watermark_obj.style.top=wmtop+\"px\"
	}
	else if (document.layers)
	{
		watermark_obj.left=dsocleft+(window_width/2)-(logowidth/2)
		watermark_obj.top=dsoctop+(window_height/2)-(logoheight/2)
	}
}";
        break;
    case "ur":
        $flogo_text .= "function positionit()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
    	//Non-IE viz a proper browser

    	var window_width = window.innerWidth-20
		var window_height = window.innerHeight
		var dsocleft=pageXOffset
		var dsoctop = pageYOffset
  	}
	else if	(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
    	var dsocleft=ie? document.documentElement.scrollLeft : pageXOffset
		var dsoctop=ie? document.documentElement.scrollTop : pageYOffset
		var window_width=document.documentElement.clientWidth
		var window_height=document.documentElement.clientHeight
  	}
	else if	(document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
    	//IE 4 compatible
    	var dsocleft=document.body.scrollLeft
		var dsoctop=idocument.body.scrollTop
		var window_width=document.body.clientWidth
		var window_height=document.body.clientHeight
  	}
	if (ie||document.getElementById)
	{

		var wmleft=parseInt(dsocleft)+parseInt(window_width)-logowidth-Hoffset
		watermark_obj.style.left=wmleft+\"px\"
		var wmtop=parseInt(dsoctop)+Voffset
		watermark_obj.style.top=wmtop+\"px\"

	}
	else if (document.layers)
	{
		watermark_obj.left=dsocleft+window_width-Hoffset-logowidth
		watermark_obj.top=dsoctop+Voffset
	}
}";
        break;

    case "ul":
        $flogo_text .= "function positionit()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
    	//Non-IE viz a proper browser
    	var window_width = window.innerWidth-20
		var window_height = window.innerHeight
		var dsocleft=pageXOffset
		var dsoctop = pageYOffset
  	}
	else if	(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
    	var dsocleft=ie? document.documentElement.scrollLeft : pageXOffset
		var dsoctop=ie? document.documentElement.scrollTop : pageYOffset
		var window_width=document.documentElement.clientWidth
		var window_height=document.documentElement.clientHeight
  	}
	else if	(document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
    	//IE 4 compatible
    	var dsocleft=document.body.scrollLeft
		var dsoctop=idocument.body.scrollTop
		var window_width=document.body.clientWidth
		var window_height=document.body.clientHeight
  	}
	if (ie||document.getElementById)
	{

		var wmleft=parseInt(dsocleft) + Hoffset
		watermark_obj.style.left=wmleft+\"px\"

		var wmtop=parseInt(dsoctop)+Voffset
		watermark_obj.style.top=wmtop+\"px\"
	}
	else if (document.layers)
	{
		watermark_obj.left=dsocleft+Hoffset
		watermark_obj.top=dsoctop+Voffset
	}
}";
        break;
    case "ll":
        $flogo_text .= "function positionit()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
    	//Non-IE viz a proper browser
    	var window_width = window.innerWidth-20
		var window_height = window.innerHeight
		var dsocleft=pageXOffset
		var dsoctop = pageYOffset
  	}
	else if	(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
    	var dsocleft=ie? document.documentElement.scrollLeft : pageXOffset
		var dsoctop=ie? document.documentElement.scrollTop : pageYOffset
		var window_width=document.documentElement.clientWidth
		var window_height=document.documentElement.clientHeight
  	}
	else if	(document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
    	//IE 4 compatible
    	var dsocleft=document.body.scrollLeft
		var dsoctop=idocument.body.scrollTop
		var window_width=document.body.clientWidth
		var window_height=document.body.clientHeight
  	}
	if (ie||document.getElementById)
	{
		var wmleft=parseInt(dsocleft) + Hoffset
		watermark_obj.style.left=wmleft+\"px\"
		var wmtop=parseInt(dsoctop)+parseInt(window_height)-logoheight-Voffset
		watermark_obj.style.top=wmtop+\"px\"
	}
	else if (document.layers)
	{
		watermark_obj.left=dsocleft+Hoffset
		watermark_obj.top=dsoctop+window_height-logoheight-Voffset
	}
}";
        break;
    default :
    case "lr":
        $flogo_text .= "function positionit()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
    	//Non-IE viz a proper browser
    	var window_width = window.innerWidth-20
		var window_height = window.innerHeight
		var dsocleft=pageXOffset
		var dsoctop = pageYOffset
  	}
	else if	(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
    	var dsocleft=ie? document.documentElement.scrollLeft : pageXOffset
		var dsoctop=ie? document.documentElement.scrollTop : pageYOffset
		var window_width=document.documentElement.clientWidth
		var window_height=document.documentElement.clientHeight
  	}
	else if	(document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
    	//IE 4 compatible
    	var dsocleft=document.body.scrollLeft
		var dsoctop=idocument.body.scrollTop
		var window_width=document.body.clientWidth
		var window_height=document.body.clientHeight
  	}
	if (ie||document.getElementById)
	{
		var wmleft=parseInt(dsocleft)+parseInt(window_width)-logowidth-Hoffset
		watermark_obj.style.left=wmleft+\"px\"
		var wmtop=parseInt(dsoctop)+parseInt(window_height)-logoheight-Voffset
		watermark_obj.style.top=wmtop+\"px\"
	}
	else if (document.layers)
	{
		watermark_obj.left=dsocleft+window_width-Hoffset-logowidth
		watermark_obj.top=dsoctop+window_height-logoheight-Voffset
	}
}";
        break;
}

$flogo_text .= "
function hidewatermark()
{
	if (document.layers)
		watermark_obj.visibility=\"hide\"
	else
		watermark_obj.style.visibility=\"hidden\"
	clearInterval(watermarkinterval)
}

function beingwatermark()
{
	var wmshowtime = watermarkinterval=setInterval(\"positionit()\",50)
	insertimage()
	if (visibleduration!=0)
		var wmtime = setTimeout(\"hidewatermark()\",visibleduration*1000)
}

if (ie||document.getElementById||document.layers)
//window.onload=beingwatermark
beingwatermark()
-->
</script>";
print $flogo_text;

?>