this.onload = function() {
	Init();
}

// var Init_Array_ColorPicked = new Array();
function Init() {
	aaa = "";
	spmap_i = document.getElementById("spmap");
	if(spmap_i !== null) {
		spmap_i = spmap_i.childNodes;
		for(c_i = 1; c_i < spmap_i.length; c_i++) {
			spmap_i[c_i].onmousemove = function() {
					eval(this.id); // Klappt leider nicht (tmp_i ist leer beim Aufruf)
			}
			aaa += spmap_i[c_i].id;
		}
		document.getElementById("Feed").options[1].selected = true;
		document.getElementById("Feed").onchange();
		document.getElementById("Quantity").options[4].selected = true;
		document.getElementById("Quantity").onchange();
		document.getElementById("manWidth").value = "200";
		document.getElementById("manWidth").onkeyup();
		document.getElementById("showLogo").checked = true;
		document.getElementById("showLogo").onchange();
//		DoSetup(2, '#000000');
//		DoSetup(4, '#FF0000');
//		DoSetup(6, '#FF0000');
//		DoSetup(8, '#FF0000');
//		DoSetup(9, '#FF0000');
		document.getElementById("showTeaser").checked = false;
		document.getElementById("showTeaser").onchange();
		DoSetup(0, '');
	}
}

var EAS_ccv_element;
function ColorPicked(color_cp) {
	EAS_ccv_element = document.getElementById("current_color_value");
	c_cp = document.getElementById("current_color");
	if(color_cp.length > 0) {
		EAS_ccv_element.value = "#" + color_cp;
	} else {
		EAS_ccv_element.value = "";
	}
	c_cp.style.backgroundColor = EAS_ccv_element.value;
}

var EAS_ccv_destination_element;
function DestinationSelected(object_ds) {
	EAS_ccv_destination_element = document.getElementById(object_ds);
}

function RouteClick(object_rc, idx_rc) {
	r_rc = document.getElementsByName(object_rc);
	r_rc[idx_rc].onclick();
// Hier muss noch das Knöpfhcen gesetzt werden (OPTIK)
}

function ColorSelected(message_cs) {
	if(typeof(EAS_ccv_destination_element) !== 'undefined') {
		EAS_ccv_destination_element.value = EAS_ccv_element.value;	
		EAS_ccv_destination_element.style.backgroundColor = EAS_ccv_destination_element.value;
		BuildColorArray(EAS_ccv_destination_element.id + "=" + encodeURIComponent(EAS_ccv_destination_element.value));
	} else {
		alert(message_cs);
	}
}

function SetFeedName(value_sfn) {
	BuildColorArray("FeedName=" + value_sfn);
}

function SetFeedQty(value_sfq) {
	BuildColorArray("Anzahl=" + value_sfq);
}

function SetFeedSize(value_sfs) {
	tmp_w_sfs = value_sfs.substring(0, value_sfs.indexOf("x"));
	SetFeedWidth(tmp_w_sfs);
	tmp_h_sfs = value_sfs.substring(1 + value_sfs.indexOf("x"));
	SetFeedHeight(tmp_h_sfs);
}

function SetFeedWidth(value_sfw) {
	BuildColorArray("Breite=" + value_sfw);	
	document.getElementById("manWidth").value = value_sfw;
}

function SetFeedHeight(value_sfh) {
		BuildColorArray("Hoehe=" + value_sfh);
}

function TermBoolean(value_tb) {
	if(value_tb === true)
		tmp_tb = "on";
	else
		tmp_tb = "";
	return tmp_tb;
}

function SetFeedLogo(value_sfl) {
	BuildColorArray("Logo=" + TermBoolean(value_sfl));	
}

function SetFeedTitel(value_sft) {
	BuildColorArray("TickerTitel=" + TermBoolean(value_sft));
}

function SetFeedTeaser(value_sft) {
	BuildColorArray("Teaser=" + TermBoolean(value_sft));
}

var ColorArray = new Array();
function BuildColorArray(value_bca) {
	tmp_bca = new Array();
	replaced_bca = false;
	for(i_bca = 0; i_bca < ColorArray.length; i_bca++) {
		if(ColorArray[i_bca].substring(0, ColorArray[i_bca].indexOf("=")) === value_bca.substring(0, value_bca.indexOf("="))) {
			new_bca = value_bca;
			replaced_bca = true;
		} else {
			new_bca = ColorArray[i_bca];
		}
		tmp_bca[i_bca] = new_bca;
	}
	if(!replaced_bca) {
		tmp_bca[tmp_bca.length] = value_bca;
	}
	ColorArray = tmp_bca;
	ReloadTicker();
}

function ReloadTicker() {
	tmp_code_rt = "/layout/inc/elements/newsticker/render/preview.php";
	tmp_view_rt = tmp_code_rt + "?ViewTicker";
	tmp_code_rt += "?ViewCode";
	tmp_parms = "";
	for (ac_rt = 0; ac_rt < ColorArray.length; ac_rt++) {
		tmp_parms += "&" + ColorArray[ac_rt];
	}
	tmp_code_rt += tmp_parms;
	tmp_view_rt += tmp_parms;
	document.getElementById("TickerPreviewTicker").src = tmp_view_rt;
	document.getElementById("TickerPreviewCode").src = tmp_code_rt;
}

function selectAll(object_sa) {
	tmp_sa = document.getElementById(object_sa);
	tmp_sa.select();
}

function copyToClipBoard(object_ctcb) {
	tmp_ctcb = document.getElementById(object_ctcb);
	tmp_ctcb.focus();
	tmp_ctcb.select();
	if (document.all) {
		therange=tmp_ctcb.createTextRange();
		therange.execCommand("Copy");
		window.status="Der Code wurde in die Zwischenablage kopiert.";
		alert("Der Code wurde in die Zwischenablage kopiert.");
		setTimeout("window.status=''",1800);
	}
}	

function DoSetup(elNo, colNo) {
	ColorPicked(colNo.substring(1));
	RouteClick('setup', elNo);
	ColorSelected('');
}

