function popImage(imageURL,imageTitle){
PositionX = 100;
PositionY = 100;
defaultWidth = 60;
defaultHeight = 60;
var AutoClose = true;
var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
if( !imgWin ) { return true; } //popup blockers should not cause errors
imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
'function resizeWinTo() {\n'+
'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
'var oH = document.images[0].height, oW = document.images[0].width;\n'+
'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
'window.doneAlready = true;\n'+ //for Safari and Opera
'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
'}\n'+
'<\/script>'+
'<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+
'<img src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();">'+
(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
imgWin.document.close();
if( imgWin.focus ) { imgWin.focus(); }
return false;
}

function newWindow(url, width, height){
	var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
	var x = parseInt(screen.width / 2.0) - (width / 2.0);
	var y = parseInt(screen.height / 2.0) - (height / 2.0);
	scroll = "yes";
	if (isMSIE) {
		width += 35;
		height += 55;
	}
	var win = window.open(''+url+'', "Receipt", "top=" + y + ",left=" + x + ",scrollbars="+ scroll +",modal=yes,width=" + width + ",height=" + height + ",resizable=no");
	win.document.close();
	win.focus();
}

function copy_address(obj,cnt) {
var fields=new Array("first_name_","surname_","email_","phone_no_","address_","address2_","city_","state_","zip_","text_"); 
for(var i=0;i<fields.length;i++) {
	eval("document.create_account."+fields[i]+cnt+".value = ''");
	}
if(obj.checked == true) {
	var prev = cnt-1;
	for(var i=0;i<fields.length;i++) {
        	eval("document.create_account."+fields[i]+cnt+".value = document.create_account."+fields[i]+prev+".value");
        	}
	// now the state
	//eval("document.create_account.state_"+cnt+".selectedIndex = document.create_account.state_"+prev+".selectedIndex");
	}
}

function inputPage(event, url, pageNumber){
	//if(event.keyCode==13){
	var page = document.getElementById(pageNumber).value;
	window.location.href=url+'/page/'+page;
	//}
}

function change_input_text(display_text, id){
	var get_value = document.getElementById(id).value;
	if(get_value == "" || display_text == ""){
		document.getElementById(id).value = display_text;
		return true;
	}else{
		return false;
	}
}

function change_input_type(new_type, id, display_text, current){
	var parentElem = "p";
	
	try {
		if(change_input_text(display_text, id)){
			document.getElementById(id).type = new_type;
		}else{
			document.getElementById(id).type = "password";	
		}
	} catch(error) {
		document.getElementById(id).type
		
		var textnode = document.createElement("input");
		
		textnode.onblur = function() { change_input_text("Password", id); };
		textnode.onclick = function() { change_input_text("", id); };
		
		if(change_input_text(display_text, id)){
			textnode.type = new_type;
		}else{
			textnode.type = "password";
		}
		textnode.className = "required password";
				
		document.getElementById(parentElem).appendChild(textnode);
		document.getElementById(parentElem).removeChild(current);
		
		
		textnode.id = id;
		textnode.name = id;
		textnode.focus();
	}
}


function display(nr)
{
	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}
