// Window Opener
function w_open(url, name, features) {
	w = window.open(url, name, features);
	w.focus();
	return w;
}

function s_open(url,name,features) {
	mysearch = window.open(url, name, features);
	mysearch.focus();
	return mysearch;
}

function dreiD_open(url,name) {
	mydreiD = window.open(url, name, 'width=656,height=566');
	mydreiD.focus();
	return mydreiD;
}

function showPage(path) {
	top.location.href = path;
}

function showNewPage(path) {
	newPage = window.open(''+path,'mywin','');
	newPage.blur();
}

//var window_cart = null;
function openWin_cart(url) {
	w = window.open(url, 'sat_xl', 'width=625,height=550,scrollbars=yes');
	w.focus();
	return w;
}

//var window_advent = null;
function openWin_advent(url) {
	window_advent = w_open(url, "window_advent", "width=350,height=350,scrollbars=yes");
}

function openWin_zoom(url) {
	w = window.open(url, 'zoomWin', 'width=100,height=120,scrollbars=no,resizable=no,status=no,menubar=no,top=0,left=0');
	w.focus();
}

function openWin_agb(url) {
	w = window.open(url, 'bigWin', 'width=640,height=480,scrollbars=yes,status=yes,menubar=yes');
	w.focus();
}

function openWin_standard(url) {
	w = window.open(url, 'stdWin', 'width=400,height=520,scrollbars=yes');
	w.focus();
}

function openWin_big(url) {
	w = window.open(url, 'bigWin', 'width=640,height=500,scrollbars=yes,status=yes,menubar=yes');
	w.focus();
}

function showInOpener(url) {
	opener.document.location.href = url;
}

function submitToCart(theForm) {
	var win1 = (Fensterweite()-400)/2;
	var win2 = (Fensterhoehe()-200)/2;
	document.getElementById("showWKinfo").style.left=win1+"px";
	document.getElementById("showWKinfo").style.top=win2+site_getScrollTop()+"px";
	document.getElementById("showWKinfo").style.display="block";
	theForm.target = "WKiframe";
	theForm.scrpos.value = site_getScrollTop();
	theForm.submit();
	return false;
}

function backFromPayment() {
	document.getElementById('payment-layer').style.display='none';
	document.getElementById('payment-lock-layer').style.display='none';
	document.getElementById('payment-container').style.display='none';
}

// {ini.shopalias}?{local.page_id}
function reloadForProductSizes(select, idpath, params) {
	var selGrIndex = 0; 

	if (select != null && select.form.Gross) {
		select.form.Gross.disabled = true;
		selGrIndex = select.form.Gross.selectedIndex;
		select.form.Gross.selectedIndex = 0;
	}
	scrollTop = site_getScrollTop();
	document.location.href = idpath
			+ (select == null ? "" : '&sel_artnr=' + select.options[select.options.selectedIndex].value 
				+ (select.form.Gross && select.form.Gross.options ? '&sel_artgr=' + select.form.Gross.options[selGrIndex].value : '')
				+ (!select.form.mcnr ? "" : "&mcnr=" + select.form.mcnr.value + "&mcnrv=" + select.form.mcnrv.value))
					 //+ "&mcartnr=" + select.form.mcartnr.value + "&mcmodnr=" + select.form.mcmodnr.value
			+ (scrollTop >= 0 ? '&scrpos=' + scrollTop : "")
			+ '&' + params 
	;
}

function site_getScrollTop() {
//alert("" + contentLayerID + ", " + document.getElementById + ", " + document.getElementById(contentLayerID));
	/*
	if (typeof contentLayerID != 'undefined' && document.getElementById && document.getElementById(contentLayerID)) {
		div = document.getElementById(contentLayerID);
alert("" + div.scrollTop);
		if (div.scrollTop)
			return div.scrollTop;
	}
	
if (typeof window.pageYOffset != 'undefined')
alert("" + window.pageYOffset );
if (typeof document.body != 'undefined')
alert("" + document.documentElement.scrollTop );
alert("" + document.body.scrollTop);

	*/

	scrollPos = -1;

	if (typeof document.body != 'undefined' && document.body.scrollTop > 0) {
	   scrollPos = document.body.scrollTop;
	}
	else if (typeof document.documentElement != 'undefined' && document.documentElement.scrollTop > 0) {
	   scrollPos = document.documentElement.scrollTop;
	}
	else if (typeof window.pageYOffset != 'undefined' && window.pageYOffset > 0) {
	   scrollPos = window.pageYOffset;
	}

	return scrollPos;
}

