
<!--

if (top.frames.length > 0) top.location.href = self.location;

var x;
var y;

document.onmousemove = xy;

function addToCart(nr, la) {
	cart_makeHttpRequest('ajaxcart.php?&cmsmeid='+nr+'&la='+la, 'callback', true, 'id');
	window.setTimeout('hideError()', 1000);
}

function cart_makeHttpRequest(url, callback_function, return_xml, id)
{
	var http_request = false;
	if (window.XMLHttpRequest) {
		// Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) {
		// IE
		try {
			http_request = new ActiveXObject('Msxml2.XMLHTTP');
		} catch (e) {
			try {
				http_request = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e) {
			}
		}
	}
	if (!http_request) {
		alert('Unfortunatelly your browser doesn’t support this feature.');
		return false;
	}
	
	http_request.onreadystatechange = function()
	{
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				if (return_xml) {
					var xmldoc = http_request.responseXML;
					// Warenkorb
					var i = 0;
					if (xmldoc.getElementsByTagName('carts').item(0)) {
						// cartul ist ID des ul-Elements: 					
						cartul_node = document.getElementById('cartul');
						while (cartul_node.hasChildNodes()) {
							cartul_node.removeChild(cartul_node.firstChild);
						}
						while (xmldoc.getElementsByTagName('count').item(i)) {
							var count_node = xmldoc.getElementsByTagName('count').item(i);
							if (count_node.firstChild.data != 'nix') {
								// count
								var htmTag_li = document.createElement('li');
								var htmInh_li = document.createTextNode(count_node.firstChild.data);
								htmTag_li.appendChild(htmInh_li);
								cartul_node.appendChild(htmTag_li);
								// error
								var error_node = xmldoc.getElementsByTagName('error').item(i);
								var htmTag_li = document.createElement('li');
								var htmInh_li = document.createTextNode(error_node.firstChild.data);
								var htmAttr_id = document.createAttribute('id');
								htmAttr_id.nodeValue = 'error';
								htmTag_li.setAttributeNode(htmAttr_id);
								htmTag_li.appendChild(htmInh_li);
								cartul_node.appendChild(htmTag_li);
							}
							i++;
						}
						cartul_node.style.display = 'block';
					} else {
						cartul_node = document.getElementById('cartul');
						cartul_node.style.display = 'none';
						while (cartul_node.hasChildNodes()) {
							cartul_node.removeChild(cartul_node.firstChild);
						}
					}
				} else {
					eval(callback_function + '(http_request.responseText, id)');
				}
			} else {
				/* alert('There was a problem with the request. (Code: ' + http_request.status + ')') ; */
			}
		}
	}
	http_request.open('GET', url, true);
	http_request.send(null);
}

function chkForm()
{
	var ids = {'name':'name', 'vornamen':'vornamen', 'strasseNr':'strasseNr', 'postleitzahl':'postleitzahl', 'ort':'ort', 'email':'email'};
	for (var key in ids) {
		if (document.getElementById(ids[key])) {
			obj = document.getElementById(ids[key]);
			if (obj.value == '') {
				obj.style.backgroundColor = '#FFFF00';
				alert('Bitte ausfüllen!');
				obj.focus();
    			window.setTimeout("obj.style.backgroundColor = '#FFFFFF';", 2000);
				return false;
			}
		}
	}
}

function copy(inElement) {
	if (inElement.createTextRange) {
    	var range = inElement.createTextRange();
   		if (range) {
   			range.execCommand('Copy');
   		}
	} else {
    	var flashcopier = 'flashcopier';
    	if (!document.getElementById(flashcopier)) {
      		var divholder = document.createElement('div');
      		divholder.id = flashcopier;
      		document.body.appendChild(divholder);
    	}
    	document.getElementById(flashcopier).innerHTML = '';
    	var divinfo = '<embed src=\'swf/_clipboard.swf\' FlashVars=\'clipboard='+encodeURIComponent(inElement.value)+'\' width=\'0\' height=\'0\' type=\'application/x-shockwave-flash\'></embed>';
    	document.getElementById(flashcopier).innerHTML = divinfo;
  	}
}

function countSearch(s, la) {
	if (s.length > 1) {
		document.getElementById('countSearch').style.display = 'block';
    	document.getElementById('imgSearching').style.display = 'block';
		countSearch_makeHttpRequest('ajaxcountsearch.php?&srchstr='+s+'&la='+la, 'callback', true, 'id');
    } else {
  		document.getElementById('imgSearching').style.display = 'none';
  		document.getElementById('countSearch').style.display = 'none';
  	}
}

