Location: PHPKode > scripts > PHP No Margin Image Pop up Window > php-no-margin-image-pop-up-window/test.php
<?php
## The pop up function for dodo's nmimage popup
function popup($nmdir, $title, $pic, $thumbnail, $des, $fmode = "false") {
global $target;
$target++;

// do you wish to use autocenter script?
$autocenter = 0;  // set to 1 if you want to use it. make sure you put the appropriate
		  // javascript between your <head> and </head> from 
		  //  http://www.dynamicdrive.com/dynamicindex8/autocenter.htm

$size = GetImageSize($pic);
$width = $size[0];
$height = $size[1];
if($thumbnail != "" && $thumbnail != "none") {
	$size = GetImageSize($thumbnail);
	$twidth = $size[0];
	$theight = $size[1];
}

// get function mode
if($fmode != "false") {
$fmode = explode(",", $fmode);
$mode = $fmode[0];
}
	
if($autocenter == 1) {
	echo "<a href=\"#\" onclick=\"NewWindow('nmimage.php?z=$dir$pic&width=$width&height=$height&title=$title','$target','$width','$height','no');return false\" onMouseOver=\"window.status='$title';return true\" onMouseOut=\"window.status='';return true\">";
} else {
	print "\n<A HREF=\"#\" onMouseOver=\"window.status='$title';return true\" onMouseOut=\"window.status='';return true\" onClick=\"window.open('$nmdir";
	print "nmimage.php?z=$dir$pic&width=$width&height=$height&title=$title','$target','width=$width,height=$height,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no,left=0,top=0,screenx=50,screeny=50');return false\">";
}
	if($thumbnail != "" && $thumbnail != "none") {
		if($mode == "highlight") {
			if(!$fmode[1])
				$fmode[1] = "black";
			if(!$fmode[2])
				$fmode[2] = "white";
			print "<img src=\"$thumbnail\" width=\"$twidth\" height=\"$theight\" border=\"0\" class=\"borderimage\" onMouseover=\"borderit(this,'$fmode[1]')\" onMouseout=\"borderit(this,'$fmode[2]')\"></a>";
		} elseif($mode == "shake") {			
			print "<img src=\"$thumbnail\" width=\"$twidth\" height=\"$theight\" border=\"0\" class=\"shakeimage\" onMouseover=\"init(this);rattleimage()\" onMouseout=\"stoprattle(this);top.focus()\" onClick=\"top.focus()\"></a>";
		} elseif($mode == "ghighlight") {	
			if(!$fmode[1])
				$fmode[1] = 50;		
			print "<img src=\"$thumbnail\" width=\"$twidth\" height=\"$theight\" border=\"0\" style=\"filter:alpha(opacity=$fmode[1])\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a>";
		} else {
			print "<img src=\"$thumbnail\" width=\"$twidth\" height=\"$theight\" border=\"0\"></a>";
		}
	} else {
	print "$des</a>";
	}
} // end of function
?>
<!-- HERE COMES THE REGULAR HTML -->
<html>
<head>
<title>Test dodo's nmimage v2.0</title>
<!-- REMOVE BELOW IF YOU DO NOT WANT TO USE AUTOCENTER SCRIPT -->
<!-- ******************************************************* -->
<script language="javascript">

/*
Auto center window script- Eric King (http://redrival.com/eak/index.shtml)
Permission granted to Dynamic Drive to feature script in archive
For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}

</script>
<!-- ****************************** -->
<!-- END OF AUTOCENTER SCRIPT -->



<!-- REMOVE BELOW IF YOU DO NOT WANT TO USE HIGHLIGHT SCRIPT -->
<!-- ******************************************************* -->
<style>
.borderimage{
border:1px solid white; // the regular color
}
</style>
<script language="JavaScript1.2">

/*
Highlight Image Script II- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

function borderit(which,color){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
which.style.borderColor=color
}
}
</script>
<!-- ****************************** -->
<!-- END OF REMOVE HIGHLIGHT SCRIPT -->

<!-- REMOVE BELOW IF YOU DO NOT WANT TO USE SHAKE SCRIPT -->
<!-- *************************************************** -->
<style>
.shakeimage{
position:relative
}
</style>
<script language="JavaScript1.2">

/*
Shake image script (onMouseover)- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

//configure shake degree (where larger # equals greater shake)
var rector=3

///////DONE EDITTING///////////
var stopit=0 
var a=1

function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}

function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}

function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}

</script>
<!-- ************************** -->
<!-- END OF REMOVE SHAKE SCRIPT -->

<!-- REMOVE BELOW IF YOU DO NOT WANT TO USE GRADUAL-HIGHLIGHT SCRIPT -->
<!-- *************************************************************** -->
<script language="JavaScript1.2">

/*
Gradual-Highlight Image Script- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",50)
}
function low(which2){
clearInterval(highlighting)
which2.filters.alpha.opacity=20
}

function highlightit(cur2){
if (cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=5
else if (window.highlighting)
clearInterval(highlighting)
}

</script>
<!-- ************************************** -->
<!-- END OF REMOVE GRADUAL-HIGHLIGHT SCRIPT -->



</head>
<body bgcolor=white text=black>
<!-- calls the function with php tags -->
This is an example with only description: <br>
<?php
## call the function with description
popup("", "picture", "picture.gif", "none", "this is my test picture");
?>
<br>
This an example with a thumbnail but no special effect: <br>
<?
## call the function without highlight
popup("", "picture", "picture.gif", "picturethumbnail.gif", "this is my test picture");
?>
<br>
This is an example with a thumbnail and with highlight: <br>
<?
## call the function with highlight
popup("", "picture", "picture.gif", "picturethumbnail.gif", "this is my test picture", "highlight,red,white");
?>
<br>
This is an example with a thumbnail and with shake: <br>
<?
## call the function with highlight
popup("", "picture", "picture.gif", "picturethumbnail.gif", "this is my test picture", "shake");
?>
<br>
This is an example with a thumbnail and with gradual-highlight: <br>
<?
## call the function with highlight
popup("", "picture", "picture.gif", "picturethumbnail.gif", "this is my test picture", "ghighlight,50");
?>
</body>
</html>
Return current item: PHP No Margin Image Pop up Window