/*--------------------------------------
	2by2 java script
---------------------------------------- */    
/*== voor customer.wp ==*/
function ChangeFax()
{                     
/*=========	
  	if (eval('document.prof.CBfax.checked') == true) {
   		document.prof.radiobutton8.checked = false;
   		document.prof.radiobutton9.checked = false;
   		document.prof.radiobutton10.checked = false;
   		document.prof.radiobutton11.checked = false;
   		document.prof.radiobutton12.checked = false;
   		document.prof.radiobutton13.checked = false;
   		document.prof.radiobutton14.checked = false;
  	}	
=========*/  	
}
//-----------------------------------------------------                  
/*== voor customer.wp ==*/
function ZetRB(cNaam)
{                                                     
                                                      
//	if (eval('document.prof.CBfax.checked') == false) {       
	                                             
	  if(cNaam == "r1m")
   		document.prof.f_ma.checked = false;
  	  if(cNaam == "r2m")
   		document.prof.f_di.checked = false;
  	  if(cNaam == "r3m")
   		document.prof.f_wo.checked = false;
  	  if(cNaam == "r4m")
   		document.prof.f_do.checked = false;
  	  if(cNaam == "r5m")
   		document.prof.f_vr.checked = false;
  	  if(cNaam == "r6m")
   		document.prof.f_za.checked = false;
  	  if(cNaam == "r7m")
   		document.prof.f_zo.checked = false;
   
  	  if(cNaam == "r1f")
   		document.prof.e_ma.checked = false;
  	  if(cNaam == "r2f")
   		document.prof.e_di.checked = false;
  	  if(cNaam == "r3f")
   		document.prof.e_wo.checked = false;
  	  if(cNaam == "r4f")
   		document.prof.e_do.checked = false;
  	  if(cNaam == "r5f")
   		document.prof.e_vr.checked = false;
  	  if(cNaam == "r6f")
   		document.prof.e_za.checked = false;
  	  if(cNaam == "r7f")
   		document.prof.e_zo.checked = false;
	   		
/*===========	
	} 
	else {                       
  	  if(cNaam == "r1f")
   		document.prof.radiobutton8.checked = false;
  	  if(cNaam == "r2f")
   		document.prof.radiobutton9.checked = false;
  	  if(cNaam == "r3f")
   		document.prof.radiobutton10.checked = false;
  	  if(cNaam == "r4f")
   		document.prof.radiobutton11.checked = false;
  	  if(cNaam == "r5f")
   		document.prof.radiobutton12.checked = false;
  	  if(cNaam == "r6f")
   		document.prof.radiobutton13.checked = false;
  	  if(cNaam == "r7f")
   		document.prof.radiobutton14.checked = false;
	}
=============*/	
}            
//-----------------------------------------------------      
function ClearRB()
{
	document.prof.e_ma.checked = false;
	document.prof.e_di.checked = false;
	document.prof.e_wo.checked = false;
	document.prof.e_do.checked = false;
	document.prof.e_vr.checked = false;
	document.prof.e_za.checked = false;
	document.prof.e_zo.checked = false;
	document.prof.f_ma.checked = false;
	document.prof.f_di.checked = false;
	document.prof.f_wo.checked = false;
	document.prof.f_do.checked = false;
	document.prof.f_vr.checked = false;
	document.prof.f_za.checked = false;
	document.prof.f_zo.checked = false;
	
}
//----------------------------------------------------
function ReDisplayProfile(sVar)
{
/*	
  if(sVar == 'F') {
  	//alert("CBfax= " + document.prof.elements['CBfax'].value);
   if(document.prof.elements['CBfax'].value == "FaxNo")
    document.location.href = "Remainprofile.wp?p=FaxNo";	
   else 
   document.location.href = "Remainprofile.wp?p=FaxYes";	
  } 
  if(sVar == 'M') {
   if(document.prof.elements['CBfax2'].value == "MailNo")
    document.location.href = "Remainprofile.wp?p=MailNo";	
   else 
   document.location.href = "Remainprofile.wp?p=MailYes";	
  } 
  if(sVar == 'N') {
   if(document.prof.elements['CBnewPro'].value == "NewPro")
    document.location.href = "Remainprofile.wp?p=NewProNo";	
   else 
   document.location.href = "Remainprofile.wp?p=NewProYes";	
  } 
  
	//document.location.href = "Remainprofile.wp";
*/	
}
//---------------------------------------------------
function ZetMailRO()
{
	document.prof.e_ma.checked = false;
	document.prof.e_di.checked = false;
	document.prof.e_wo.checked = false;
	document.prof.e_do.checked = false;
	document.prof.e_vr.checked = false;
	document.prof.e_za.checked = false;
	document.prof.e_zo.checked = false;

}
//----------------------------------------------------
function ZetFaxRO()
{
	document.prof.f_ma.checked = false;
	document.prof.f_di.checked = false;
	document.prof.f_wo.checked = false;
	document.prof.f_do.checked = false;
	document.prof.f_vr.checked = false;
	document.prof.f_za.checked = false;
	document.prof.f_zo.checked = false;
	
}
//-----------------------------------------------------
function SaveProfile(prof)
{
  document.prof.submit(prof);	
}
//-----------------------------------------------------
function SaveProfile2by2()
{
  document.location.href = "SaveProfile2by2.wp";	
}
//----------------------------------------------------


