 var $j = jQuery.noConflict();


function openWindow (strUrl, name, width, height, scroll)
{

	features  = "resizable=0,location=0,directories=0,status=1,menubar=0,toolbar=0,scrollbars=";
	features += (scroll ? "1" : "0");
	features += ",width=" + width + ",height=" + height;

	if(name.length == 0)
		name = 'WMF';
	var  xwin = window.open(strUrl, name, features);
	xwin.focus();
}

function openBasketWindow (strUrl)
{
	//strUrl +="?PID=";
	//strUrl += myForm.PID.value;
	//strUrl += "&number=";
	//strUrl += myForm.number.value;
	//strUrl += "&pgid=";
	//strUrl += myForm.pgid.value;
	openWindow(strUrl, 'WK', 275, 192, false);
}


function openRelationWindow (strUrl)
{
	//strUrl +="?PID=";
	//strUrl += myForm.PID.value;
	//strUrl += "&number=";
	//strUrl += myForm.number.value;
	//strUrl += "&pgid=";
	//strUrl += myForm.pgid.value;
	openWindow(strUrl, 'REL', 800, 600, true);
}





function openBasket ()
{
	if(opener.opener){

		opener.opener.location.href = 'basket.php';
		opener.close();
		window.close();
	}else{
		opener.location.href = 'basket.php';
		window.close();
	}
}


	function updateBasket(qty, pid){
		var link = 'basket.php?psn=' + pid + '&qty=' + qty + '&source=upd';
		window.location.href = link;
	}


	function deleteBasketItem(pid){
			var link ='basket.php?psn=' + pid + '&source=del';
			window.location.href = link;
	}



function toggle(elementID){

		var id = document.getElementById(elementID);
		if(id.style.display == 'none')
			id.style.display = 'block';
		else
			id.style.display = 'none';

	}


function toggleTech(elementID, idLink, txteinblenden, txtausblenden){
		var id = document.getElementById(elementID);
		var id2 = document.getElementById(idLink);
		if(id.style.display == 'none'){
			id.style.display = 'block';
			id2.innerHTML  = txtausblenden;
		}else{
			id.style.display = 'none';
			id2.innerHTML  = txteinblenden;
		}
}



function showAjaxDiv(elementID, elementIDLink, txteinblenden, txtausblenden, strUlr){

	var div = document.getElementById(elementID);
	var link = document.getElementById(elementIDLink);

	if(div.style.display == 'none'){

			div.style.display = 'block';
			link.innerHTML  = txtausblenden;
			ajaxUpdate_GET(elementID, strUlr)
	}else{
		div.style.display = 'none';
		link.innerHTML  = txteinblenden;
	}


}


function getLinkText(elementID, elementIDLink, txteinblenden, txtausblenden){

		var div = document.getElementById(elementID);
		var link = document.getElementById(elementIDLink);
		if(div.style.display == 'none'){
			link.innerHTML  = txteinblenden;
		}else{
			link.innerHTML  = txtausblenden;
		}
}


function ajaxUpdate_GET(strElementID, strUlr){
	new Ajax.Updater(strElementID,strUlr);
}



function MM_jumpMenu (targ, selObj, restore)
{
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex = 0;
}

function MM_showHideLayers()
{ //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function checkKey(id) {
    	Ereignis = window.event;
   	var idbevor;
   	var idafter = id+1;

   	if (id !== 0)idbevor = id-1;
	else idbevor = id;

    if(Ereignis.keyCode === 9){ // Tab
    	if (Ereignis.shiftKey){
    		document.forms.FormProductNumberSearch['ID'+idbevor].focus();
    		return;
    	}else{
    		return;
    	}
    }
     if((Ereignis.keyCode === 8)|| (Ereignis.keyCode === 46) ){ // loeschen & entfernen
     	 document.forms.FormProductNumberSearch['ID'+idbevor].value = '';
      document.forms.FormProductNumberSearch['ID'+idbevor].focus();
    	return;
    }
    document.forms.FormProductNumberSearch['ID'+idafter].focus();
}


function swapImgRestore() { //v3.0
		var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function swapImage() { //v3.0
		var i,j=0,x,a=swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_findObj(n, d) { //v4.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		 if(!x && document.getElementById) x=document.getElementById(n); return x;
}


function doCallback(){
	
	var salutation 	= document.forms.f_call.sal.value;
	var name 		= document.forms.f_call.name.value;
	var phone 		= document.forms.f_call.phone.value;
	var subject		= document.forms.f_call.subject.value;
	var firstname	= document.forms.f_call.firstname.value;
	var countryid	= document.forms.f_call.countryid.value;
	var email		= document.forms.f_call.email.value;
	var preselection	= document.forms.f_call.preselection.value;
	
	
	var sal = '';

	 if (document.f_call.sal[0].checked){
		sal = document.f_call.sal[0].value;
	 }

      if (document.f_call.sal[1].checked) {
     	sal = document.f_call.sal[1].value;
      }

    document.getElementById('div_ajax').innerHTML = '<img src="images/layout/warten.gif"/><br/>loading...';	
    
	new Ajax.Request('callback.php', {
		method: "post",
		parameters: {
			ajax: '1',
			name: name,
			phone: phone,
			sal: sal,
			subject: subject,
			firstname: firstname,
			countryid: countryid,
			preselection: preselection,
			email: email
		},
    	onSuccess: function(transport) {
			document.getElementById('div_ajax').innerHTML = transport.responseText; 
		}
	});
}

function doCatalogOrder()
{
	document.getElementById('div_orderCatalog').innerHTML = '<img src="images/layout/warten.gif"/><br/>loading...';

	new Ajax.Request("orderCatalog.php", {
		method: "post",
    	onSuccess: function(transport) {
			index = transport.responseText.indexOf("[ERROR]");
			if (index != -1) {
				window.location.href = 'login.php';
			} else {
				document.getElementById('div_orderCatalog').innerHTML = transport.responseText; 
			}
		}
	});
}

