a_matno  = new Array();
a_cadurl = new Array();
a_huburl = new Array();
a_etkurl = new Array();
a_cfgurl = new Array();

s_ShopUrl = 'choose_country.cfm';
s_CADUrl  = '';
s_CFGUrl  = '';
s_ConfiguratorURL = '';

var MatNo = 'null';

var http_request = false;

function clickMatNo(sMatNo)
{
	MatNo = sMatNo;

	var length = a_matno.length - 1;

	s_CADUrl = '';
	s_ETKUrl = '';
	s_CFGUrl = '';

	for (var index=1; index<=length; index++)
	{
		if ( a_matno[index] == sMatNo )
		{
			s_CADUrl = a_cadurl[index];
			s_ETKUrl = a_etkurl[index];
			s_CFGUrl = a_cfgurl[index];
			break;
		}
	}

	if ( !s_CADUrl || s_CADUrl == '' )
	{
		if ( !s_ETKUrl || s_ETKUrl == '' )
		{
			if ( !s_CFGUrl || s_CFGUrl == '' )
				showMenu(window.menu1);
			else
				showMenu(window.menu5);
		}
		else
		{
			if ( !s_CFGUrl || s_CFGUrl == '' )
				showMenu(window.menu3);
			else
				showMenu(window.menu7);
		}
	}
	else
	{
		if ( !s_ETKUrl || s_ETKUrl == '' )
		{
			if ( !s_CFGUrl || s_CFGUrl == '' )
				showMenu(window.menu2);
			else
				showMenu(window.menu6);
		}
		else
		{
			if ( !s_CFGUrl || s_CFGUrl == '' )
				showMenu(window.menu4);
			else
				showMenu(window.menu8);
		}
	}
}

function OpenLink (column)
{
	var linkcorr = a_linkurl[column-1].replace(/amp;/g,"");

	// unschöne Lösung, aber wie es halt bei unvorhersehbaren plötzlichen Kundenwünschen so ist
	// sollen selbstverständlich auch Mails über Linkeinträge generiert werden können...
	// Also:

	//if (linkcorr.search('mailto:') != -1)
	//	window.location = linkcorr;
	//else
	//	OpenURLInNewWindow( "", linkcorr, "", "", "", "", "yes", "", "", "yes", "", "");

	// und jetzt gibt's statt Links Download (bei denen sich kein weiteres Fenster öffnen soll)
	// also grundsätzlich:
	window.location = linkcorr;
}

function gotoPage (pageid)
{
	var urlparam = window.location.search;
	var url_corr = urlparam.replace(/[p,P]age[i,I][d,D]=[c,i,m,p,g]\d+/g, "PageID="+pageid);

	try
	{
		var url_page = urlparam.replace(/.*pageid=/i, "");
		url_page = url_page.replace(/&.*/i, "");

		var url_hist = urlparam.replace(/.*vhist=/i, "");
		url_hist = url_hist.replace(/&.*/i, "");

		var url_newh = url_hist + "," + url_page;

		var url_corr2 = url_corr.replace(url_hist,url_newh);

		window.location.search = url_corr2;
	}
	catch (e)
	{
		window.location.search = url_corr;
	}
}

function OpenConfigurator (column)
{
	s_ConfiguratorURL = a_confurl[column-1];
	var linkcorr = s_ConfiguratorURL.replace(/amp;/g,"");

	if ( s_ConfiguratorURL.search('ModelcodeSelection') != -1 )
		location.href = linkcorr ;
	else
		OpenURLInNewWindow( "", linkcorr, "800", "600", "", "", "yes", "", "", "yes", "", "");
}

function OpenCADGenerator (column)
{
	s_CadURL = a_cadgenurl[column-1];

	// Da Firefox aus welchen Gründen auch immer mit dem "&amp;" nicht klar kommt,
	// wird's einfach durch ein "&" ersetzt.
	var linkcorr = s_CadURL.replace(/amp;/g,"");

	// Mit dem Durchmesserzeichen gibt's auch ein Problem, deshalb nach "Anweisung" von Fredrik Östvik:
	var linkcorr2 = linkcorr.replace(/v10=\W/,"v10=%D8");

	// beim Hüpfen in einen eigenen Configurator in diesem Fenster bleiben
	if ( s_CadURL.search('CallConfigurator.cfm') != -1 )
		location.href = linkcorr2 ;
	else
		OpenURLInNewWindowUTF8( "", linkcorr2, "800", "600", "", "", "yes", "", "", "yes", "", "");

}

function showBigImage(sUrl,sID)
{
	if ( sID )
		var newurl = "../ShowBigImage.cfm?id=" + sID + "&picture=" + sUrl;
	else
		var newurl = sUrl;

	OpenURLInNewWindow( "", newurl, "640", "480", "", "", "yes", "", "", "no", "", "");
}

function HighlightMatNo(search_matno)
{
	var length = a_matno.length - 1;
	var regexp = new RegExp(search_matno, "i");

	if (search_matno.length != 0)
		for (var index=1; index<=length; index++)
			if ( regexp.test(a_matno[index]) )
				if (document.getElementById(a_matno[index]) != null)
					document.getElementById(a_matno[index]).style.backgroundColor = '#BBD86B';
}