function countSearch_makeHttpRequest(url, callback_function, return_xml, id)
{
	var http_request = false;
	if (window.XMLHttpRequest) {
		// Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) {
		// IE
		try {
			http_request = new ActiveXObject('Msxml2.XMLHTTP');
		} catch (e) {
			try {
				http_request = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e) {
			}
		}
	}
	if (!http_request) {
		alert('Unfortunatelly your browser doesn’t support this feature.');
		return false;
	}
	
	http_request.onreadystatechange = function()
	{
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				if (return_xml) {
					var xmldoc = http_request.responseXML;
					// Anzahl Funde
					if (xmldoc.getElementsByTagName('count').item(0)) {
					while (document.getElementById('countSearch').hasChildNodes()) {
						document.getElementById('countSearch').removeChild(document.getElementById('countSearch').firstChild);
					}
					var count_node = xmldoc.getElementsByTagName('count').item(0);
						if (count_node.firstChild.data > 0) {
							if (count_node.firstChild.data > 1) {
								var htmInh_div = document.createTextNode(count_node.firstChild.data+' '+'[fundstellen]');
							} else {
								var htmInh_div = document.createTextNode(count_node.firstChild.data+' '+'[fundstelle]');
							}
						} else {
							var htmInh_div = document.createTextNode('nessun risultato');
						}
						document.getElementById('countSearch').appendChild(htmInh_div);
				  		document.getElementById('imgSearching').style.display = 'none';
						document.getElementById('count').style.display = 'block';
					} else {
					}
				} else {
					eval(callback_function + '(http_request.responseText, id)');
				}
			} else {
				/* alert('There was a problem with the request. (Code: ' + http_request.status + ')') ; */
			}
		}
	}
	http_request.open('GET', url, true);
	http_request.send(null);
}

function email(n, h) {
    window.location.href = 'mailto:' + n + '@' + h;
}

function hide() {
    Div = document.getElementById('hilfe');
    Div.style.display = 'none';
}

function hideDiv(n) {
    Div = document.getElementById(n);
    Div.style.display = 'none';
}

function hideError()
{
	if (document.getElementById('error')) {
		document.getElementById('error').style.display = 'none';
	}
}

function setNumber(ccmsmeid, anzahl)
{
	var http_request = false;
	if (window.XMLHttpRequest) {
		// Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) {
		// IE
		try {
			http_request = new ActiveXObject('Msxml2.XMLHTTP');
		} catch (e) {
			try {
				http_request = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e) {
			}
		}
	}
	if (!http_request) {
		alert('Unfortunatelly your browser doesn’t support this feature.');
		return false;
	}
	http_request.onreadystatechange = function()
	{
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
			/*
				if (return_xml) {
				} else {
					eval(callback_function + '(http_request.responseText, id)');
				}
			*/
			} else {
				/* alert('There was a problem with the request. (Code: ' + http_request.status + ')') ; */
			}
		}
	}
	http_request.open('GET', 'ajaxSetNumber.php?&ccmsmeid='+ccmsmeid+'&anzahl='+anzahl, true);
	http_request.send(null);
}

function setText(key, value)
{
	var http_request = false;
	if (window.XMLHttpRequest) {
		// Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) {
		// IE
		try {
			http_request = new ActiveXObject('Msxml2.XMLHTTP');
		} catch (e) {
			try {
				http_request = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e) {
			}
		}
	}
	if (!http_request) {
		alert('Unfortunatelly your browser doesn’t support this feature.');
		return false;
	}
	http_request.onreadystatechange = function()
	{
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
			/*
				if (return_xml) {
				} else {
					eval(callback_function + '(http_request.responseText, id)');
				}
			*/
			} else {
				/* alert('There was a problem with the request. (Code: ' + http_request.status + ')') ; */
			}
		}
	}
	http_request.open('GET', 'ajaxSetText.php?&k='+key+'&v='+value, true);
	http_request.send(null);
}

function zusatzfenster(url) {
	dummy = window.open(url, 'zusatzfenster', 'width=966, height=600, scrollbars=yes, left=20, top=20');
}

// Diese Funktion fügt Informationen in ein Formularfeld ein
var alertText;
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1));
var is_safari = ((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1));
var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ));
if (clientPC.indexOf('opera')!=-1) {
    var is_opera = true;
    var is_opera_preseven = (window.opera && !document.childNodes);
    var is_opera_seven = (window.opera && document.childNodes);
}
// apply tagOpen/tagClose to selection in textarea,
// use sampleText instead of selection if there is none
// copied and adapted from phpBB

