/*/ COPYRIGHT & CODE OWNERSHIP

1. As per agreement with the client, the client may not distribute any coding, scripts or functions freely or at a fee to any persons, whether knowingly or unintentionally without the consent of Eiledon SOlutions CC.
2. Modifying any of the coding, functions or scripts produced for the client is at the users own risk and no free support can be provided.
3. This notice applies to all scripts, coding and function, etc, produced for the client.

/*/
function Nav(which,a,meth){
if(meth == "on"){ //alert(which);
which.style.backgroundImage=which.style.backgroundImage.replace('Nav1','Nav2');
document.getElementById(a+"1").className = 'a2';
} else { 
which.style.backgroundImage=which.style.backgroundImage.replace('Nav2','Nav1');
document.getElementById(a+"1").className = '';
}
}

function lineTotal(price,qty,div){
price = price;
total = (price)*qty;				
document.getElementById(div).innerHTML="R "+total;
}
function clearTotal(div){
document.getElementById(div).innerHTML="";
}
function qties(counter,value,button){
counter += value;
if(counter == 0){ button.disabled = true; } else { button.disabled = false; } 
}

function isEmptyStr(strng,err) {
var error = "";
  if (strng.length == 0) {
     error = err + "\n";
  }
return error;	  
}


// email
function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "Your email address contains illegal characters.\n";
       }
    }
return error;    
}
function isEmptyUser(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please create a Username.\n";
  }
return error;	  
}
function isEmptyPass(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please create a Password.\n";
  }
return error;	  
}
function isEmptyPass2(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please Confirm your Password.\n";
  }
return error;	  
}
function isNoMatch() {
var error = "";
  if (theForm.pass.value != theForm.pass2.value) {
     error = "Your Passwords do Not Match.\n";
  }
return error;	  
}
function isEmptyName(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please provide your Name.\n";
  }
return error;	  
}
function isEmptySName(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please provide your Surname.\n";
  }
return error;	  
}

// non-empty textbox
function isEmptyTel(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please provide a Telephone number. \n";
  }else {
//test email for illegal characters
       var illegalChars= /[\@\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "Your Telephone Number contains illegal characters.\n";
       }
    }
return error;	  
}
function isEmptyCell(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please provide a Cellphone Number. \n";
  }else {
//test email for illegal characters
       var illegalChars= /[\@\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "Your Cellphone Number contains illegal characters.\n";
       }
    }
return error;	  
}




function qtytwo(counter,add,cart){
document.getElementById("totalqty").value = parseInt(document.getElementById("totalqty").value) - parseInt(document.getElementById(counter).value);
document.getElementById(counter).value =  parseInt(add);
document.getElementById("totalqty").value = parseInt(document.getElementById("totalqty").value) + parseInt(document.getElementById(counter).value);

/*/if(add == 0){
document.getElementById("totalqty").value = parseInt(document.getElementById("totalqty").value) - parseInt(document.getElementById(counter).value);
document.getElementById(counter).value =  parseInt(add);
document.getElementById("totalqty").value = parseInt(document.getElementById("totalqty").value) + parseInt(document.getElementById(counter).value);
} else {
document.getElementById(counter).value =  parseInt(add);
document.getElementById("totalqty").value = parseInt(document.getElementById("totalqty").value) + parseInt(document.getElementById(counter).value);
}/*/
if(document.getElementById("totalqty").value > 0){ cart.disabled = false; }  else { cart.disabled = true; }

}

function delitem(id,itemid,title){

if(confirm("Are you sure you want to remove this item from your cart?")){
	location.href='index.php?go=cart&action=delitem&id='+ id +'&item=' + itemid +''; }


}
function formatCurrency(num) {
<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site:  http://www7.ewebcity.com/cyanide7 -->
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + 'R ' + num + '.' + cents);
}
function delitotal(deln,cart,delc,delt){
pDeln = parseInt(deln);
pDelc = pDeln+parseInt(cart);
delc.value = formatCurrency(pDeln);
delt.value = formatCurrency(pDelc);
}

function checkWholeForm(theForm) {
    var why = "";
    why += isEmptyName(theForm.name.value);
    why += isEmptyTel(theForm.tel.value);
    why += checkEmail(theForm.email.value);
    why += isEmptyMessage(theForm.message.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}
// email
function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}

function isEmptyName(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please include your name.\n";
  }
return error;	  
}
// non-empty textbox
function isEmptyTel(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please provide a contact number. \n";
  }else {
//test email for illegal characters
       var illegalChars= /[\@\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "Your contact number contains illegal characters.\n";
       }
    }
return error;	  
}
function isEmptyMessage(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please provide a message. \n";
  } 
return error;	  
}