//-----------------------------------------------------      
//-- Printen van een pagina
//----------------------------------------------------
function tmt_print(bers) {
	
    function stopError() {
        return true;
    };
    window.onerror = stopError;
    if (window.print) {
        eval(bers + ".print()");
    } else {
        if (document.all) {
            var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
            document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
            WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);
            WebBrowser1.outerHTML = "";
        }
    }
}
//----------------------------------------------------
function PrintPrijsLijst(bers)
{
   window.onerror = stopError;
    if (window.print) {
        eval(bers + ".print()");
        //bers.close();
    } else {
        if (document.all) {
            var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
            document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
            WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);
            WebBrowser1.outerHTML = "";
        }
    }
    function stopError() {
    	alert("Print error");
        return true;
    };
    
}
//-----------------------------------------------------------
function PrintRma(bers)
{
  tmt_print(bers);
  tmt_print(bers);
  document.location.href = "RmaBasketClosed.wp";
}
//----------------------------------------------------
function PrintDetail(bers){
    window.onerror = stopError;
    if (window.print) {
        eval(bers + ".print()");
        //alert("Printen 1");
        //bers.close();
    } else {
        if (document.all) {
            var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
            document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
            WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);
            WebBrowser1.outerHTML = "";
            //alert("Printen 2");
        }
    }
    function stopError() {
    	alert("Print error");
        return true;
    };
    
}
//----------------------------------------------------
function terug() 
{ 
   history.back(1);
}
//-----------------------------------------------------
function OpenWindow(URL,Name,Features) 
{
   window.open(URL,Name,Features); 
}
//-----------------------------------------------------
//----------------------------------------------------
//-- volgende 3 functie's zijn voor animated gifs
//----------------------------------------------------
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//----------------------------------------------------
function MM_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 MM_findObj(n, d) { //v3.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); return x;
}
*/
function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}
//----------------------------------------------------
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_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];}
}
//----------------------------------------------------

//============= Login page ==========

function VergetenLogin() {
	
  //document.location.href= "sendpas.htm";
  window.open("/shop2by2/sendpas.htm","pw","scrollbars=yes,height=350,width=350,left=200,top=100"); 
}
//---------------------------------
function PlaceFocusLogin() {
  document.loginpage.elements['login'].focus();                                         
}
//------------------------------------------------------------------
function ResetFormLogin()
{
  document.loginpage.elements['login'].value = "";
  document.loginpage.elements['paswoord'].value = "";
  document.loginpage.elements['login'].focus();
}
//------------------------------------------------------------------
function ValideerLogin() {
  var nOk;
  nOk = 0;
  
  if(document.loginpage.elements['login'].value == "") {
    alert("Enter your logincode");                
    document.loginpage.elements['login'].focus();
    nOk = 0;
  } else {
    nOk = 1;
  }
  if(nOk == 1) {                                        
    if(document.loginpage.elements['paswoord'].value == "") {
      alert("Enter your password");                 
      document.loginpage.elements['paswoord'].focus();
      nOk = 0;
    } else {
      nOk = 1;
    }    
  }    
  
  if(nOk == 1)  {
    return true;
  } else {
    return false;    
  }  
}      
//-----------------------
function SubmitFormLogin(loginpage)
{
  if(ValideerLogin()) {	
   document.loginpage.submit(loginpage);
   document.loginpage.elements['login'].value == ""
   document.loginpage.elements['paswoord'].value == ""
  } 
}
//-----------------------
function SubmitFormRma(RmaDescription)
{
	if(ValideerRma()) {
	 document.RmaDescription.submit(RmaDescription);		
	}
	
}
//--------------------------------------
function ValideerRma()
{
	if(document.RmaDescription.elements['txtomschr'].value == "") {
		alert("Please fill in the fault description for this item");
		return false;
	} else {
		return true;
	}
	
	
}
//-----------------------------
function SubmitInit(sAktie)
{
	document.formconfig.elements['HFaktie'].value = sAktie;
	document.formconfig.submit(formconfig);	
}
//---------------------
function PlaceFocusLoginEcall() {
  document.ecallloginpage.elements['login'].focus();                                         
}

