function fenster(datei) {
	////alert(datei);
   x = (screen.width/2)-(1024/2);
   y = (screen.height/2)-(768/2);
   win=window.open(datei,"","width=1024,height=768,status = no,toolbar = no,menubar = no,location = no,resizable = yes,titlebar = yes,scrollbars=yes,fullscreen = no,top ="+y+",left ="+x);
}
function give_var(){
	document.getElementById('varcheck').value='67reuab7flar3';
}

function change_pass(mysession){
	logged = document.getElementById("whoareyou").innerHTML;
	logged = logged.split(" ");
	logegd = logged.reverse();
	if(logged[0] != "Gast"){
		window.open("./module/change_pass.php?PHPSESSID=" + mysession);
	}
	else{
		document.getElementById("passmessage").innerHTML = "Bitte erst anmelden!";
	}
}

function add_smily(short_cut){
	top.document.getElementById("id_tlk_gti77").value += short_cut;
}
function check_user(){
	myname = document.getElementById("deinname").value;
	mypass = document.getElementById("deinpasswort").value;
	document.getElementById("deinname").value = "";
	document.getElementById("deinpasswort").value = "";
	document.getElementById("passmessage").innerHTML = "&nbsp;";
	document.getElementById("whoareyou").innerHTML = "Du bist angemeldet als<br>Gast";
	get_modul("./module/check_user.ajax.php?deinname=" + myname + "&deinpasswort=" + mypass)
	//?deinname=" + myname + "&deinpasswort=" + mypass
}

function parent_check(){
	if(!top.frames[0]){
		location.href="index.htm";
	}
}

function mark_sets(checkstate){
	checkstate = parseInt(checkstate);
	for(t=0; t<=99; t++){
		if(document.getElementById("check_" + t)){
			document.getElementById("check_"+ t).checked = checkstate;
		}
	}
}

function change_view(mypath, mywidth, myheight){
	document.getElementById("myproduct").src="./images/spacer.gif";
	if(mywidth != ""){
		document.getElementById("myproduct").width=mywidth;
	}
	if(myheight != ""){
		document.getElementById("myproduct").height=myheight;
	}
	document.getElementById("myproduct").src=mypath;
}
function delete_sets(table, id, head, order_field, order_dir, set_start, user_id, PHPSESSID, checkstat){
	SQL = "";
	USQL = "Caution: Do you realy want to delete the dataset No.";
	counter = 0;
	donot = "";
	for(t=0; t<=99; t++){
		if(document.getElementById("check_" + t)){
			if(document.getElementById("check_" + t).checked == checkstat){
				del_id = document.getElementById("check_" + t).name;
				del_id = del_id.split("_");
				del_id = del_id[1];
				if(table == "tbl_user" && user_id == del_id){
					donot += "<br>Hinweis: Der Datensatz mit dem eigenen Profil wurde aus Sicherheitsgründen ignoriert!";
				}
				else{
					//mydat = document.getElementById("c_blind_datum_" + del_id).firstChild.data;
					SQL += "DELETE FROM " + table + " WHERE blind_id = " + del_id + " LIMIT 1|";
					counter ++;
					if(counter > 1){
						USQL +=  ", ";
					}
					USQL += del_id;
				}
			}
		}
	}
	if(counter > 0){
		if(counter > 1){
			USQL = USQL.replace(/dataset/, "datasets");
		}
		USQL += " from the table \"";
		USQL += table;
		USQL += "\"?";
		USQL += donot;
		pstring = "SQL=" + SQL + "&USQL=" + USQL + "&table=" + table + "&id=" + id + "&head=" + head + "&order_field=" + order_field + "&order_dir=" + order_dir + "&set_start=" + set_start + "&PHPSESSID=" + PHPSESSID;
		change_location("confirm.php", pstring);
	}
}

function delete_table(table, id, head, order_field, order_dir, set_start, PHPSESSID){
	SQL = "TRUNCATE " + table;
	USQL = "CAUTION: Do you realy want to delete ALL datasets from the table \"" + table + "\"?";
	pstring = "SQL=" + SQL + "&USQL=" + USQL + "&table=" + table + "&id=" + id + "&head=" + head + "&order_field=" + order_field + "&order_dir=" + order_dir + "&PHPSESSID=" + PHPSESSID + "&task=table";
	change_location("confirm.php", pstring);
}



function change_location(var_filename, var_paramstring){
	location.replace(var_filename+"?"+var_paramstring);
}

function reload_main(task){
	top.frames[2].location.href = task;
}

function roll_over(obj_id, the_class){
	document.getElementById(obj_id).className = the_class;
}

function reload_page(urlstring){
	location.href = urlstring;
}

function log_off(session_id){
	win = window.open("destroy_session.php?session_id="+session_id,"", "width=1px, height=1px,left=2000");
	top.location.href = "index.php";
}

function roll_pic(myid, mypic){
	document.getElementById(myid).src = mypic;
}

function build_sub(myid, cat1, mynames, myids, menuecount, parent){
	//alert("Bumm");
	mynames = mynames.split("|");
	myids = myids.split("|");
	mycount = mynames.length - 1;
	out = "";
	out += "<table width=\"100%\" height=\"1px\" border=\"0\">";
	for(t = 0; t <= mycount; t++){
	//	alert(out);
		out += "<tr><td class=\"text_white_13\" align=\"center\"><a href='index.php?modul=choice&cat2=" + myids[t] + "&parent=" + parent + "'>" + mynames[t] + "</a></td></tr>";
	}
	out += "<tr><td onmouseOver=\"javascript:kill_menue(" + menuecount + ")\">&nbsp;</td></tr>";
	out += "</table>";
	document.getElementById("sub_" + myid).innerHTML = out;
}

function kill_menue(menuecount){
	menuecount --;
	for(t = 0; t <= menuecount; t++){ 
		document.getElementById("sub_" + t).innerHTML = "&nbsp;";
		document.getElementById("d_" + t).className = "div_dark";
	}
}
function show_details(myvars){
	mypic = document.getElementById('myproduct').src;
	mypic = mypic.split("_");
	mypic = mypic[mypic.length-2];
	picnum = mypic.substr(3);
	location.href = "./modules/details.php?picnum=" + picnum + "&" + myvars;
}


