﻿function CheckForHash(forceload){
	if(document.location.hash){
		var HashLocationName = document.location.hash;
		var HLNS = new Array
		HashLocationName = HashLocationName.replace("#","");		
		if ((unescape(LastNavigationStep)!=unescape(HashLocationName)) || (forceload==1)) {
			HLNS=HashLocationName.split("/")
			LastNavigationStep=HashLocationName
			switch (HLNS[0]) {
				case "Hersteller":
					if (HLNS.length==3) {
						BB_move_menue(unescape(HLNS[2].replace(".html","")),unescape(HLNS[1]));
					}
					if (HLNS.length==6) {
						if (HLNS[2]!=window.hersteller_id) {
							DirectLinks[0]=unescape(HLNS[5].replace(".html",""))
							DirectLinks[1]=unescape(HLNS[4])	
							BB_move_menue(unescape(HLNS[2].replace(".html","")),unescape(HLNS[1]));
						}else{
							BB_ShowModells(unescape(HLNS[5].replace(".html","")),unescape(HLNS[4]));
						}
					}
					if (HLNS.length==9) {
						if (HLNS[2]!=window.hersteller_id) {
							DirectLinks[2]=unescape(HLNS[8].replace(".html",""))
							DirectLinks[3]=unescape(HLNS[7])	
							DirectLinks[4]=unescape(HLNS[5])	
							DirectLinks[5]=unescape(HLNS[4])
							BB_move_menue(unescape(HLNS[2].replace(".html","")),unescape(HLNS[1]));
						}else{
							BB_loadProduct(unescape(HLNS[8].replace(".html","")),unescape(HLNS[7]),unescape(HLNS[5]),unescape(HLNS[4]));
						}						
					}					
					break;
				case "admin_start.html": case "kasse.html": case "impressum.html": case "Partner.html": case "Kontakt.html": case "registration.html": case "admin_photos.html": case "Kontakt.html": case "Kundenstimmen.html": case "FAQ.html": case "admin_haendler.html": case "warenkorb.html": case "mylounge.html": case "admin_addproduct.html": case "admin_kunden.html": case "admin_price.html": case "admin_todo.html": case "admin_purchase.html": case "admin_search.html": case "admin_receipt.html": case "admin_angebote.html": case "admin_statistic.html":case "payment.html":
					BB_loadAJAX(unescape(HLNS[0]))
					break;	
				
				case "checkout":
					checkoutNow(unescape(HLNS[1]))
					break;	
				
				case "Suche":
					searchItem(unescape(HLNS[1].replace(".html","")))
					break;	
					
				case "Kunde":
					loadCostumer2(unescape(HLNS[1].replace(".html","")))
					break;
					
				case "callback":
					loadCostumer4(unescape(HLNS[1].replace(".html","")))
					break;
					
				case "callback.html":
					BBnextCallback()
					break;
					
				case "Kunden":
					loadCostumer3(unescape(HLNS[1].replace(".html","")))
					break;
										
				/*case "admin_start.html":
					document.getElementById('topmenu_shop_menu').style.display='block'
					document.getElementById('topmenu_login_menu').style.display='none';
					document.getElementById('leftmenu_selectedbrand_link').innerHTML="Admin Menü"
					URLRequest('http://www.uhrenlounge.de/shop/asp/ajaxSQL.asp?action=getadminMenue',1)
					break;	*/
			}	
		}
	}
}
function RenameAnchor(anchorid, anchorname){
	document.getElementById(anchorid).name = anchorname; //this renames the anchor
}
function RedirectLocation(anchorid, anchorname, HashName){
	RenameAnchor(anchorid, anchorname);
	document.location = HashName;
}

//BackButton Ersatzfunktionen
//-----------------------------

function BBnextCallback(){
	URLRequest('http://www.uhrenlounge.de/shop/html/ajax_admin_kunden.asp?mode=callback')
}

function checkoutNow(ppStatus){
	URLRequest('http://www.uhrenlounge.de/shop/html/ajax_kasse.asp?status=' + ppStatus,1)
}
function loadCostumer3(searchTXT){
	URLRequest('http://www.uhrenlounge.de/shop/html/ajax_admin_kunden.asp?searchtxt=' + searchTXT)
}

function loadCostumer2(id){
	URLRequest('http://www.uhrenlounge.de/shop/html/ajax_admin_kunden.asp?userID=' + id)
}

function loadCostumer4(id){
	URLRequest('http://www.uhrenlounge.de/shop/html/ajax_admin_kunden.asp?mode=callback&userID=' + id)
}

