function openGalery(img)
{
    var image= GetImageString(img);
    var galeryPath = "images/camps/";
    openPopup(galeryPath + image,0,0);
}

function openSingleGalery(img)
{
    var image= img;
    var galeryPath = "images/camps/";
    openSinglePopup(galeryPath + image,0,0);
}

function openGalery(img,imageCount)
{
    var image= GetImageString(img);
    var galeryPath = "images/camps/";
    openPopup(galeryPath + image + "|" + imageCount,0,0);
    
}

function openGaleryByDimension(img,height,width)
{
    var image= GetImageString(img);
    var galeryPath = "images/camps/";
	openPopup(galeryPath + image,width,height);	
}

function openPopup(url,width,height)
{
	var wincont;
	if(width == 0)
	    width = 600;
	    
	if(height == 0)
	    height = 500;
	    	    
	var breite = width;
	var hoehe = height;
	var xpos = screen.width/2-breite/2;
	var ypos = screen.height/2-hoehe/2;
	wincont = window.open("details.htm?" + url,'Detail','scrollbars=0,noresize,menubar=no,width='+breite+',height='+hoehe+',left='+xpos+',top='+ypos+'');
	//wincont = window.open(url,'Detail','scrollbars=0,noresize,menubar=no,width='+breite+',height='+hoehe+',left='+xpos+',top='+ypos+'');
	wincont.focus();
}

function openSinglePopup(url,width,height)
{
	var wincont;
	if(width == 0)
	    width = 600;
	    
	if(height == 0)
	    height = 500;
	    	    
	var breite = width;
	var hoehe = height;
	var xpos = screen.width/2-breite/2;
	var ypos = screen.height/2-hoehe/2;
	wincont = window.open("details_single.htm?" + url,'Detail','scrollbars=0,noresize,menubar=no,width='+breite+',height='+hoehe+',left='+xpos+',top='+ypos+'');
	//wincont = window.open(url,'Detail','scrollbars=0,noresize,menubar=no,width='+breite+',height='+hoehe+',left='+xpos+',top='+ypos+'');
	wincont.focus();
}

function openAGBPopup(url,width,height)
{
	var wincont;
	if(width == 0)
	    width = 600;
	    
	if(height == 0)
	    height = 500;
	    	    
	var breite = width;
	var hoehe = height;
	var xpos = screen.width/2-breite/2;
	var ypos = screen.height/2-hoehe/2;
	wincont = window.open(url,'AGB','scrollbars=1,noresize,menubar=no,width='+breite+',height='+hoehe+',left='+xpos+',top='+ypos+'');
	//wincont = window.open(url,'Detail','scrollbars=0,noresize,menubar=no,width='+breite+',height='+hoehe+',left='+xpos+',top='+ypos+'');
	wincont.focus();
}

var newwindow;
function flashpopup(url)
{
	newwindow=window.open(url,'name','height=360,width=480,resizable=no,toolbar=no,location=no,status=no,menubar=no,screenX=240,screenY=320,left=240,top=320');
	if (window.focus) {newwindow.focus()}
}

function GetImageString(img)
{	
	var imageBase = "{campID}_galerie_gross_{imageID}";
	var comp = img.split("_");
	var myImage = "";
	var campID = comp[0].substring(comp[0].lastIndexOf("/")+1);
	myImage = imageBase.replace("{imageID}", comp[3]);
	myImage = myImage.replace("{campID}", campID);
	return myImage
}

function GetImageIndexMax()
{
    var img = window.location.search;
    if (img != "")
    {
        var tmp = img.substring(1);
        tmp = tmp.substring(tmp.lastIndexOf("|"));                       
        return tmp.substring(1);    
    }
    else
        return "";
}

function GetImageIndex()
{
    var img = window.location.search;
	var comp = img.split("_");
	var tmp = comp[3].substring(0,3);
	tmp = tmp.replace("00","");
	tmp = tmp.replace("0","");
	return parseInt(tmp);	
}

function GetImageBase()
{
    var img = window.location.search;
	var comp = img.split("_");
	return img.replace(comp[3].substring(0,3),"{0}");
}

function GetPreviousImage()
{
    var i = GetImageIndex();    
    if( i > 1)
    {
        i--;
        if  (i == undefined) {return "null";}
        if (i == 0) {return "null";}
        return (i > 9)? "0"+ i : "00" + i;
    }
}

function GetNextImage()
{   
    var i = GetImageIndex();   
    var index = parseInt(GetImageIndexMax());
    //alert((i > 9)? "0"+ i : "00" + i);
    if( i <= index)
    {
        i++;                
        if (i > index) {return "null";}        
        return (i > 9)? "0"+ i : "00" + i;
        
    }
}

function GetImageFromUrl()
{   
    var img = window.location.search;
    if (img != "")
    {
        var tmp = img.substring(1);
        tmp = tmp.substring(tmp.lastIndexOf("|"));               
        img = img.replace(tmp,"");
        return img.substring(1);    
    }
    else
        return "";
}

function doformcheck()
{
	if(document.form1.gender.value=='NA')
	{
		alert("Bitte prüfe deine Adressangaben auf Vollständigkeit");
		document.form1.gender.focus();
		return false;
	}
	if(document.form1.surname.value=='')
	{
		alert("Bitte prüfe deine Adressangaben auf Vollständigkeit");
		document.form1.surname.focus();
		return false;
	}
	if(document.form1.forename.value=='')
	{
		alert("Bitte prüfe deine Adressangaben auf Vollständigkeit");
		document.form1.forename.focus();
		return false;
	}
	if(document.form1.birthday.value=='')
	{
		alert("Bitte prüfe deine Adressangaben auf Vollständigkeit");
		document.form1.birthday.focus();
		return false;
	}
	
	if(document.form1.street.value=='')
	{
		alert("Bitte prüfe deine Adressangaben auf Vollständigkeit");
		document.form1.street.focus();
		return false;
	}
	if(document.form1.plz.value=='')
	{
		alert("Bitte prüfe deine Adressangaben auf Vollständigkeit");
		document.form1.plz.focus();
		return false;
	}
	if(document.form1.city.value=='')
	{
		alert("Bitte prüfe deine Adressangaben auf Vollständigkeit");
		document.form1.city.focus();
		return false;
	}
	if(document.form1.land.value=='')
	{
		alert("Bitte prüfe deine Adressangaben auf Vollständigkeit");
		document.form1.land.focus();
		return false;
	}
	if(document.form1.phone.value=='')
	{
		alert("Bitte prüfe deine Adressangaben auf Vollständigkeit");
		document.form1.phone.focus();
		return false;
	}
	if(document.form1.mail.value=='')
	{
		alert("Bitte prüfe deine Adressangaben auf Vollständigkeit");
		document.form1.mail.focus();
		return false;
	}
	
	//if(document.form1.course.value=='0;NA')
	//{
	//	alert("Bitte wähle einen Kurs aus");
	//	document.form1.course.focus();
	//	return false;
	//}
	
	if(document.form1.agb_bluejuice.checked==false)
	{
		alert("Du musst die AGB von BLUE JUICE Camps akzeptieren");
		document.form1.agb_bluejuice.focus();
		return false;
	}
	if(document.form1.agb_surfcamp.checked==false)
	{
		alert("Du musst die AGB des Surf Camps akzeptieren");
		document.form1.agb_surfcamp.focus();
		return false;
	}
	if(document.form1.privacy.checked==false)
	{
		alert("Du musst die Datenschutzbestimmungen akzeptieren");
		document.form1.privacy.focus();
		return false;
	}
	return true;
}