function banFlash(){
document.write('<object  width="205" height="85">');
document.write('<param name="movie" value="images1/baz1.swf" />');
document.write('<param name="quality" value="high" />');
document.write('<embed src="images1/baz1.swf" quality="high"  width="205" height="85"></embed>');
document.write('</object>');	
}
function http(field){
element(field).value= element(field).value.replace("http://","");
}

function element(id){
return document.getElementById(id);
}

function kwcount(field,icnt,imax){
var v = field.value;
maxl = parseInt(imax)+1;
a = v.split(',');
if(a.length > maxl){
	field.value = field.value.replace(/,+[A-Za-z0-9+]+$/,'');//0,field.value.lastIndexOf(',')-1);
	field.value = field.value.substring(0,field.value.lastIndexOf(','));
}
element(icnt).value=a.length-1+" of "+imax;
 }

function ValCallb(form){
var error = "";
	
error += dropdown(form.title.value,"Please select your Title.");
error += isBlank(form.name.value,"Please enter your Name.");
error += isBlank(form.surname.value,"Please enter your Surname.");
error += checkEmail(form.email.value,"Please enter a valid Email Address.");
error += isEmptyNum(form.tel.value,"Please enter a valid  Phone Number.\n");
error += isBlank(form.comments.value,"Please provide enter a message.");	
}

function checkApp(form,maxi){
var error = "";
/*//*/
error += dropdown(form.salutation.value,"Please select your Title.");
error += isBlank(form.name.value,"Please enter your Name.");
error += isBlank(form.surname.value,"Please enter your Surname.");
error += isBlank(form.company.value,"Please enter your Company name.");
error += checkEmail(form.email.value,"Please enter a valid Company Email Address.");
error += isEmptyNum(form.tel.value,"Please enter a valid Company Phone Number.\n");

error += isBlank(form.title.value,"Please provide a Title for your listing.");
error += dropdown(form.cat,"Please select a Category for your listing.");
error += dropdown(form.region,"Please select a Region for your listing.");
error += isBlank(form.tel.value,"Please provide a Telephone number for your listing.");
error += checkEmail(form.email.value,"Please enter a valid Email Address for your listing.");
error += isBlank(form.description.value,"Please enter a Description for your listing.");
error += isBlank(form.keywords.value,"Please enter a Keywords for your listing.");
error += checkkeys(maxi,form.keywords,"You are only allowed MAX keywords.");
error += chox('terms',"You must agree to the terms and conditions.");


if(error != ""){ alert(error); return false; } 
}

function checkContact(form){
var error = "";
/*//*/
error += dropdown(form.title,"Please select your Title.");
error += isBlank(form.name.value,"Please enter your Name.");
error += isBlank(form.surname.value,"Please enter your Surname.");
error += checkEmail(form.email.value,"Please enter a valid Email Address.");
error += isEmptyNum(form.tel.value,"Please enter a valid Phone Number.");

error += isBlank(form.comments.value,"Please enter you Comments.");

if(error != ""){ alert(error); return false; } 
}



function checkkeys(maxi,field,mes){
	var error = "";
imax = parseInt(maxi)+1;
a = field.value.split(',');
	if(maxi > 0){
		if(a.length <= imax){
			error = "";
		} else {
			error = mes.replace("MAX",maxi);
		}
	} else {
					error = "";
}
return error;
}
function chox(field,mes){
	var error = "";
		if(element(field).checked == false){
			error = mes;
		} return error;
}
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

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 popUp2($url,w,h) {
   mywindow = window.open ($url,"mywindow","location=0,status=0,scrollbars=1,toolbar=0,menubar=0,titlebar=0,width=" + w + ",height=" + h + "");
  mywindow.moveTo(300,200);
 }
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(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='index2.php?content=cart&action=delitem&id='+ id +'&item=' + itemid +''; }
}
function formatCurrency(num) {
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 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;
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
 
function isBlank(str,msg){
	var error = "";
	str = trim(str)
	if(str.length == 0){ error = msg +'\n'; }
	return error;
	}

function fieldmatch(str1,str2,msg){
	var error = "";
	if(str1 != str2){
	error = msg +'\n';
	}
	return error;

}
function checkEmail (strng,msg) {
var error="";
	if (isBlank(strng)) { error = msg + "\n"; }
	
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(strng))) { error = msg + "\n"; }
		else {
		   var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
			 if (strng.match(illegalChars)) { error = msg + "\n"; }
		}
	return error;    
}
function isEmptyNum(strng,msg) {
var error = "";
	if (isBlank(strng)) { error = msg + "\n"; } else {
		   var illegalChars= /[\@\<\>\,\;\:\\\"\[\]][a-zA-z]/
			 if (strng.match(illegalChars)) { error = msg + "\n"; }
		}
	return error;	  
}
function valNum(strng,msg) {
var error = "";
	if(strng.length != 0){
		   var illegalChars= /[\@\<\>\,\;\:\\\"\[\]]/
			 if (strng.match(illegalChars)) { error = msg + "\n"; }
	}
	return error;	  
}
function radio(radiobut,strng){
var error = "";
var radio_choice = false;
for (i = 0; i < radiobut.length; i++){
if (radiobut[i].checked)
radio_choice = true; 
}
if (!radio_choice){ error = ""+strng+"\n"; }
return error; }

function dropdown(menu,strng){
var error = "";
if( menu.value == "0"){
	error = strng+" \n";
}
return error; }
 
			
function toggleLayer(whichLayer){
if (document.getElementById) {
	// this is the way the standards work
	var style2 = document.getElementById(whichLayer).style;
	style2.display = style2.display? "":"block";
}
else if (document.all){
	// this is the way old msie versions work
	var style2 = document.all[whichLayer].style;
	style2.display = style2.display? "":"block";
} else if (document.layers) {
	// this is the way nn4 works
	var style2 = document.layers[whichLayer].style;
	style2.display = style2.display? "":"block"; }
}
function dropother(menu,layer){
 if ( menu.selectedIndex == 1 ){
 	toggleLayer(layer); } else { 	
	if(document.getElementById(layer).style.display == "block"){
 	toggleLayer(layer); } }

}/*//*/