function searchItem(keyword){
	searchTXT=keyword
	document.getElementById('searchtext').value=searchTXT
		document.getElementById('serien_menu_controls_filter').style.display="block"
		document.getElementById('serien_menu_controls').style.display="none"
		document.getElementById("serien_menu_container_right").innerHTML="<br><br>"
		document.getElementById('controls_middle').innerHTML="<b>Zurück</b> zu Ihren Suchergebnissen"
		document.getElementById('controls_middle').href="#Suche/" + searchTXT +".html" 
		document.getElementById("leftmenu_selectedbrand_link").innerHTML="Suchergebnisse"
		document.getElementById('serien_menu_controls_filter').style.display="block"
		document.getElementById('serien_menu_controls').style.display="none"
		document.getElementById('controls_middle').onclick=""
	serien_id=""
	serien_name=""
	for (var i=1; i<6; i++) {
		document.getElementById('filter_dropdown_' + i).innerHTML=""
		document.getElementById("filter_label_" +i).innerHTML="Alle +"
	}
	if (document.getElementById("serien_menu_middle").offsetHeight=="12"){
		document.getElementById("serien_menu_middle").style.height="auto"
		tmp=document.getElementById("serien_menu_middle").offsetHeight
		document.getElementById("serien_menu_middle").style.height="12px"
		openDivMove ("serien_menu_middle",tmp)
	}
	setTimeout(function(){
		URLRequest('http://www.uhrenlounge.de/shop/html/ajax_serien.asp?searchtxt=' + searchTXT)
	},500)
}

function BB_move_menue(hersteller_name,hersteller_id)
{	 
	oldhersteller_id=window.hersteller_id
	if (window.hersteller_id==hersteller_id){
		if ((DirectLinks[0]==0) && (DirectLinks[2]==0)) {
			URLRequest('http://www.uhrenlounge.de/shop/html/ajax_hersteller.asp?hid=' + hersteller_id);	
		}
		if (DirectLinks[0]!=0) {
			BB_ShowModells(DirectLinks[0],DirectLinks[1]);
			DirectLinks[0]=0
			DirectLinks[1]=0
		}
		if (DirectLinks[2]!=0) {
			BB_loadProduct(DirectLinks[2],DirectLinks[3],DirectLinks[4],DirectLinks[5]);
			DirectLinks[2]=0
			DirectLinks[3]=0
			DirectLinks[4]=0
			DirectLinks[5]=0
		}
		return;
	}
	
	window.hersteller_id=hersteller_id
	window.hersteller_name=hersteller_name

	//if (isMoving==1)file:///C:/Dokumente und Einstellungen/Müller/Eigene Dateien/Projects/www.uhrenlounge.de/shop/js/backbutton.js
	//	return;
		
	document.getElementById("leftmenu_selectedbrand").style.opacity="0"
	document.getElementById("leftmenu_selectedbrand").style.filter="0"
	document.getElementById("leftmenu_selectedbrand").FadeState=-2
	//document.getElementById("serien_menu_container_left").style.opacity="0"
	//document.getElementById("serien_menu_container_left").style.filter="0"
	//document.getElementById("serien_menu_container_left").FadeState=-2
	loadSeries(hersteller_id);
	if (document.getElementById("serien_menu_middle").offsetHeight=="12"){
		document.getElementById("serien_menu_middle").style.height="auto"
		//tmp=document.getElementById("serien_menu_middle").offsetHeight
		//document.getElementById("serien_menu_middle").style.height="12px"
		//openDivMove ("serien_menu_middle",tmp)
	}
}


function BB_ShowModells(serien_name,serien_id){
	document.getElementById('serien_menu_controls_filter').style.display="block"
	document.getElementById('serien_menu_controls').style.display="none"
	
	//TimeToFade = 100
	//document.getElementById('display_area_right').style.opacity="1"
	//document.getElementById('display_area_right').style.filter="100"
	//document.getElementById('display_area_right').FadeState=2
	//fade('display_area_right')	
	TimeToFade = 200
	window.serien_id=serien_id
	window.serien_name=serien_name
	setTimeout("URLRequest('http://www.uhrenlounge.de/shop/html/ajax_serien.asp?hid='+ window.hersteller_id + '&sid=' + serien_id);",100)	
	
}

function BB_loadProduct(Product_name,Product_id,Serien_name,Serien_id)
{	
	Modell_id=Product_id
	Modell_name=Product_name
	//TimeToFade = 100
	//fade('display_area_right')	
	TimeToFade = 200
	window.Modell_id=Product_id
	window.Modell_name=Product_name
	window.serien_id=Serien_id
	window.serien_name=Serien_name
	window.actlPrice=null
	window.fullPrice=null		
	URLRequest('http://www.uhrenlounge.de/shop/html/ajax_detail.asp?pid=' + Modell_id);	
}

function BB_loadAJAX(page)
{
	if (window.loading==1) {
		setTimeout(function(){
			BB_loadAJAX(page);
		},250)
		return;
	}
	LastMoveElement=null
	page=page.replace(".html","")
	//page=warenkorb || page=kasse
	URLRequest('http://www.uhrenlounge.de/shop/html/ajax_' + page + '.asp?x=1')
}

var HashCheckInterval = setInterval("CheckForHash()", 1000);
window.onload = CheckForHash;