//---------------------
function SubmitFormEcallLogin()
{
  if(ValideerLoginEcall()) {	
   document.ecallloginpage.submit(ecallloginpage);
   document.ecallloginpage.elements['login'].value == ""
   document.ecallloginpage.elements['paswoord'].value == ""
  } 
}
//-----------------------
function ValideerLoginEcall() {
  var nOk;
  nOk = 0;
  
  if(document.ecallloginpage.elements['login'].value == "") {
    alert("Enter your logincode");                
    document.ecallloginpage.elements['login'].focus();
    nOk = 0;
  } else {
    nOk = 1;
  }
  if(nOk == 1) {                                        
    if(document.ecallloginpage.elements['paswoord'].value == "") {
      alert("Enter your password");                 
      document.ecallloginpage.elements['paswoord'].focus();
      nOk = 0;
    } else {
      nOk = 1;
    }    
  }    
  
  if(nOk == 1)  {
    return true;
  } else {
    return false;    
  }  
}      
//-----------------------
//==== EOF Login page ===============
function SluitWindow()
{
   window.close();
}
//---------- Prijslijsten ---------------------
function SendPR() 
{
   document.location.href= "../MailPrijs.wp";
}
//-------------
function SendXls() 
{
   document.location.href= "../MailPrijsXls.wp";
}
//-------------
function SendXML() 
{
    document.location.href= "../MailPrijsXML.wp";
}
//---------- EOF prijslijsten -----------------

//---------- SERIAL --------------------------
function PlaceFocusSerial() {
  document.formserial.elements['txtserial'].focus();                                         
}
//---------------------------------------
function SerialNrSearch(sAktie, formserial) 
{
   document.formserial.elements['HFbutton'].value = sAktie;
   if(sAktie == 'single') {
    if(document.formserial.elements['txtserial'].value == '') {
	 alert('Enter a valid serial number');
	 return;
    }		 
   } 
   if(sAktie == 'datum') {
    if(document.formserial.elements['txtdate1'].value == '') {
	 alert('Enter a valid date');
	 return;
    }	 
   } 
   if(sAktie == 'factuur') {
    if(document.formserial.elements['txtinvoice1'].value == '') {
	 alert('Enter a valid invoice number');
	 return;
    }	 
   } 
   document.formserial.submit(formserial);
}

//--------- EOF Serial -----------------------

//-------- Confirm mail adres -----------------
function MailAdres() {
 var nPos;
 cVolledig = new String(document.checkm.elements['txtmail'].value);    
 if(cVolledig = "") {
   alert("Please enter a complete email address !");
   return false;
 } else {  
   nPos = document.checkm.elements['txtmail'].value.indexOf('@');
   if(nPos <= 0) {
     alert("Please enter a valid email address !");
     return false;                                           
   } else {
    return true;
   }  
 }               
}
//---------------------------
function PlaceFocusConMail() {
  document.checkm.elements['txtmail'].focus();
}
//---------------------------
function SubmitConMail() {
 if(MailAdres) {
  document.checkm.submit(checkm);
 } 
}

//------- EOF Confirm mail adres --------------