function insertTags(tagOpen, tagClose, sampleText, txtarea)
{
    // var txtarea = document.cms_meld.cms_me_text;
    // IE
    if(document.selection  && !is_gecko)
    {
        var theSelection = document.selection.createRange().text;
        if(!theSelection)
        {
            theSelection=sampleText;
        }
        if((tagClose == '</ol>') || (tagClose == '</ul>'))
        {
            var selit = '';
            var listItems = theSelection.split("\r\n");
            for (i = 0; i < listItems.length; i++)
            {
                selit += '<li>' + listItems[i] + "</li>\r\n";
            }
            theSelection = "\r\n" + selit;
            tagClose += "\r\n";
        }
        txtarea.focus();
        if(theSelection.charAt(theSelection.length - 1) == ' ')
        {
            // exclude ending space char, if any
            theSelection = theSelection.substring(0, theSelection.length - 1);
            document.selection.createRange().text = tagOpen + theSelection + tagClose + ' ';
        }
        else
        {
            document.selection.createRange().text = tagOpen + theSelection + tagClose;
        }
    // Mozilla
    }
    else if(txtarea.selectionStart || txtarea.selectionStart == '0')
    {
        var startPos = txtarea.selectionStart;
        var endPos = txtarea.selectionEnd;
        var scrollTop=txtarea.scrollTop;
        var myText = (txtarea.value).substring(startPos, endPos);
        if(!myText)
        {
            myText=sampleText;
        }
        if((tagClose == '</ol>') || (tagClose == '</ul>'))
        {
            var selit = '';
            var listItems = myText.split("\n");
            for (i = 0; i < listItems.length; i++)
            {
                selit += '<li>' + listItems[i] + "</li>\n";
            }
            myText = "\n"+ selit;
        }
        if(myText.charAt(myText.length - 1) == ' ')
        {
            // exclude ending space char, if any
            subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + ' ';
        }
        else
        {
            subst = tagOpen + myText + tagClose;
        }
        txtarea.value = txtarea.value.substring(0, startPos) + subst + txtarea.value.substring(endPos, txtarea.value.length);
        txtarea.focus();
        var cPos=startPos+(tagOpen.length+myText.length+tagClose.length);
        txtarea.selectionStart=cPos;
        txtarea.selectionEnd=cPos;
        txtarea.scrollTop=scrollTop;
    // All others
    }
    else
    {
        var copy_alertText=alertText;
        var re1=new RegExp('\$1','g');
        var re2=new RegExp('\$2','g');
        copy_alertText=copy_alertText.replace(re1,sampleText);
        copy_alertText=copy_alertText.replace(re2,tagOpen+sampleText+tagClose);
        var text;
        if (sampleText)
        {
            text=prompt(copy_alertText);
        }
        else
        {
            text='';
        }
        if(!text)
        {
            text=sampleText;
        }
        if((tagClose == '</ol>') || (tagClose == '</ul>'))
        {
            var selit = '';
            var listItems = text.split("\n");
            for (i = 0; i < listItems.length; i++)
            {
                selit += '<li>' + listItems[i] + "</li>\n";
            }
            text = "\n" + selit;
            tagClose += "\n";
        }
        text=tagOpen+text+tagClose;
        document.infoform.infobox.value=text;
        // in Safari this causes scrolling
        if(!is_safari)
        {
            txtarea.focus();
        }
		noOverwrite=true;
	}
	// reposition cursor if possible
    if (txtarea.createTextRange)
    {
        txtarea.caretPos = document.selection.createRange().duplicate();
    }
}

ytplayer = 0;
function onYouTubePlayerReady(playerId) {
    ytplayer = document.getElementById('myytplayer');
}
function play() {
	if (ytplayer) {
		ytplayer.playVideo();
	}
}

function verbergeDiv(o) {
	o.style.display = 'none';
}

function verbergeDivName(n) {
    o = document.getElementById(n);
	o.style.display = 'none';
}

function zeige(n) {
    document.onmousemove = xy;
    Div = document.getElementById('hilfe');
    Div.firstChild.nodeValue = n;
    Div.style.left = (x + 11) + 'px';
    Div.style.top = (y + 11) + 'px';
    Div.style.display = 'block';
}

function zeigeDiv(n) {
    document.onmousemove = xy;
    Div = document.getElementById(n);
    if (document.all) {
	    var arrayPageScroll = document.viewport.getScrollOffsets();
	    var divTop = arrayPageScroll[1];
    	Div.style.top = (y + divTop - 19) + 'px';
	} else {
    	Div.style.top = (y - 19) + 'px';
	}
    Div.style.left = (x - 19) + 'px';
    Div.style.display = 'block';
	// window.setTimeout('verbergeDiv(Div)', 5000);
}

function xy(evt) {
    x = (document.all) ? window.event.x : evt.pageX;
    y = (document.all) ? window.event.y : evt.pageY;
}

//-->
 
