﻿var menu_sections = new Array("service", "veranstaltungen", "beruf", "scriptexpert", "sponsoring", "umfragen", "verband", "allerlei", "mitglied", "mitgliedschaft", "memberarea","archiv");

var act_section = null;
var act_root_section = null;

if(document.location.href.indexOf("localhost") != -1){
	var host = "http://localhost/";
	var doc_root = "Kunden-Websites/Kunden/New%20Scriptweb/refining-scriptweb%2008/Scriptweb-refined/";
}else{
	var host = "";
	var doc_root = "/";
}

var myBoxy = null;

function init_boxy(){

	if(Boxy){
		$('a[rel*=facebox]').boxy({//title: "Hoschi",
		  							//closeText: "Schliessen",
		  							//unloadOnHide: false,
		  							beforeShow: function(){
		  								window.alert("xo");
		  								myBoxy = this;
		  							},
		  							
		  							afterShow: function(){
		  							
		  								myBoxy = this;
		  								try{
		  									//resize_boxy();
		  								}catch(err){
		  									// nothing
		  								}
		  								
		  								$('a[rel="boxy"]').click( function() {
									        set_boxy_content(this.href);
									        return false;
									    });
		  							}
		  							
		  							}); 
	}
}

function set_boxy_content(content_url){

	
	$.get(content_url, function(data){
							
							myBoxy.setContent(data);
							
							myBoxy.center();

							$('a[rel="boxy"]').click( function() {
								        set_boxy_content(this.href);
								        return false;
								    });
						}
	);
}

jQuery(document).ready(function($) {
		if($('a[rel*=facebox]').boxy)
		  init_boxy();

	})


function close_fb(boxyId){
	boxyId.hide();
	return true;
}

// Logout für Member

function logout(){

	var base = document.location.href;
	
	if(base.indexOf("seiten_mitglieder") != -1){
		base = "../";
	}else{
		base = "../../seiten_mitglieder/";
	}
	
	$.post(base + "scripts/do_logout.php", 
			function(){
				$('#centerdiv').load(base + "scripts/check_status.php?login_msg=logged_out");
				$('#log_status').hide();
			});
}

function menu_handler(){
	
	// Set the pulldown-menu to the actual root_section
	
	l = document.frm_rootselector.sel_rootselector.options.length;
	
	for(var i =0;i<l;i++){
		if(act_root_section == document.frm_rootselector.sel_rootselector.options[i].value){
			document.frm_rootselector.sel_rootselector.selectedIndex = i;
		}
	}
	
	for (var menu in menu_sections){
		if(menu_section == menu_sections[menu]){
		
			$('#menu_' + menu_sections[menu]).show('slow');
			act_section = menu_sections[menu];
			
			// Aktuelle Seite auf aktiv setzen
			
			var tmp = document.location.href.split("/");
			var this_page = tmp.pop();
			
			if(this_page.indexOf("#") != -1){
				tmp = this_page.split("#");
				this_page = tmp[0];
			}
			
			if(document.getElementById(this_page))
				document.getElementById(this_page).className = "line sub selected";
		}
	}
	
	
	// Nach Upload entfernen!!!
	/*
	for(var i in document.getElementsByTagName('a')){
	
		var href = document.getElementsByTagName('a')[i].href;
		
		if(href != undefined && href.indexOf("Kunden-Websites") == -1 && href.indexOf("localhost") != -1){
			
			var tmp = href.split("/");
			tmp = tmp.slice(3);
			var new_href = host + doc_root + tmp.join("/");
		
			document.getElementsByTagName('a')[i].href = new_href;
		}
	}
	*/
}

function toggle_menu(which){

	if(act_section != which){
		$('#menu_' + act_section).hide('slow');
		$('#menu_' + which).show('slow');
		act_section = which;
	}

}

function set_root_section(){
	var root_sel = document.frm_rootselector.sel_rootselector[document.frm_rootselector.sel_rootselector.selectedIndex].value;
	
	document.location.href = host + doc_root + "set_root.php?root=" + root_sel + "&act_page=" + document.location.href;
}


// Für Masked INput

var tel_fields = new Array();
var tel_format = new Array();
   		
tel_format['ch'] = "+99 (9)99 999 99 99";
tel_format['li'] = "+99 (9)99 999 99 99";
tel_format['de'] = "+99 (9)999 999 99 99";
tel_format['at'] = "+99 (9)999 999 99 99";

function change_tel_format(ctry_pulldown){

	var ctry = $("#" + ctry_pulldown).val();

	for(var i in tel_fields){
		$("#" + tel_fields[i]).mask(tel_format[ctry], {allowPartial:true});
	}
}

