var popWin = null; 
var winCount = 0;
var winName = "popWin";

function openPopWin(winURL, winWidth, winHeight, winFeatures)
{
	winName = "popWin" + winCount++;
	closePopWin();
	if (openPopWin.arguments.length == 4)
	{
		winFeatures = "," + winFeatures;
	}
	else
	{
		winFeatures = "";
	}
	popWin = window.open(winURL, winName, "width=" + winWidth + ",height=" + winHeight + winFeatures);  
}
  
function closePopWin()
{    
  if (navigator.appName != "Microsoft Internet Explorer" || parseInt(navigator.appVersion) >=4)
  if(popWin != null) if(!popWin.closed) 
  popWin.close();   
}

function validate_gb_form() 
{
	var okSoFar=true;
	with ( $('gb_form') )
	{
		var foundAt = email.value.indexOf("@",0);
		if (foundAt < 1 && okSoFar)
		{
			okSoFar = false;
			alert ("Bitte geben Sie eine gueltige Email-Adresse ein!");
			email.focus();
		}
		if (name.value=="" && okSoFar)
		{
			okSoFar=false;
			alert("Bitte geben Sie Ihren Namen ein!");
			name.focus();
		}
		if (comment.value=="" && okSoFar)
		{
			okSoFar=false;
			alert("Bitte geben Sie Ihren Kommentar ein!");
			comment.focus();
		}
		if (result.value=="" && okSoFar)
		{
			okSoFar	=	false;
			alert("Bitte geben Sie das Resultat der Rechnung ein!");
			result.focus();
		}
	   if (okSoFar==true)
		{
		   return true;
		   //submit();
	   }
	   else
	   {
		  return false;
	   }
	}
}

function get_photo(nr)
{
	new Ajax.Updater('img_cont',
	'inc/pic.php?nr=' + nr,
	{
		method: 'get',
		onComplete: function()
		{
			//var lb_h = $('lightbox_img').getHeight();
			//$('lightbox').setStyle({ height: lb_h });
		}
	});
}

function handle_img_change(img)
{
	var browser;
	var img_path;
	
	browser		=	navigator.appName;
	
	switch(browser)
	{
		case "Microsoft Internet Explorer":
			img_path	=	'img/cd_' + img + '_gr.jpg'
			break;
		default:
			img_path	=	'img/cd_' + img + '_gr.jpg';
	}
	
	// Bild auswechseln
	$('lightbox_img').src	=	img_path;
	
	// Groesse der Lightbox setzen
	var lb_w				=	$('lightbox_img').getWidth() + 'px';
	$('lightbox').setStyle({ width: lb_w });
	$('lightbox_footer').setStyle({ width: lb_w });;

	return false;
}


