﻿function openPopUp(site)
{
	winurl 		= "./"+site;
	winname 	= "suzuki";
	width 		= 710;
	height 		= 705;

	test = window.open(winurl,winname,"top=50,left=50,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width="+width+",height="+height+",channelmode=0,dependent=0,fullscreen=0");
}

function openWin(site)
{
	winurl 		= "./"+site;
	winname 	= "suzuki";
	width 		= 710;
	height 		= 705;

	test = window.open(winurl,winname,"top=50,left=50,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width="+width+",height="+height+",channelmode=0,dependent=0,fullscreen=0");
}

function openParent(site)
{
	window.opener.location.href = './' + site;
}

function checkSelectForm() {
	select_id=document.getElementById('select_id');
	if(select_id.value==false) {
		alert('Bitte wählen Sie Ihren Standort aus');
		return false;
	}
	return document.multiselect.submit();
}

function checkForm( newWin )
{
	error_bool = 0;
	myForm = document.map24_search;

	// BECAUSE WE DO NO FREESEARCH WE NEED TO CHECK FOLLOWING COMBINATIONS
	// 1. NO ZIP NO CITY NO DEALER => error
	// 2. IF ZIP MIN LEN
	// 3. IF CITY MIN LEN
	// 4. IF DEALER WE NEED ZIP OR CITY

	// CONDITION 1
	if ( myForm['search[dealer]'].value.length == 0 && myForm['search[city]'].value.length == 0 && myForm['search[zip]'].value.length == 0 )
	{
		error_bool = 1;
		error_msg = "Bitte geben Sie einen Händlernamen, eine PLZ oder einen Ort ein.";
	}
	else
	{
		// CONDITION 2
		if ( myForm['search[zip]'].value.length > 0 && myForm['search[zip]'].value.length < 2 )
		{
			error_bool = 1;
			error_msg = "Bitte geben Sie eine PLZ mit mind. 2 Ziffern ein.";
		}

		// CONDITION 3
		if ( myForm['search[city]'].value.length > 0 && myForm['search[city]'].value.length < 3 )
		{
			error_bool = 1;
			error_msg = "Bitte geben Sie einen Ort mit mind. 3 Buchstaben ein.";
		}

		// CONDITION 4
		if ( myForm['search[dealer]'].value.length > 0 && (myForm['search[city]'].value.length == 0 && myForm['search[zip]'].value.length > 0) && (myForm['search[city]'].value.length > 0 && myForm['search[zip]'].value.length == 0) )
		{
			error_bool = 1;
			error_msg = "Bitte geben Sie zusätzlich zum Händlernamen eine PLZ oder einen Ort ein.";
		}
	}

	if ( error_bool )
	{
		alert (error_msg);
		return false;
	}
	else
	{
		if ( newWin == 1 )
		{
			openWin('index.php');
		}
		else
		{
			// location.href='map24.searchresult.php';
			return true;
		}
		return true;
	}
}

function checkStartAddress()
{
	error_bool = 0;
	myForm = document.map24_search;

	// check street: if given min. length of 3 is required
	if ( myForm['search[street]'].value.length > 0 && myForm['search[street]'].value.length < 3 )
	{
		error_bool = 1;
		error_msg = "Bitte geben Sie eine Straße mit mind. 3 Buchstaben ein.";
	}

	// check city: if given min. length of 3 is required
	if ( myForm['search[city]'].value.length > 0 && myForm['search[city]'].value.length < 3 )
	{
		error_bool = 1;
		error_msg = "Bitte geben Sie einen Ort mit mind. 3 Buchstaben ein.";
	}

	// check zip: if given min. length of 2 is required
	if ( myForm['search[zip]'].value.length > 0 && myForm['search[zip]'].value.length < 2 )
	{
		error_bool = 1;
		error_msg = "Bitte geben Sie eine PLZ mit mind. 2 Ziffern ein.";
	}

	// city or zip must be given if no market is given
	if ( myForm['search[zip]'].value.length == 0 && myForm['search[city]'].value.length == 0 )
	{
		error_bool = 1;
		error_msg = "Bitte geben Sie einen Händlernamen, eine PLZ oder einen Ort ein.";
	}


	if ( error_bool )
	{
		alert (error_msg);
		return false;
	}
	else
	{
		return true;
	}
}

function preload()
{
	// alert("Hallo");
	if(document.images)
	{
		imgPath = "http://img.customer.map24.com/suzuki/staticnav/";
		// active images
		back_a = new Image();
		back_a.src = imgPath + "back_a.gif";

		next_a = new Image();
		next_a.src = imgPath + "next_a.gif";

		home_a = new Image();
		home_a.src = imgPath + "home_a.gif";

		zoomin_a = new Image();
		zoomin_a.src = imgPath + "zoomin_a.gif";

		zoomout_a = new Image();
		zoomout_a.src = imgPath + "zoomout_a.gif";

		print_a = new Image();
		print_a.src = imgPath + "print_a.gif";

		// inactive images
		back_ia = new Image();
		back_ia.src = imgPath + "back_ia.gif";

		next_ia = new Image();
		next_ia.src = imgPath + "next_ia.gif";

		home_ia = new Image();
		home_ia.src = imgPath + "home_ia.gif";

		zoomin_ia = new Image();
		zoomin_ia.src = imgPath + "zoomin_ia.gif";

		zoomout_ia = new Image();
		zoomout_ia.src = imgPath + "zoomout_ia.gif";

		print_ia = new Image();
		print_ia.src = imgPath + "print_ia.gif";
	}
}

preload();

function swapImg(imgName,imgState)
{
	if (document.images)
	{
    	document[imgName].src = eval(imgName+"_"+imgState + ".src");
		// document[imgName].src = "http://www.pixelpeter.de/pp_klein.gif";
	}
}
