

//
//	Function changeImage
//		-changes the src and hieght of an image to
//
//		IN: imgTag : the image tag to change
//		IN: divTag : sets image height to the height of the div
//		IN: img	: changes the scr of imgTag to this value
//
function changeImage( imgTag, divTag, img )
{
	h = document.getElementById(divTag).offsetHeight-5 + "px";
	document[imgTag].style.height= h; 
	document[imgTag].src= img;                           	
}


//
//	Function opens a new window on click
//
//		IN: url 		- 	new page address
//		IN: name		-	window name
//		IN: w			-  	window width
//		IN: h			-	window height

function wopen(url, name, w, h) 
{
	// Fudge factors for window decoration space.
	 // In my tests these work well on all platforms & browsers.
	w += 32;
	h += 96;
	style = 'width=' + w + ', height=' + h + ', ' + 
			'location=no, menubar=no, ' + 
			'status=no, toolbar=no, scrollbars=no, resizable=no';

	win = window.open(url, name, style );
	win.resizeTo(w, h);
	win.focus();
	return true;
}


//
//	Function opens a window to confirm that the sold
//	action was sucessful.
//
//		IN: myform		- 	the input element that exectuted function
//		IN: url 		- 	new page address
//		IN: name		-	window name
//		IN: w			-  	window width
//		IN: h			-	window height

function confirmSold(myform, url, name, w, h) 
{
	// Fudge factors for window decoration space.
	 // In my tests these work well on all platforms & browsers.
	w += 32;
	h += 96;
	style = 'width=' + w + ', height=' + h + ', ' + 
			'location=no, menubar=no, ' + 
			'status=no, toolbar=no, scrollbars=no, resizable=no';

	// Add sold variable to URL 
	if ( myform.checked )	
		url += '&sold=1';
	else
		url += '&sold=0';
	
	win = window.open(url, name, style );
	win.resizeTo(w, h);
	win.focus();
	
	return true;
}


//
//	Function open a popup window for a form
//
function popupform(myform, windowname)
{
	if (! window.focus)
		return true;
	win = window.open('', windowname, 'height=150,width=400,scrollbars=no, location=no');
	myform.target = windowname;
	win.focus();
	return true;
}

function writeEmail(userid, domain)
{
	document.write(userid+'@'+domain);
	return true;
}

function popupImage(imagename, width, height, windowname) {
	img = new Image();
	img.src = imagename;
	w = 600;
	h = 600;
	
	//Resize window to smaller size
	if( width > w ) {
	   	ratio = width / w;
		width = width / ratio;
		height = height / ratio;
	}
	if( height > h ) {
	   	ratio = height / h;
		width = width / ratio;
		height = height / ratio;
	}	
	
	win = window.open(imagename, windowname, 'height=' + height + ',width=' + width + 
					  ',toolbar=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes');
	
	width  = parseInt(width) + 50;
	height = parseInt(height) + 50;
	win.resizeTo( width, height  );
	//win.moveTo(origLeft,origTop);
	win.focus();
	
	return false;
}
