// Function written by Sachin 12 January 2009
// Functions redirects to ccvenue PG with product ID
// Form hiddden element holds product id
// Product id must be available at ccavenues'c control panel
// CheckOutReturnUrl holds url to returns back from ccavenue's shopping cart
// Please do not change any form object names

// JavaScript Document
function buynow() {    
      var buypackage = document.amtship.buyselection.value;
	  //var CheckOutReturnUrl = document.URL;
	  var CheckOutReturnUrl = continueshoppingURL();
window.location =  "https://www.ccavenue.com/shopzone/custcart/sendtocart.jsp?M_mitplune_8682,"+buypackage+"," + CheckOutReturnUrl;
   }
   
   
   function checkoutbut() {
         //var CheckOutReturnUrl = document.URL;
		 var CheckOutReturnUrl = continueshoppingURL();
		 
  window.location = "https://www.ccavenue.com/shopzone/custcart/sendtocart.jsp?M_mitplune_8682,shopcart," + CheckOutReturnUrl;
   }
   
   
   
   
   
   
   
function continueshoppingURL()
{
myString = document.URL;
myArray=myString.split("/");
currentpage=(myArray[myArray.length-1]);
baseurl = remove(myString, currentpage)

return (baseurl + "productstore.html");
}
function remove(s, t) {
  /*
  **  Remove all occurrences of a token in a string
  **    s  string to be processed
  **    t  token to be removed
  **  returns new string
  */
  i = s.indexOf(t);
  r = "";
  if (i == -1) return s;
  r += s.substring(0,i) + remove(s.substring(i + t.length), t);
  return r;
  }
