	function showhide(id){
		if (document.getElementById){
			obj = document.getElementById(id);
			if (obj.style.display == "none"){
				obj.style.display = "";
			} else {
				obj.style.display = "none";
			}
		}
	}
	
	function loadUnLoadCalenderWithParam(m, y){
		showhide('dateSelector'); 
		showhide('text-contents');
		
		if(document.getElementById('text-contents').style.display == ""){
			// displayQCalendar('<?php echo date("n"); ?>', '<?php echo date("Y"); ?>', 'text-contents', '0');
			displayQCalendar(m, y, 'text-contents', '0');
		}
	}
	
	function chooseDate(d, m, y){
		if((d == "14") && (m == "02") && (y == "2010")){
			alert("We apologize for the inconvenience. We're completely booked for February 14, 2010 (Valentine's Day). Please try an alternate date");
		} else {
			document.checkout_address.delivery_day.value = d;
			document.checkout_address.delivery_month.value = m;
			document.checkout_address.delivery_year.value = y;
			loadUnLoadCalender();
		}
	}
	

	function monitorClick(e){
        if(!document.getElementById('text-contents')) return;
		var evt = (e) ? e : event;
       
        var theElem = (evt.srcElement) ? evt.srcElement : evt.target;

        while(theElem!=null){
          if(theElem.id == "text-contents") {
            document.getElementById('text-contents').style.display = '';
            return true;
          }
		 
          theElem = theElem.offsetParent;         
        }
        if(document.getElementById('text-contents').style.display == "") loadUnLoadCalender();
        return true;
    }

    document.onclick = monitorClick;
	document.onmousedown = monitorClick;

////Login or registration Functions
function displayQCalendar(m, y, divID, pid){
  var ran_no=(Math.round((Math.random()*9999)));	
  var param = '?m='+m+'&y='+y+'&ran='+ran_no+'&divID='+divID; //+'&osCsid='+sid;	
  var data = 'm='+m+'&y='+y+'&ran='+ran_no+'&divID='+divID; //+'&osCsid='+sid;
	
  $.ajax({
   type: "GET",
   url: "quick_calendar.php" + param,
   data: data,
   success: function(msg){
   	   document.getElementById(divID).innerHTML = msg; 
   }
 });

}

function saveGiftMessageToDB(gfBoxID){
  var param = "";	
  var data  = "cmd=save_gift_message";
  data += '&gmEditValue=' + escape(document.getElementById("gmEditValue" + gfBoxID).value);
  data += '&gmEditID=' + escape(gfBoxID);
	
  $.ajax({
   type: "POST",
   url: "_ajaxProcessor.php" + param,
   data: data,
   success: function(msg){
   	   // alert(msg);
   }
 });
}

function saveAddressChangeToDB(addFieldName){
  var param = "";	
  var data  = "cmd=save_address";
  data += '&gmEditValue=' + escape(document.getElementById(addFieldName + "EditValue").value);
  data += '&gmEditField=' + escape(addFieldName);
	
  $.ajax({
   type: "POST",
   url: "_ajaxProcessor.php" + param,
   data: data,
   success: function(msg){
   	   // alert(msg);
   }
 });
}
/*
function proceedForMashreqBankForm(){
  var param = "?osCsid=" + sid;	
  var data  = "cmd=emailAndProceedForMashreqPaymentModule";

  document.getElementById('btnMashreqBankPayment').value = 'Please Wait !!!';
  document.getElementById('btnMashreqBankPayment').disabled = true;
  document.getElementById('btnPayWithPayPal').disabled = true;
  //document.getElementById('btnGoogleCheckoutPayment').disabled = true;

  $.ajax({
   type: "POST",
   url: "ajax_checkout.php" + param,
   data: data,
   success: function(msg){
	// $('#mainCartCheckoutShoppingCartArea').html(msg);
	submitMashreqBankForm();
   }
 });	
  
}
*/
function proceedForGoogleCheckoutModuleForm(){
  var param = "";	
  var data  = "cmd=emailAndProceedForGooglePaymentModule";

  $.ajax({
   type: "POST",
   url: "_ajaxProcessor.php" + param,
   data: data,
   success: function(msg){
	document.getElementById('btnGoogleCheckoutPayment').form.submit();
   }
 });	
  
}

function proceedForPayPalModuleForm(){
  var param = "";	
  var data  = "cmd=emailAndProceedForPayPalPaymentModule";

  $.ajax({
   type: "POST",
   url: "_ajaxProcessor.php" + param,
   data: data,
   success: function(msg){
	document.getElementById('btnPayPalPayment').form.submit();
   }
 });	
  
}

function proceedForPayPalExpressCheckoutModuleForm(){
  var param = "";	
  var data  = "cmd=emailAndProceedForPayPalExpressCheckoutPaymentModule";

  $.ajax({
   type: "POST",
   url: "_ajaxProcessor.php" + param,
   data: data,
   success: function(msg){
	document.frmPayPalExpChk.submit();
	//document.getElementById('btnPayPalExpChk').form.submit();
   }
 });	
	
}

//function proceedForCashOnDelivery(url){
function proceedForCashOnDeliveryModuleForm(){	
  var param = "";	
  var data  = "cmd=emailAndProceedForCashOnDeliveryModule";

  $.ajax({
   type: "POST",
   url: "_ajaxProcessor.php" + param,
   data: data,
   success: function(msg){
	document.getElementById('btnCODPayment').form.submit();
   }
 });	
}



function checkInputType(chacha, e){
	
	var unicode = (e == null) ? 0 : (e.charCode ? e.charCode : e.keyCode);
	//alert(unicode);
	if ((unicode==46) || (unicode==37) || (unicode==39) || (unicode==8)){ //if the key isn't the backspace key (which we should allow)
	} else { //if the key isn't the backspace key (which we should allow)
		if ((unicode<48)||(unicode>57)){ //if not a number
var SplitName = chacha.value;
chacha.value = ""
//alert(SplitName.length + " -- " + chacha.value);
for (num = 0; num < SplitName.length; num++) {
	if(((SplitName.charCodeAt(num) >= 48) && (SplitName.charCodeAt(num) <= 57)))
	  chacha.value = chacha.value + SplitName.substr(num, 1);
	//alert(SplitName.substr(num, 1));
}
} 
}

}

function executeJavascriptInIt(productItems){
	var productItemsArray = productItems.split('<script language="javascript">');
	for(var i=1; i<productItemsArray.length; i++){
		eval((productItemsArray[i].split('</script>'))[0]);
	}
}
