var m_win = (navigator.appVersion.indexOf("Win") != -1);
var m_selected = [];
var m_kategorie;
var m_color1;
var m_color2;
var m_special;
//m_win = false;

function refresh() {
	var rgb1 = 0;
	var rgb2 = 0;
	var special = 0;
	
	if(m_color1) {
		values = m_selected[m_color1].split(",");
		rgb1 = values[1];
		file1 = values[2];
		self.parent.contentleft.image1.location.href ="openfile.php?id="+file1+"&part=data";
	}
		
	if(m_color2) {
		values = m_selected[m_color2].split(",");
		rgb2 = values[1];
		file2 = values[2];
		self.parent.contentleft.image2.location.href ="openfile.php?id="+file2+"&part=data";
	}
	
	if(m_special) {
		special = m_selected[m_special];
	}	
	
	var flashLiveConnect = m_win ? self.parent.contentleft.preview.document.getElementById("flashpreview") : false;
	
	if(flashLiveConnect) {		
		if(m_color1)flashLiveConnect.SetVariable("usercolor1", rgb1);
		if(m_color2)flashLiveConnect.SetVariable("usercolor2", rgb2);
		if(m_special)flashLiveConnect.SetVariable("special", special);
		flashLiveConnect.SetVariable("refresh", 1);
	} else {
		if(m_color1) {
			self.parent.contentleft.preview.location.href ="flashpreview.html?usercolor1="+rgb1+"&usercolor2="+rgb2+"&special="+special+"&kategorie="+m_kategorie;
		}
	}
}

function get_value(name) {
	var control = eval("document.myform."+name);
	return control.value;
}

function optionclick(value) {
	if(m_special) {
		//if(value != m_selected[m_special] ) {
			m_selected[m_special] = value;
			refresh();
		//}	
	}
	
}

function select_onclick(control) {
	var value = get_value(control);
	m_selected[control] = value;
	refresh();
}

function init(kategorie,coloroption1,coloroption2, special) {
	m_kategorie = kategorie;
	m_color1 = coloroption1;
	m_color2 = coloroption2;
	m_special = special;

	if(m_color1)m_selected[m_color1] = get_value(m_color1);
	if(m_color2)m_selected[m_color2] = get_value(m_color2);
	if(m_special)m_selected[m_special] = 1;
	
	//refresh();
}
function popup(href, width, height) {
	//_left = (window.width - width) / 2;
	//_top = (window.height - height) / 2;
	_left = 0;
	_top = 0;
	//alert(_left+","+_top);
	MyWindow=window.open(href,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left='+_left+',top='+_top+',width='+width+',height='+height);
}