//------ Nieuw Paswoord ----------------------
//---------------------------------
function PlaceFocusNewPW() {
  document.form1.elements['txtnewpas'].focus();                                         
}
//------------------------------------------------------------------
function SubmitFormNewPW(form1)
{
	document.form1.submit(form1);
}
//------------------------------------------------------------------
function ClearPageNewPW()
{
	document.form1.elements['txtnewpas'].value = "";
	document.form1.elements['txtnewpas'].focus(); 
}
//------------------------------------------------------------------
function ValideerNewPW() {
  var nOk;
  nOk = 0;
  
  if(document.form1.elements['txtnewpas'].value == "") {
    alert("You must enter a new password"); 
    nOk = 0;
  } else {
    nOk = 1;
  }
  
  if(nOk == 1)  {
    return true;
  } else {
    return false;    
  }  
}      
//-----------------------
//------ EOF Nieuw paswoord ------------------

//------ Basket ------------------------------
function SubmitBasket() 
{
   //document.location.href = "CloseBasket.wp";
   //parent.frames.basket.location.href = "CloseBasket.wp";
   
   //-- basket frame
   //parent.frames[3].location.href = "DummyBasket.wp";
   //parent.frames[1].location.href = "DummyBasket.wp";
   parent.frames[2].location.href = "DummyBasket.wp";
   //-- onderste frame
   //parent.frames[5].location.href = "CloseBasket.wp";
   parent.frames[3].location.href = "CloseBasket.wp";
}
//--------------------------------------------
function Klik(sStat, form1) {
 //-- pickup	
 if(sStat == "1")  {
  document.form1.elements['hiddenField'].value = "del";
  document.form1.elements['txtOther1'].value = "";
  document.form1.elements['txtOther2'].value = "";
  //document.form1.elements['RBdelivery'].value = "checked";
  document.form1.submit(form1);
 } 
 //-- delivery
 if(sStat == "2") {
  document.form1.elements['hiddenField'].value = "add";
  document.form1.submit(form1);
 } 
 //-- submit button
 if(sStat == "3") {
  document.form1.elements['hiddenField'].value = "submitbasket";
  document.form1.submit(form1);
 } 
 //-- invoice adres
 if(sStat == "4") {
  document.form1.elements['hiddenField'].value = "refresh";
  document.form1.submit(form1);
 	
 }
 //-- other delivery adres
 if(sStat == "5") {
  document.form1.elements['hiddenField'].value = "refresh";
  document.form1.submit(form1);
 	
 }


}
//-------------------------------------------
function ReturnToStart()
{
  //-- ga terug naar het hoofdframe en herlaad alles	
  if (window != top)	
   top.location.href = "index.htm"	
}
//------------------------------------------	
//------ EOF basket --------------------------

//------- ArtInfo2 --------------------------
function PlaceFocusInArtinfo() {
  document.artinfo.elements['lnAantal'].focus();                                         
}
//------------------------------------------------------------------

function CancelInArtinfo()
{
  document.location.href = "artikel.wp";
}
//------------------------------------------------------------------
function SubmitInArtinfo()
{      
   if(ValideerInArtinfo()) {	
    //-- basket displayen in juiste frame
    //parent.frames[1].location.href = "addtoshop.wp?artnr=" + document.artinfo.elements['txtArtnum'].value + "&artqty="+document.artinfo.elements['lnAantal'].value;
    parent.frames[2].location.href = "addtoshop.wp?artnr=" + document.artinfo.elements['txtArtnum'].value + "&artqty="+document.artinfo.elements['lnAantal'].value;
    //-- artikelen terug displayen in het onderste frame
    document.location.href = "artikel.wp";
   } 
}                                        
//------------------------------------------------------------------
function ValideerInArtinfo()
{
  if(document.artinfo.elements['lnAantal'].value == "") {
    alert("Enter a quantity");                
    return false;
  } else {
    if(document.artinfo.elements['lnAantal'].value == "0") {
      alert("Enter a quantity"); 
      PlaceFocusInArtinfo();               
      return false;
    } else  {
      return true;                                            
    }
  }
}
//------------------------------------------------------------------


//--------- EOF ArtInfo2 --------------------------------------------