function site_setScrollTop(val) {
	if (typeof document.body != 'undefined' && document.body) {
	   document.body.scrollTop = val;
	}
	else if (typeof document.documentElement != 'undefined') {
		document.documentElement.scrollTop = val;
	}
	else if (typeof window.pageYOffset != 'undefined' && window.pageYOffset > 0) {
	   window.pageYOffset = val;
	}
	
	window.scrollTo(0, val);
/*
	*/
//

	/*
	if (typeof contentLayerID != 'undefined' && document.getElementById && document.getElementById(contentLayerID)) {
		div = document.getElementById(contentLayerID);
		//if (div.scrollTop) {
				div.scrollTop = val;
		//}
	}
	*/
}

function resizeDivTo(div_id, div_height){
	var div = document.getElementById(div_id);
	if(div.offsetHeight < div_height){
		var h = div.offsetHeight + 1;
		div.style.height = h+'px';
		window.setTimeout("resizeDivTo('" + div_id +"'," + div_height + ");", 20);
	}
}


/*
function Fensterweite() {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}

function Fensterhoehe() {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}*/

function Fensterweite(win) { 
	if (win == undefined) win = window; 
	if (win.innerWidth) { 
		return win.innerWidth; 
	} 
	else { 
		if (win.document.documentElement && 
			win.document.documentElement.clientWidth) { 
			return win.document.documentElement.clientWidth; 
		} 
		return win.document.body.offsetWidth; 
	} 
} 

function Fensterhoehe(win) { 
	if (win == undefined) win = window; 
	if (win.innerHeight) { 
		return win.innerHeight; 
	} 
	else { 
		if (win.document.documentElement 
			&& win.document.documentElement.clientHeight) { 
			return win.document.documentElement.clientHeight; 
		} 
		return win.document.body.offsetHeight; 
	} 
}

function activateAGB(id) {
	if(id=="checkbox"){
		if(document.getElementById('checkbox').checked==true){
			document.getElementById('checkbox2').checked=true;
		}
		else{
			document.getElementById('checkbox2').checked=false;
		}
	}
	if(id=="checkbox2"){
		if(document.getElementById('checkbox2').checked==true){
			document.getElementById('checkbox').checked=true;
		}
		else{
			document.getElementById('checkbox').checked=false;
		}
	}
}
function activateNewsletter (id) {
	if(id=="newsletter__cb2"){
		if(document.getElementById('newsletter__cb').checked==true){
			document.getElementById('newsletter__cb2').checked=true;
		}
		else{
			document.getElementById('newsletter__cb2').checked=false;
		}
	}
	if(id=="newsletter__cb"){
		if(document.getElementById('newsletter__cb2').checked==true){
			document.getElementById('newsletter__cb').checked=true;
		}
		else{
			document.getElementById('newsletter__cb').checked=false;
		}
	}
}




function showAvailInfo(artnr, avail, currentState) {
	if (avail == ""){
		avail = -1;
	}
	if (currentState > 0) {
		d2 = document.getElementById(artnr + "_availInfo" + currentState);
		d2.style.display = 'none';
	}
	if (avail > 0) {
		d = document.getElementById(artnr + "_availInfo" + avail);
		d.style.display = 'block';
	}
}

// advent_win: 'width=500,height=400,scrollbars=yes'
// agb 'width=640,height=480,scrollbars=yes,status=yes,menubar=yes'
// praemie 'width=400,height=550,scrollbars=yes'
// schuhe safety 'width=500,height=400,scrollbars=yes'
// skonto 'width=500,height=400'
// jubilee win 'width=585,height=600,scrollbars=yes'
// teinahme bedingungen 'width=350,height=300'
// mass 'width=500,height=400,scrollbars=yes'
// materialinfo 'width=500,height=400,scrollbars=yes'
// klinge allg 'width=500,height=400,scrollbars=yes'
// general popup 'width=500,height=400,scrollbars=yes'




