function addbookmark()
{
bookmarkurl="http://www.condom003.com";
bookmarktitle="Cheap and Quakity Condom"
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		Button1_over = newImage("../images/Button1-over.gif");
		Button2_over = newImage("../images/Button2-over.gif");
		Button3_over = newImage("../images/Button3-over.gif");
		Button4_over = newImage("../images/Button4-over.gif");
		Button5_over = newImage("../images/Button5-over.gif");
		preloadFlag = true;
	}
}
function show_payment(val) {
	document.getElementById('payment_method').innerHTML = document.getElementById(val).innerHTML;
}

function show_message() {
	alert('The online payment is currently not available. Kindly proceed by Bank Transfer at the time being. Sorry for any inconvenience caused.') ;
	document.getElementById('bank_transfer').checked = true;
	show_payment('bank');
}

function check_purchase_form() {
  var frm = document.getElementById('purchase_form');
  var all_error = "";
  var finished = true;
  for(var i=0; i<frm.elements.length; ++i) {
    error = "";
    if(frm.elements[i].type == "text") {

      // Check if mandatory field is unset
      if(frm.elements[i].value == "" && frm.elements[i].parentNode.innerHTML.search(/mandatory/) >= 0) {
        error = "mandatory field is unset";
      }

      // Check if email is invalid
      if(frm.elements[i].name.search(/email/i) >= 0) {
        var str = frm.elements[i].value;
        var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
        var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
        if (reg1.test(str) || !reg2.test(str)) {
          error = "email is invalid";
        }
      }

      if(error.length > 0) {
        all_error += error;
        frm.elements[i].style.border = "2px solid red";
        frm.elements[i].style.color = "red";
        frm.elements[i].onchange = purchase_form;
        if(finished) frm.elements[i].focus();
        var finished = false;
      }
      else {
        frm.elements[i].style.border = "2px inset";
        frm.elements[i].style.color = "black";
        frm.elements[i].onchange = null;
      }
    }
  }

  if (!frm.terms.checked == true && finished == true)
  { 
			alert('Your have to agree with our term and condition');
			var finished = false;
  }

  return finished;
}

function  check_friend_form() {
	
	frm = document.forms['recommend'];
	if(!frm.yourname.value) 
		{ 
			frm.yourname.focus(); 
			alert('Please fill in the your name'); return false; 
		}
	if(!frm.youremail.value) 
		{ 
			frm.youremail.focus(); 
			alert('Please fill in the your email address'); return false; 
		}
	if( frm.youremail.value.indexOf("@") == -1 || frm.youremail.value.indexOf(".") == -1)
		{
			frm.youremail.focus();
			alert('The format of your email address is invalid'); return false;
		}
	//if(!frm.friendname.value) 
	//	{ 
	//		frm.friendname.focus(); 
	//		alert('Please fill in the your friend\'s name'); return false; 
	//	}
	if(!frm.friendemail.value) 
		{ 
			frm.friendemail.focus(); 
			alert('Please fill in the your friend\'s email address'); return false; 
		}
	if( frm.friendemail.value.indexOf("@") == -1 || frm.friendemail.value.indexOf(".") == -1)
		{
			frm.friendemail.focus();
			alert('The format of your frined\' email address is invalid'); return false;
		}
	if(!frm.emailsubject.value) 
		{ 
			frm.emailsubject.focus(); 
			alert('Please fill in the your email subject'); return false; 
		}
	if (frm.message.value != frm.message.value)
		{ 
			frm.rpassword.focus(); 
			alert('Please fill in the message that your like email to your friend'); return false; 
		}
	return true;
}

function  check_contact_form() 
{
frm = document.forms['contact_form'];

	if(!frm.name.value) 
		{ 
			frm.name.focus(); 
			alert('Please fill in the your name'); return false; 
		}
	if(!frm.email.value) 
		{ 
			frm.email.focus(); 
			alert('Please fill in the your email address'); return false; 
		}
	if( frm.email.value.indexOf("@") == -1 || frm.email.value.indexOf(".") == -1)
		{
			frm.email.focus();
			alert('The format of your email address is invalid'); return false;
		}
	if(!frm.message.value) 
		{ 
			frm.message.focus(); 
			alert('Please fill in the your message'); return false; 
		}
	return true;
}

function  check_friend_form() {
	
	frm = document.forms['recommend'];
	if(!frm.yourname.value) 
		{ 
			frm.yourname.focus(); 
			alert('Please fill in the your name'); return false; 
		}
	if(!frm.youremail.value) 
		{ 
			frm.youremail.focus(); 
			alert('Please fill in the your email address'); return false; 
		}
	if( frm.youremail.value.indexOf("@") == -1 || frm.youremail.value.indexOf(".") == -1)
		{
			frm.youremail.focus();
			alert('The format of your email address is invalid'); return false;
		}
	//if(!frm.friendname.value) 
	//	{ 
	//		frm.friendname.focus(); 
	//		alert('Please fill in the your friend\'s name'); return false; 
	//	}
	if(!frm.friendemail.value) 
		{ 
			frm.friendemail.focus(); 
			alert('Please fill in the your friend\'s email address'); return false; 
		}
	if( frm.friendemail.value.indexOf("@") == -1 || frm.friendemail.value.indexOf(".") == -1)
		{
			frm.friendemail.focus();
			alert('The format of your frined\' email address is invalid'); return false;
		}
	if(!frm.emailsubject.value) 
		{ 
			frm.emailsubject.focus(); 
			alert('Please fill in the your email subject'); return false; 
		}
	if (frm.message.value != frm.message.value)
		{ 
			frm.rpassword.focus(); 
			alert('Please fill in the message that your like email to your friend'); return false; 
		}
	return true;
}

function  check_contact_form() 
{
frm = document.forms['contact_form'];

	if(!frm.name.value) 
		{ 
			frm.name.focus(); 
			alert('Please fill in the your name'); return false; 
		}
	if(!frm.email.value) 
		{ 
			frm.email.focus(); 
			alert('Please fill in the your email address'); return false; 
		}
	if( frm.email.value.indexOf("@") == -1 || frm.email.value.indexOf(".") == -1)
		{
			frm.email.focus();
			alert('The format of your email address is invalid'); return false;
		}
	if(!frm.message.value) 
		{ 
			frm.message.focus(); 
			alert('Please fill in the your message'); return false; 
		}
	return true;
}

function add_qty(id) {

	var id;	
	var qty = document.getElementById(id+'_qty').value;
	var nqty = parseInt(qty)+1;
	document.getElementById(id+'_qty').value = nqty;

}
function minus_qty(id) {

	var id;	
	var qty = document.getElementById(id+'_qty').value;
	if (qty == 0)
	{
		return;
	} else 
	{
		var nqty = qty-1;
		document.getElementById(id+'_qty').value = nqty;
	}
}
function show_basket_detail(val) {
	document.getElementById('show_detail').innerHTML = document.getElementById(val).innerHTML;
}