//------- Search --------------------------------------------------
function Zoeken()
{
   var sZoek, sLink;
   sZoek = document.formSearch.elements['artnum'].value;
   sLink = "SearchItems.wp?sZ=" + sZoek ;
   //-- eigen frame terug resetten
   //document.location.href = "search.htm";
   //-- onderste frame
   parent.frames[3].location.href = sLink;   
   document.location.href = "search.htm";
}	
//------ EOF search ----------------------------------------------

//----- Invoices ------------------------------------------------
function SubmitInvoice(iOption, formInvoice)
{
  switch(iOption) {
   case 1: document.formInvoice.elements['HF'].value="1"; break;
   case 2: document.formInvoice.elements['HF'].value="2"; break;
   case 3: document.formInvoice.elements['HF'].value="3"; break;
   case 4: document.formInvoice.elements['HF'].value="4"; break;
  }
  document.formInvoice.submit(formInvoice);
}
//-------------------------
function OpenWindowDetailInv(URL,Name,Features) 
{
   window.open(URL,Name,"scrollbars=yes,height=550,width=500,left=200,top=50");
}
//---------------------------
function OpenWindowInv(URL,Name,Features) 
{
  window.open(URL,Name,"scrollbars=yes,height=700,width=650,left=100,top=50");
}
//---------------------------
function ReturnFromInvoice()
{
  document.location.href = "mainInvoice.wp";	
}
//---------------------------
function PlaceFocusInvoice() {
  document.formInvoice.elements['txtInvoice'].focus();                                         
}

//------- EOF invoices --------------------------------------------

//------- Creditnotas --------------------------------------------
function SubmitCredit(iOption)
{
  switch(iOption) {
   case 1: document.formCredit.elements['HF'].value="1"; break;
   case 2: document.formCredit.elements['HF'].value="2"; break;
   case 3: document.formCredit.elements['HF'].value="3"; break;
   case 4: document.formCredit.elements['HF'].value="4"; break;
  }
  document.formCredit.submit(formCredit);
}
//-------------------------
function OpenWindowDetailCredit(URL,Name,Features) 
{
   window.open(URL,Name,"scrollbars=yes,height=550,width=500,left=200,top=50");
}
//---------------------------
function OpenWindowCredit(URL,Name,Features) 
{
  window.open(URL,Name,"scrollbars=yes,height=700,width=650,left=100,top=50");
}
//---------------------------
function ReturnFromCredit()
{
  document.location.href = "mainCredits.wp";	
}
//---------------------------
function PlaceFocusCredit() {
  document.formCredit.elements['txtInvoice'].focus();                                         
}
//---------------------------------------

//------- EOF creditnotas ----------------------------------------

function OpenWindowPromo(URL,Name,Features) 
{
	window.open(URL,Name,"scrollbars=yes,height=550,width=500,left=150,top=50");
}
//----------------------------------------------------------------
function OpenWindowRma(URL,Name) 
{
	//window.open("http://localhost/shop2by2/RmaReady.htm","RMAReady","scrollbars=no, menubar=no,location=no,toolbar=no,titlebar=no,height=425,width=470,left=150,top=50"); 
	//var win = launchCenter("http://www.2by2.be/shop2by2/RmaReady.htm","RMAReady", 425, 470, "scrollbars=no, menubar=no,location=no,toolbar=0,titlebar=no");
	var win = launchCenter("RmaReady.htm","RMAReady", 425, 470, "scrollbars=no, menubar=no,location=no,toolbar=0,titlebar=no");

}
//-----------------------------------------------------

function launchCenter(url, name, height, width, opt) {
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
    str += "," + opt;
  }
  return window.open(url, name, str);
}
//------------------------------------------------------------------------------

function OpenWindowRMA(URL,Name,Features) 
{
   window.open(URL,Name,"scrollbars=yes,height=550,width=500,left=200,top=50");
}
//---------------------------
function ToonFrames()
{
	alert("0 - " + parent.frames[0].name);
	alert("1 - " + parent.frames[1].name);
	alert("2 - " + parent.frames[2].name);
	alert("3 - " + parent.frames[3].name);
	alert("4 - " + parent.frames[4].name);
	alert("5 - " + parent.frames[5].name);
	alert("6 - " + parent.frames[6].name);
	alert("7 - " + parent.frames[7].name);
	alert("8 - " + parent.frames[8].name);
	alert("9 - " + parent.frames[9].name);
	alert("10 - " + parent.frames[10].name);
}

