/*
 *    for trim .....
 */
      
   function trim(stringToTrim){
	   return stringToTrim.replace(/^\s+|\s+$/g,"");
	}

/*
 * Function to allow one JavaScript file to be included by another.
 * Copyright (C) 2006-08 www.cryer.co.uk
 */ 

    function IncludeJavaScript(jsFile){
      document.write('<script type="text/javascript" src="'
        + jsFile + '"></scr' + 'ipt>'); 
    }

/*
 *    calling another javascript file from this script...
 */

	IncludeJavaScript('js/ajax.js');
	IncludeJavaScript('js/modal-message.js');
	IncludeJavaScript('js/ajax-dynamic-content.js');
	
/*
 *    creating class for select menu
 */

function selectMenu (){
	
	  	this.id_seperator = '';
		this.name_seperator = '';
		this.ingredient_amount  = 0;
		this.I_ID    = 0;
		this.R_ID    = 0;
		this.U_ID    = 0;
		this.I_Name  = '';
		this.I_Price = 0;
		this.checkRadio = 0;

		this.chooseMenu = function (id){
		
			var currentSelected = document.getElementById('selectedMenu').value; 
			document.getElementById('menu'+currentSelected).style.display = 'none';
			document.getElementById('menu'+id).style.display              = 'block';
			document.getElementById('selectedMenu').value                 =  id;
	
			document.getElementById('borderRight'+currentSelected).style.borderRightWidth   = "1px"; 
			document.getElementById('borderRight'+currentSelected).style.borderRightStyle   = "solid"; 
			document.getElementById('borderRight'+currentSelected).style.borderRightColor   = "#dadada"; 	  
			
			document.getElementById('borderRight'+id).style.borderRightWidth  = ""; 
			document.getElementById('borderRight'+id).style.borderRightStyle  = ""; 
			document.getElementById('borderRight'+id).style.borderRightColor  = ""; 	  		
	  }	 

/*
 *   call to the ajax function.
 */

  this.ajaxCall = function (url,functionName){		  			
			 AJAXLIB.makeGetRequest(url,functionName);
       }

///////////////////////////////////////////// Add To Section ///////////////////////////////////////////////////

/*
 *    buulding ajax url to call
 */	 
 
	   this.buildAjaxUrlForAddToCart = function (I_ID,R_ID,U_ID,I_Name,I_Price,counter){		 
	  
		this.I_ID=I_ID;
		this.R_ID=R_ID;
		this.U_ID=U_ID;
		this.I_Name=I_Name;
		this.I_Price=I_Price; 
		
		this.checkRadio = 0;
	   
		// check for selected ingredinents 
	  	this.checkSelectedIngrediends(counter);	
		
		if (this.checkRadio)
		  return;
								
		// adding ingredients price ..
		I_Price = parseFloat(I_Price) + parseFloat(this.ingredient_amount);
		
		this.I_Price=I_Price;
				
        var url = 'ajax/cart_ajax.php?I_ID='+I_ID+'&R_ID='+R_ID+'&U_ID='+U_ID+'&item_ingrediends='+this.id_seperator+'&C_Amount='+I_Price+'&action=add&inst='+document.getElementById('instruction').value;
							
		this.ajaxCall(url,this.ajaxResponseFunctionForAddToCart);	  
	 }
	 	
/*
 *    ajax function  for add to cart ...
 */
	this.ajaxResponseFunctionForAddToCart = function (resText)
	{			//alert(resText);
   			oSelectMenu.addItem(oSelectMenu.I_ID,oSelectMenu.U_ID,oSelectMenu.I_Name,oSelectMenu.I_Price,oSelectMenu.name_seperator,resText,oSelectMenu.R_ID);
			closeMessage();
    }



/*
 *    Add item to cart
 */
	
	this.addItem = function (I_ID,U_ID,I_Name,I_Price,ingredient_name,C_ID,R_ID) {		 
			I_Price=I_Price.toFixed(2);
			C_Quentity=1;

		var value = "ajax/select_ingredients_ajax.php?I_ID="+I_ID+"&R_ID="+R_ID+"&C_ID="+C_ID+"&action=edit&selIngredients="+ingredient_name;
			
		var str	= '<div id=cart_content'+C_ID+'>';
		    str	+= '<div class="grey_link" style="width:60px; text-align:left; font-weight:normal; float:left; margin-left:15px;';		
		    str += 'margin-top:10px">'+I_Name+'</div>';            
			str += '<div class="grey_link" style="width:30px; text-align:left; font-weight:normal; float:left; margin-left:15px;';			
            str += 'margin-top:20px; text-align:center"><input type="text" size="1" name="test" id="quantity'+C_ID+'" value="'+C_Quentity+'"  onchange="oSelectMenu.buildAjaxUrlForUpdateQuantity(this.value,'+C_ID+','+I_Price+');"/></div>';									
            str += '<div class="grey_link" style="width:50px; text-align:left; font-weight:normal; font-size:14px; float:left;';
			str += 'margin-left:15px; margin-top:22px; text-align:center" id=Item_Price'+C_ID+'>&pound; '+I_Price+'</div>';
			str +=  '<div class="grey_link" style="width:90%; text-align:left; font-weight:normal; float:left; margin-left:15px; margin-top:10px">';
			str += '<table width="100%"><tr><td id=Ingredient_name'+C_ID+' >'+ingredient_name+'</td></tr></table>';
			str += '</div>';
            str += '<div class="remove_edit"><a href="#" onclick="oSelectMenu.buildAjaxUrlForRemoveFromCart('+C_ID+');return false;">Remove</a>';
			str += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'            
			str += '<a href="#" onclick="displayMessage(\''+value+'\')";return false>Edit</a></div></div>';

	       		 
		   var b=trim(document.getElementById('Subtotal').innerHTML).split(' ');
	
		   if (isNaN(b[1]))		
		       b[1] = 0;
			 
		   var a=parseFloat(I_Price) + parseFloat(b[1]);
			
	 		document.getElementById('Subtotal').innerHTML  = '&pound; '+a.toFixed(2);
			
			document.getElementById('total').innerHTML  = '&pound; '+a.toFixed(2);
			
		    document.getElementById('myTabletd').innerHTML  += str;
		}

/*
 *    get checked ingrediends...
 */

    this.checkSelectedIngrediends  = function (counter) {

		this.id_seperator   	= '';
		this.name_seperator 	= '';
		this.ingredient_amount  = 0;
		
		var result  = Array();
		var flag    = 0;
        
		for (var i=0;i<counter;i++)
		  {		
			for(var j=0;;j++)
			   {		
					if (document.getElementById("check"+i+j))	
					    {
						  
						  if (document.getElementById("check"+i+j).type == 'radio' &&  j == 0 )
								flag =1;   
						   
						  if(document.getElementById("check"+i+j).checked)
						    {
							   flag = 0;	 
							   result = document.getElementById("check"+i+j).value.split('_');    					
							   this.ingredient_amount = parseFloat(this.ingredient_amount) + parseFloat(result[2]);			   
							   if (this.id_seperator == '')
								 {					 				   					
								   this.id_seperator = result[0];
								   this.name_seperator = result[1];
								 }
							   else
								 {
								   this.id_seperator = this.id_seperator +','+result[0];
								   this.name_seperator = this.name_seperator +','+result[1];
								 }								
							}						      				
						}
					else
					   break;
			   }
			  /*if (flag)
			   {
			   document.getElementById('radio'+i).style.display = 'block';
			   this.checkRadio = 1;
			   }*/
			   
		  }
	}


/////////////////////////////////////////// end of add section //////////////////////////////////////////////////


/////////////////////////////////////////// Remove from cart section //////////////////////////////

/*
 *    building url for Remove item form cart...
 */
		
   this.buildAjaxUrlForRemoveFromCart = function (C_ID)
   {
	    if (confirm('Are you sure you want to remove this item ?')){
			   var url = 'ajax/cart_ajax.php?C_ID='+C_ID+'&action=remove';
			   this.ajaxCall(url,this.ajaxResponseFunctionForRemoveFromCart);   
			   document.getElementById('cart_content'+C_ID).style.display = 'none';
			
			var b,c;
			c=trim(document.getElementById('Item_Price'+C_ID).innerHTML).split(' ')
			b=trim(document.getElementById('Subtotal').innerHTML).split(' ');
			
		if (isNaN(b[1]))		
		     b[1] = 0;
			 
			var a = parseFloat(b[1]) - parseFloat(c[1]);			
	 		document.getElementById('Subtotal').innerHTML  = '&pound; '+ a.toFixed(2);
				
		// alert(document.getElementById('tip')[0].value);
		document.getElementById('tip')[0].selected = 'selected';
		
		// calculating total..		
		this.calculateTotal(a);	
			 }	
   }

/*
 *    ajax function  for add to cart ...
 */
	this.ajaxResponseFunctionForRemoveFromCart = function (resText,I_Price) {
			
	}

/////////////////////////////////////////////////////////// end of Remove from cart section ////////////////////////////////////////


/////////////////////////////////////////////////////////// update to cart section ///////////////////////////////////////////////
/*
*	Update item to cart
*/

    this.buildAjaxUrlForUpdateToCart = function (I_Name,I_Price,C_ID,counter){		 
	  
	    // the variable		
		this.C_ID=C_ID;
		this.I_Name=I_Name;
		this.I_Price=I_Price; 
	   	 
		// check for selected ingredinents 
	  	this.checkSelectedIngrediends(counter);	
		// adding ingredients price ..
		
		I_Price = parseFloat(I_Price) + parseFloat(this.ingredient_amount);
		this.I_Price=I_Price;	
				
        var url = 'ajax/cart_ajax.php?item_ingrediends='+this.id_seperator+'&C_Amount='+I_Price+'&C_ID='+this.C_ID+'&action=save&inst='+document.getElementById('instruction').value;		
		
		this.ajaxCall(url,this.ajaxResponseFunctionForUpdateToCart);	  
	 }
	 
	
/*
 *    ajax function  for add to cart ...
 */
	this.ajaxResponseFunctionForUpdateToCart = function (resText) {		         
			//alert(resText); 
   			oSelectMenu.updateItem(oSelectMenu.I_Price,oSelectMenu.name_seperator,oSelectMenu.C_ID);
    }
	
/*
 *    Update item  & price to cart
 */
 
	this.updateItem = function (I_Price,ingredient_name,C_ID){
		
	var value = parseFloat(document.getElementById('quantity'+C_ID).value) * parseFloat(I_Price);
	var	f     = trim(document.getElementById('Item_Price'+C_ID).innerHTML).split(' ');

		
	 document.getElementById('Item_Price'+C_ID).innerHTML  = "&pound; "+ value.toFixed(2);
	 document.getElementById('Ingredient_name'+C_ID).innerHTML = ingredient_name;
	 	 
     subtotal = this.getSubTotal();	
	 var a = parseFloat(subtotal) + parseFloat(value) -  parseFloat(f[1]);							
     document.getElementById('Subtotal').innerHTML  = '&pound; '+a.toFixed(2);			
     this.calculateTotal(a);	 
	}

/////////////////////////////////////////////////////////// end of update to cart section //////////////////////////////////////////


/////////////////////////////////////////////////////////// update quentity /////////////////////////////////////////////////////

	this.buildAjaxUrlForUpdateQuantity = function (value,C_ID,C_Amount) {	
		var url = 'ajax/cart_ajax.php?C_ID='+C_ID+'&C_Quentity='+value+'&action=Quantity'; 
		this.ajaxCall(url,this.ajaxResponseFunctionForUpdateQuantityToCart(C_ID,value,C_Amount));	  
		}

/*
 *    ajax function  for add quantity to cart ...
 */
 
	this.ajaxResponseFunctionForUpdateQuantityToCart = function (C_ID,value,C_Amount) {
		
		    var b,d,subtotal,f;
			f=trim(document.getElementById('Item_Price'+C_ID).innerHTML).split(' ');
			d=parseFloat(C_Amount) * parseFloat(value);
			document.getElementById('Item_Price'+C_ID).innerHTML= '&pound; '+d.toFixed(2);				
		    subtotal = this.getSubTotal();	
	 	    var a = parseFloat(subtotal) + parseFloat(d) -  parseFloat(f[1]);							
			document.getElementById('Subtotal').innerHTML  = '&pound; '+a.toFixed(2);			
		    this.calculateTotal(a);
        }	


/////////////////////////////////////////////////////////// end of update quentity ////////////////////////////////////////////////

    /*
	 * Update Tip to Cart
	 */

   this.buildAjaxUrlForAddTip = function (R_ID,U_ID){	   
		 var tip=document.getElementById('tip').value;		 
	     var url = 'ajax/cart_ajax.php?U_ID='+U_ID+'&R_ID='+R_ID+'&Tip='+tip+'&action=addtip';		
		 this.ajaxCall(url);
		 this.calculateTotal(this.getSubTotal());
	}

/*
*code to check the duplication of the code
*/
this.check_user_code=function(userid,code)
{
		
		var url='ajax/check_user_code.php?userid='+userid+'&code='+code;
		alert(url);
		this.ajaxCall(url,this.alerttext());
}
this.alerttext=function(resText)
{
		alert(resText);
}

/*
 *    calculating total .
 */

  this.calculateTotal  = function (subtotal){
	  	  
	  var tip=document.getElementById('tip').value;
	  var a=parseFloat(subtotal) + parseFloat(tip);	
	  document.getElementById('total').innerHTML="&pound; "+a.toFixed(2);
  }

/*
 *    calculating total .
 */

  this.getSubTotal  = function (){
		var b=trim(document.getElementById('Subtotal').innerHTML).split(' ');
		if (isNaN(b[1]))		
		return 0;
		else
		return b[1];
  }
/*
 *     Add Favourites
 */
  this.buildAjaxUrlForAddFavourites = function (R_ID,U_ID){	   
				 
	    
		 // alert(document.getElementById('Favourite_total').innerHTML);
		 
		 var favourite =document.getElementById('Favourite_total').innerHTML;
		// alert(favourite);
		 var f = parseFloat(favourite)+1;
		 document.getElementById('Favourite_total').innerHTML=f;
		 var str='<img onclick="oSelectMenu.buildAjaxUrlForRemoveFavourites('+R_ID+','+U_ID+');" src="images/remove_favourite1.jpg" alt="remove"/>';

		 document.getElementById('favourites').innerHTML  = str;
		 
		   var url = 'ajax/cart_ajax.php?U_ID='+U_ID+'&R_ID='+R_ID+'&action=addfavourite';		
		 this.ajaxCall(url,this.ajaxResponseFunctionForAddFavourite);
		
		 
	}

this.ajaxResponseFunctionForAddFavourite = function (resText) {		         
			//alert(resText); 
			alert("You have added a restaurant to your favorites,This means you dont need to search for it again simply click into your favourites from above.");
}
/*
 *     Remove Favourites
 */
	
	this.buildAjaxUrlForRemoveFavourites= function (R_ID,U_ID){
		
		var url = 'ajax/cart_ajax.php?U_ID='+U_ID+'&R_ID='+R_ID+'&action=removefavourite';		
		 this.ajaxCall(url,this.ajaxResponseFunctionForRemoveFavourite);
		 
		// alert(document.getElementById('Favourite_total').innerHTML);
		 
		 var favourite =document.getElementById('Favourite_total').innerHTML;
		
		 var f = parseFloat(favourite)-1;
		 document.getElementById('Favourite_total').innerHTML=f;
		 var str='<img onclick="oSelectMenu.buildAjaxUrlForAddFavourites('+R_ID+','+U_ID+');" src="images/add_to_favourites.jpg" alt="Add To Favourites"/>';
		 
		 document.getElementById('favourites').innerHTML  = str;
		 
		
			}
			
	 this.ajaxResponseFunctionForRemoveFavourite= function (resText) {		         
			//alert(resText); 
			alert("You have removed a restaurant to your list of favorites , you can view this favorite by going to your account and clicking favorite menu's"); 
	 }



  /**
   *     Add  Favourites From Search list
   */
  this.buildAjaxUrlForAddFavouritesSearch = function (R_ID,U_ID){	   
				 
	     var url = 'ajax/cart_ajax.php?U_ID='+U_ID+'&R_ID='+R_ID+'&action=addfavourite';		
		 this.ajaxCall(url,this.ajaxResponseFunctionForAddFavouriteSearch);
		 
		 
		 var favourite =document.getElementById('fav_total'+R_ID).innerHTML;
		 var f = parseFloat(favourite)+1;
		 document.getElementById('fav_total'+R_ID).innerHTML=f;
		 var str='<img onclick="oSelectMenu.buildAjaxUrlForRemoveFavouritesSearch('+R_ID+','+U_ID+');" src="images/remove_favourite.jpg" alt="remove"/>';
		 
		 document.getElementById('Favourite'+R_ID).innerHTML  = str;
		 
	}

   this.ajaxResponseFunctionForAddFavouriteSearch = function (resText) {		         
			//alert(resText); 
			//alert("You have added a restaurant to your favorites,you can view this favorite anytime without searching by click the 'Favorites menus' the tab above"); 
			alert("Favourite Added !");
   }

/*
 *     Remove Favourites From Search list
 */
	
	this.buildAjaxUrlForRemoveFavouritesSearch= function (R_ID,U_ID){
		
		var url = 'ajax/cart_ajax.php?U_ID='+U_ID+'&R_ID='+R_ID+'&action=removefavourite';		
		 this.ajaxCall(url,this.ajaxResponseFunctionForRemoveFavouriteSearch);
		 
		 //alert(document.getElementById('fav_total'+R_ID).innerHTML);
		 
		 var favourite =document.getElementById('fav_total'+R_ID).innerHTML;
		// alert(favourite);
		 var f = parseFloat(favourite)-1;
		 document.getElementById('fav_total'+R_ID).innerHTML=f;
		 var str='<img onclick="oSelectMenu.buildAjaxUrlForAddFavouritesSearch('+R_ID+','+U_ID+');" src="images/addto_favs.jpg" />';
		 
		 document.getElementById('Favourite'+R_ID).innerHTML  = str;
		
	 }
	 
	 
	 this.ajaxResponseFunctionForRemoveFavouriteSearch= function (resText) {		         
			//alert("You have removed a restaurant to your list of favorites , you can view this favorite by going to your account and clicking favorite menu's"); 
			
			alert("Favourite Removed !");
	 }
	
	 this.validOrder = function (R_ID)
	 {
		  if (this.getSubTotal() == 0){
				alert('Your basket is empty, please select at least one product.'); 
				return false;
		  }else{
			 	document.selectmenu.submit();
			  }
	 }
	 this.validCheckOut = function (R_ID)
	 {
		 	
		  var url; 
		  if (this.getSubTotal() == 0){
				alert('Your basket is empty, please select at least one product.'); 
				return false;
		  }
			
		    if(document.getElementById('action').value =="Just Order"){
			
			result=confirm("Are you sure you want to place the order ?");
			if(result)
			{
				if(document.getElementById('pickup').value=="1")
				{
						if(document.getElementById('select_address').value=="Select")
						{
								alert("Please select Delivery Address");
								return false;
						}
						var da_id=document.getElementById('select_address').value;
						addurl='&T_Type=D&DA_ID='+da_id;
		
				}
				else
				{
						addurl='&T_Type=P';		
				}	
				window.location='adyencheckoutresult.php?R_ID='+R_ID+addurl;
			}
			else
			{
					return false;
			}
			
			}
			
			if(document.getElementById('action').value=="Make TNG")
			{
				$tngCodez=document.getElementById('tgncodez').value;
				if(document.getElementById('pickup').value=="1")
				{
						if(document.getElementById('select_address').value=="Select")
						{
								alert("Please select Delivery Address");
								return false;
						}
						var da_id=document.getElementById('select_address').value;
						addurl='&T_Type=D&DA_ID='+da_id;
		
				}
				else
				{
						addurl='&T_Type=P';		
				}	
				$tngCodez=document.getElementById('tgncodez').value;

				window.location.href='selectmenu.php?R_ID='+R_ID+'&tngCodez='+$tngCodez+'&action=addTng'+addurl;
			}
			if(document.getElementById('TNGOrder').checked && document.getElementById('delivery').checked)
			{	
			
				if (document.getElementById('delivery').checked)
				{
					if (document.getElementById('select_address').value == -1 || document.getElementById('select_address').value == -2){
				    alert('Please Select Address'); 
					return false;
				}
				window.location.href='selectmenu.php?R_ID='+R_ID+'&action=addTng1';
		  		window.location.href='checkout.php?R_ID='+R_ID+'&action=TngOrder&DA_ID='+document.getElementById('select_address').value;
			//window.location.href='checkout.php?R_ID='+R_ID+'&action=TngOrder';
						
			}
		}
			
		  if (document.getElementById('delivery').checked && document.getElementById('Order').checked)
		  {	
				if (document.getElementById('select_address').value == -1 || document.getElementById('select_address').value == -2){
				    alert('Please Select Address'); 
					document.getElementById('select_address').focus();
					return false;
				}
				if (document.getElementById('select_address').value != -1 || document.getElementById('select_address').value != -2 || document.getElementById('select_address').value != null){
					
 window.location.href='checkout.php?R_ID='+R_ID+'&action=Order&DA_ID='+document.getElementById('select_address').value;	
				}
		  }
	 }
	 this.CloseDelivery=function(str)
	 {
		
		if(document.getElementById('TNG').value)
		{
		//document.getElementById('deliverybox').style.display='none';
		//document.getElementById('pickupbox').innerHTML='Pickup <input type="radio" name="pd" id="pickup" value="p" onclick="if(document.getElementById("select_address")) document.getElementById("select_address").style.display ="none"" value="2"/><br/>';
														       
		}
		if(str != 'jorder'){
                  document.getElementById('tngcodez').style.display = 'block';
                  if(str == 'tng')
                      {
                         document.getElementById('hiddendiv').innerHTML = document.getElementById('saveorder').innerHTML;
                         document.getElementById('saveorder').innerHTML = '<input type="image" src="images/save.jpg" >';
                      }
                  else
                      {
                         document.getElementById('saveorder').innerHTML = document.getElementById('hiddendiv').innerHTML;
                      }
                }
                else
                {
                  document.getElementById('tngcodez').style.display = 'none';
                }
	 }
	 this.OpenDelivery=function(str)
	 {
		
                if(str != 'jorder'){
                  document.getElementById('tngcodez').style.display = 'block';
                }
                else
                {
                  document.getElementById('tngcodez').style.display = 'none';
                }
                if(document.getElementById('hiddendiv').innerHTML != ''){
                   document.getElementById('saveorder').innerHTML = document.getElementById('hiddendiv').innerHTML;
                }
                
		if(document.getElementById('TNGOrder').value)
		 {
		document.getElementById('deliverybox').style.display='block';
		document.getElementById('notaplicable').innerHTML='';
		 }
		if(document.getElementById('Order').value)
		 {
		document.getElementById('deliverybox').style.display='block';
		document.getElementById('notaplicable').innerHTML='';
		 }
                
	 }
	 
	 
///////////////////Trim /////////////////////////////
		this.trim=function (stringToTrim)
		{
			return stringToTrim.replace(/^\s+|\s+$/g,"");
		}
///////////////////End Trim /////////////////////////////		

///////////////////Numeric/////////////////////////////
		this.numericvalidation=function(evt)
		{
		var carCode = (evt.which) ? evt.which : event.keyCode
	
		if (carCode > 31 && (carCode < 48) || (carCode > 57))
		{
		 alert('Please Insert Numeric Value Only.');
    	 return false;
   	   }
	
		}
///////////////////End Numeric/////////////////////////////
	 
	  this.buildAjaxUrlForDeliveryAddressValidation = function (U_ID)
		{
		if(trim(document.getElementById("Street").value) == '')
		{
		     alert("Please Enter Street Name");
			 document.getElementById("Street").focus();
			 return false;
		}
		if(trim(document.getElementById("Apart_Floor").value) == '')
		{
		alert('Please Enter Apart/Floor No.');
		document.getElementById('Apart_Floor').focus();
		return false;
		}
	
		if(trim(document.getElementById("City").value) == '')
		{
		alert('Please Enter City Name.');
		document.getElementById('City').focus();
		return false;
		}
	
		if(trim(document.getElementById("PostCode").value) == '')
		{
		alert('Please Enter PostCode.');
		document.getElementById('PostCode').focus();
		return false;
		}
		if(trim(document.getElementById('Location').value) == '')
		{
		alert('Please Enter Location.');
		document.getElementById('Location').focus();
		return false;
		}
	
	
		this.ajaxCall(this.buildAjaxUrlForAddDeliveryAddress(U_ID));
		}
	 this.buildAjaxUrlForAddDeliveryAddress = function (U_ID)
		{
			var Street= document.getElementById('Street').value;
			var Apart_Floor= document.getElementById('Apart_Floor').value;
			var City= document.getElementById('City').value;
			var PostCode= document.getElementById('PostCode').value;
			var Location= document.getElementById('Location').value;
			//var near_street= document.getElementById('near_street').value;
			
			var url = 'ajax/cart_ajax.php?U_ID='+U_ID+'&DA_Street='+Street+'&DA_Apart_Floor='+Apart_Floor+'&DA_City='+City+'&DA_PostCode='+PostCode+'&DA_Location_Nickname='+Location+'&action=addaddress';
			//alert(url);
		 this.ajaxCall(url,this.addOptions());
		 	//closeMessage();
		}
		
	this.addOptions=function() {
		//alert("comes here");
		var chosen= document.getElementById('Location').value;
		var selbox = document.selectmenu.select_address;
		if (selbox.options[0].value == " ") {
		selbox.options.length = 0;
		}
		var fnd = 0;
		for (n=0;n<selbox.length;n++){
		if(selbox.options[n].text == chosen){
			
		fnd = 1;
		}}
		if (!fnd) selbox.options[selbox.options.length] = new Option(chosen, selbox.options.length)
		for (n=0;n<selbox.length;n++){
		if(selbox.options[n].text == chosen){
			selbox.options[n].selected="selected";
		}}
		closeMessage();
		}
		
		
		////Search Menu validation/////////
			this.SearchMenu=function() 
			{
				if(trim(document.getElementById("menuname").value) == '')
				{
				alert('Please Enter Menu Name.');
				document.getElementById('menuname').focus();
				return false;
			}	
		}
		
		this.submitmiles = function() {
	alert(document.getElementById('radiusSelect').value);
	document.getElementById('searchmenu').submit();
	}
	
	/////// Functions for CreditCard select ////
	
	this.buildAjaxUrlForCreditCard= function (UC_ID,U_ID){
		
				
		var url = 'ajax/cart_ajax.php?U_ID='+U_ID+'&UC_ID='+UC_ID+'&action=CardUpdate';
		 this.ajaxCall(url,this.ajaxResponseFunctionForCreditCard);
	}
	
	this.ajaxResponseFunctionForCreditCard = function (resText) {		         
			//alert(resText); 
   			
    }
	
} // end of select menu class...

/*
 *    creating object of class select menu
 */

var oSelectMenu = new selectMenu();



