//js/developersindia.info/
// General Functions
var request_uri;
var checkout_cart_url;
var updateLinkUrl;
var ok_button_label;
var cancel_button_label;
var delete_confirm_text;
var enable_success_message;
var button_bg_color
var button_border_color;
var button_font_color;

function setAllTheUrls(php_request_uri, php_checkout_cart_url, php_updateLinkUrl, php_homeUrl, php_ok_button_label, php_cancel_button_label, php_delete_confirm_text, php_enable_success_message, php_button_bg_color, php_button_border_color, php_button_font_color){
	request_uri = php_request_uri;
	checkout_cart_url = php_checkout_cart_url;
	updateLinkUrl = php_updateLinkUrl;
	home_url = php_homeUrl;
	ok_button_label = php_ok_button_label;
	cancel_button_label = php_cancel_button_label;
	delete_confirm_text = php_delete_confirm_text;
	enable_success_message = php_enable_success_message;
	button_bg_color = php_button_bg_color;
	button_border_color = php_button_border_color;
	button_font_color = php_button_font_color;
}

function setLocation(url){
	//page appelante du compare : document.referrer
	//mise au panier STD aparement
	//alert('1');
	strurl = url;
	//alert(strurl);
	var match1 = /options=cart/.test(strurl);
	var match2 = /checkout\/onepage/.test(strurl);
	var match3 = /limit\=\w+/.test(strurl);
	var match4 = /order\=\w+\&dir\=\w+/.test(strurl);
	var match5 = /dir\=\w+\&order\=\w+/.test(strurl);
	
	var checkForCartAddToCart = /in_cart\/1/.test(strurl);
	if(checkForCartAddToCart){
		return inCartAddToCart(strurl);
	}

	var ajax = true;
	if(match1){
		ajax = false;
	}

	if(match2){
		ajax = false;
	}

	if(match3){
		ajax = false;
	}

	if(match4){
		ajax = false;
	}

	if(match5){
		ajax = false;
	}

	if( typeof( window[ 'home_url' ] ) != "undefined" )
	if(strurl==home_url){
		ajax = false;
	}

	if(ajax){
		//Element.show('loading-mask');  
		new Ajax.Request(url, {
          onSuccess: function(transport) {
			  //Element.hide('loading-mask');  
			  var json = transport.responseText.evalJSON();
			  if(json.r=="failure"){
				window.location = json.redirect_url;
			  }else{
				showDialog(json.message);
				updateTopCartLink(json.topCartText);
				var productElement =document.getElementById('opcpartoutcache');
				if (productElement != null)
					{autrement(json.autrement);billing.saveer();}
else
{
	if (top.location != self.document.location)
	{
		//on est dans une iframe
		//alert('iframe0931');
		//alert(top.location);//http://vinodomia.dev.be2store.com/
		//alert(self.document.location);//http://vinodomia.dev.be2store.com/catalog/category/view/s/nos-vins-blancs/id/17/?___store=vinodallaines2
		//alert(parent.document);//object HTMLDocument]
		//meme que avant mais sur le pere de iframe
		var productElement =parent.document.getElementById('opcpartoutcache');
		if (productElement != null)
			{autrementparent(json.autrement);parent.billing.saveer();}
	}
}
				updateSideBarCart(json.cart);
				findAndCleanUpDeleteUrls();
			}
          }, method: "get"
		});
	}else{
		window.location.href = url;
	}
}
function setLocationn(url){
//dans le panier par la barre c le meme que avant sans popup
//pour le cas ou le cart est integre partout
//au lieu de la fonction updatepost qui reload la page
//on choppe celui du ajaxaddtocart sans popup
//alert('2');
	strurl = url;
	//alert(strurl);
	var match1 = /options=cart/.test(strurl);
	var match2 = /checkout\/onepage/.test(strurl);
	var match3 = /limit\=\w+/.test(strurl);
	var match4 = /order\=\w+\&dir\=\w+/.test(strurl);
	var match5 = /dir\=\w+\&order\=\w+/.test(strurl);
	
	var checkForCartAddToCart = /in_cart\/1/.test(strurl);
	if(checkForCartAddToCart){
		return inCartAddToCart(strurl);
	}

	var ajax = true;
	if(match1){
		ajax = false;
	}

	if(match2){
		ajax = false;
	}

	if(match3){
		ajax = false;
	}

	if(match4){
		ajax = false;
	}

	if(match5){
		ajax = false;
	}

	if( typeof( window[ 'home_url' ] ) != "undefined" )
	if(strurl==home_url){
		ajax = false;
	}

	if(ajax){
		//Element.show('loading-mask');  
		new Ajax.Request(url, {
          onSuccess: function(transport) {
			  //Element.hide('loading-mask');  
			  var json = transport.responseText.evalJSON();
			  if(json.r=="failure"){
				window.location = json.redirect_url;
			  }else{
				//showDialog(json.message);
				updateTopCartLink(json.topCartText);
				var productElement =document.getElementById('opcpartoutcache');
				if (productElement != null)
					{autrement(json.autrement);billing.saveer();}
				updateSideBarCart(json.cart);
				findAndCleanUpDeleteUrls();
			}
          }, method: "get"
		});
	}else{
		window.location.href = url;
	}
}
function setLocation2(url){
//POUR LR COMPARE ONLY
//page appelante du compare : document.referrer
//alert('3');
	strurl = url;
	//alert(strurl);
	var match1 = /options=cart/.test(strurl);
	var match2 = /checkout\/onepage/.test(strurl);
	var match3 = /limit\=\w+/.test(strurl);
	var match4 = /order\=\w+\&dir\=\w+/.test(strurl);
	var match5 = /dir\=\w+\&order\=\w+/.test(strurl);
	
	var checkForCartAddToCart = /in_cart\/1/.test(strurl);
	if(checkForCartAddToCart){
		return inCartAddToCart(strurl);
	}

	var ajax = true;
	if(match1){
		ajax = false;
	}

	if(match2){
		ajax = false;
	}

	if(match3){
		ajax = false;
	}

	if(match4){
		ajax = false;
	}

	if(match5){
		ajax = false;
	}

	if( typeof( window[ 'home_url' ] ) != "undefined" )
	if(strurl==home_url){
		ajax = false;
	}
	
	if(ajax){
		//Element.show('loading-mask');  
		new Ajax.Request(url, {
          onSuccess: function(transport) {
			  //Element.hide('loading-mask');  
			  var json = transport.responseText.evalJSON();
			  if(json.r=="failure"){
				window.location = json.redirect_url;
			  }else{
				showDialog(json.message);
				updateTopCartLink(json.topCartText);
				var productElement =document.getElementById('opcpartoutcache');
				if (productElement != null)
					{autrement(json.autrement);billing.saveer();}
				updateSideBarCart(json.cart);
				findAndCleanUpDeleteUrls();
			}
          }, method: "get"
		});
		alert("Le produit a bien été ajouté au panier.");
		window.opener.location=window.opener.location;//on reload la page qui a apelé le compare
	}else{
		window.location.href = url;
	}
}

function setPLocation(url, setFocus){//alert('4');
	var patt1=new RegExp("/checkout/cart/add/product/");
	if(patt1.test(url)){
		Element.show('loading-mask');  
		new Ajax.Request(url, {
          onSuccess: function(transport) {
			  Element.hide('loading-mask');  
			  var json = transport.responseText.evalJSON();
			  if(json.r=="failure"){
				window.blur();
				window.opener.location.href = json.redirect_url;
			  }else{
				showDialog(json.message, 'compare_page');
				window.opener.location.reload();
			}
          }, method: "get"
		});
	}else{
		if( setFocus ) {
			window.opener.focus();
		}
		window.opener.location.href = url;
	}
}

function inCartAddToCart(strurl){
//ajout depuis le panier par ex ventes croisees
	Element.show('loading-mask'); 
	new Ajax.Request(strurl, {
	  onSuccess: function(transport) {
		  Element.hide('loading-mask');  
			var json = transport.responseText.evalJSON();
			if(json.r=="failure"){
				window.location = json.redirect_url;
			}else{
				updateTopCartLink(json.topCartText);
				var productElement =document.getElementById('opcpartoutcache');
				if (productElement != null)
					{autrement(json.autrement);billing.saveer();}
//				document.getElementById('main').innerHTML = json.cart;
				var scripts = json.cart.extractScripts();
				for(var i=0; i<scripts.length; i++){
					var code = scripts[i].strip().gsub(/var\s+/, '');
					eval(code);
				}
//				Effect.BlindDown('main');
				findAndCleanUpDeleteUrls();
				window.location.reload();
			}	  
			
	  }, method: "get"
	});
}

function findAndCleanUpDeleteUrls(){//alert('6');
if (top.location != self.document.location)
	{
		//iframe
		var patt1=new RegExp("/checkout/cart/delete/");
		for(i=0;i<parent.document.links.length;i++){
			if(patt1.test(parent.document.links[i])){
				url_with_random_chars = parent.document.links[i].href;
				clean_url = url_with_random_chars.replace(/\/uenc\/\w*\W*/i, "/")
				parent.document.links[i].id = clean_url;
				var patt2=new RegExp("/checkout/cart/");
				if(patt2.test(parent.document.location.href)){
					parent.document.links[i].href = "javascript:ajaxDeleteCartProduct('"+parent.document.links[i].id+"')";		
				}else{
					parent.document.links[i].href = "javascript:ajaxDeleteProduct('"+parent.document.links[i].id+"')";		
				}
				parent.document.links[i].onclick = "";
			}
		}
		// also update all add to cart href links
		updateAllHrefLinksToUseSetLocation();
	}
	else
	{
		var patt1=new RegExp("/checkout/cart/delete/");
		for(i=0;i<document.links.length;i++){
			if(patt1.test(document.links[i])){
				url_with_random_chars = document.links[i].href;
				clean_url = url_with_random_chars.replace(/\/uenc\/\w*\W*/i, "/")
				document.links[i].id = clean_url;
				var patt2=new RegExp("/checkout/cart/");
				if(patt2.test(document.location.href)){
					document.links[i].href = "javascript:ajaxDeleteCartProduct('"+document.links[i].id+"')";		
				}else{
					document.links[i].href = "javascript:ajaxDeleteProduct('"+document.links[i].id+"')";		
				}
				document.links[i].onclick = "";
			}
		}
		// also update all add to cart href links
		updateAllHrefLinksToUseSetLocation();
	}
}


// Product Detail Page Functions

var productAddToCartForm = new VarienForm('product_addtocart_form');

productAddToCartForm.submit = function(){//alert('7');
		if (this.validator.validate()) {
			Element.show('loading-mask');  
			
			// do the same with a callback:
			$('product_addtocart_form').request({
				onComplete: function(transport){ 
					Element.hide('loading-mask');
					
					var json = transport.responseText.evalJSON();
					
					if(json.r=="failure"){
						window.location = json.redirect_url;
					}else{
						showDialog(json.message);
						updateTopCartLink(json.topCartText);
						var productElement =document.getElementById('opcpartoutcache');
						if (productElement != null)
							{autrement(json.autrement);billing.saveer();}
						updateSideBarCart(json.cart);
						findAndCleanUpDeleteUrls();
					}
				}
			})

		}
}.bind(productAddToCartForm);


// Cart Page Functions
function ajaxDeleteCartProduct(url){//alert('8');
	if(makeDeleteConfirm())
	{
		Element.show('loading-mask');  
		url += "request_from/checkout/";
		new Ajax.Request(url, {  
			method: 'get',
			onComplete: function(transport) {  
			
				Element.hide('loading-mask');
				// option 1 start
				var json = transport.responseText.evalJSON();
				//if(json.r=="failure")
				//{
				//	window.location = json.redirect_url;
				//}
				//else
				//{
					updateTopCartLink(json.topCartText);
					var productElement =document.getElementById('opcpartoutcache');
					if (productElement != null)
						{autrement(json.autrement);billing.saveer();}
					document.getElementById('main').innerHTML = json.cart;
					var scripts = json.cart.extractScripts();
					for(var i=0; i<scripts.length; i++){
						var code = scripts[i].strip().gsub(/var\s+/, '');
						eval(code);
					}
					Effect.BlindDown('main');
					findAndCleanUpDeleteUrls();
				//}
				// option 1 end
			}
		});
		alert('Le produit a bien été supprimé.');
		//reloader la page pour MAJ les produits
		window.location.reload();
	}
}

// Side Bar Functions
function ajaxDeleteProduct(url){//alert('9');
	if(makeDeleteConfirm()){
		Element.show('loading-mask');
		new Ajax.Request(url, {
		method: 'get',
		onComplete: function(transport) {
		Element.hide('loading-mask');
		var json = transport.responseText.evalJSON();
		updateSideBarCart(json.cart);
		updateTopCartLink(json.topCartText);
		var productElement =document.getElementById('opcpartoutcache');
		if (productElement != null)
			{autrement(json.autrement);billing.saveer();}
		findAndCleanUpDeleteUrls();
		}
		});
		alert('Le produit a bien été supprimé.');
		var productElement =document.getElementById('opcpartoutcache');
		if (productElement == null)
			{window.location.reload();}
	}
}

function updateSideBarCart(jsonCart){//alert('10');
	if (top.location != self.document.location)
	{
		//on est dans une iframe
		var divs = parent.document.getElementsByTagName('div');
		for (var i = 0; i < divs.length; i++) {
			var div = divs[i];
			if(div.className=="block-cart"){
				//ori
				//div.innerHTML = jsonCart;
				//moi
				var panierpourri = jsonCart;
				//alert(panierpourri.search("<!-- DEBUT ESTIMATION FDP-->"));
				//alert(panierpourri.search("<!-- FIN ESTIMATION FDP-->"));
				//a enlever
				//alert(panierpourri.substring(panierpourri.search("<!-- DEBUT ESTIMATION FDP-->"),(panierpourri.search("<!-- FIN ESTIMATION FDP-->")+26)));
				//a garder
				//alert(panierpourri.substring(0,panierpourri.search("<!-- DEBUT ESTIMATION FDP-->")));
				//alert(panierpourri.substring((panierpourri.search("<!-- FIN ESTIMATION FDP-->")+26)));
				var chaine=panierpourri.substring(0,panierpourri.search("<!-- DEBUT ESTIMATION FDP-->"));
				var chaine2=panierpourri.substring((panierpourri.search("<!-- FIN ESTIMATION FDP-->")+26));
				var totalcart=chaine.concat(chaine2);
				div.innerHTML = totalcart;
				
				Effect.BlindDown(div);
				break;
			}
		}
	}
	else
	{
		//fonctionnement STD
		var divs = document.getElementsByTagName('div');
		for (var i = 0; i < divs.length; i++) {
			var div = divs[i];
			if(div.className=="block-cart"){
				//ori
				//div.innerHTML = jsonCart;
				//moi
				var panierpourri = jsonCart;
				//alert(panierpourri.search("<!-- DEBUT ESTIMATION FDP-->"));
				//alert(panierpourri.search("<!-- FIN ESTIMATION FDP-->"));
				//a enlever
				//alert(panierpourri.substring(panierpourri.search("<!-- DEBUT ESTIMATION FDP-->"),(panierpourri.search("<!-- FIN ESTIMATION FDP-->")+26)));
				//a garder
				//alert(panierpourri.substring(0,panierpourri.search("<!-- DEBUT ESTIMATION FDP-->")));
				//alert(panierpourri.substring((panierpourri.search("<!-- FIN ESTIMATION FDP-->")+26)));
				var chaine=panierpourri.substring(0,panierpourri.search("<!-- DEBUT ESTIMATION FDP-->"));
				var chaine2=panierpourri.substring((panierpourri.search("<!-- FIN ESTIMATION FDP-->")+26));
				var totalcart=chaine.concat(chaine2);
				div.innerHTML = totalcart;
				
				Effect.BlindDown(div);
				break;
			}
		}
	}
}

function makeDeleteConfirm(){
	if(window.confirm(delete_confirm_text)){
		return true;
	}
	return false;
}

function updateTopCartLink(topCartText){
	//met a jour le nb darticles dans le panier en haut apres une mise au panier
	if (top.location != self.document.location)
	{
		//iframe
		var aS = parent.document.getElementsByTagName('a');
		for (var i = 0; i < aS.length; i++) {
			var a = aS[i];
			if(a.className=="top-link-cart"){
				//alert(a);//http://dallaines.dev.be2store.com/checkout/cart/
				a.innerHTML = topCartText;
				a.title = topCartText;
				return;
			}
		}
	}
	else
	{
		//STD
		var aS = document.getElementsByTagName('a');
		for (var i = 0; i < aS.length; i++) {
			var a = aS[i];
			if(a.className=="top-link-cart"){
				//alert(a);//http://dallaines.dev.be2store.com/checkout/cart/
				a.innerHTML = topCartText;
				a.title = topCartText;
				return;
			}
		}
	}
}

function autrement(aze){//alert('11');
	//autrement STD
	var aS = document.getElementById('cartpartoutcache');
	var chaine=aze.substring(50,aze.search("<!-- schtroumpf -->"));
	aS.innerHTML = chaine;
}

function autrementparent(aze){//alert('111');
	//autrement pour le parent de iframe
	var aS = parent.document.getElementById('cartpartoutcache');
	var chaine=aze.substring(50,aze.search("<!-- schtroumpf -->"));
	aS.innerHTML = chaine;
}

function showDialog(jsonMessage, from){
	//alert(top.location);//http://www.oulahop.com/sacs/amour-de-coccinelle.html?___store=oulahopfbstoreview
	//alert(self.document.location);//http://www.oulahop.com/sacs/amour-de-coccinelle.html?___store=oulahopfbstoreview
	//var aze='http://www.oulahop.com/sacs/amour-de-coccinelle.html?___store=oulahopfbstoreview';
	//var aze=top.location;//http://www.dallaines.com/vin-bourgogne-meursault-tete-de-cuvee-2007.html?___store=dallainesstoreview
	//var aze='http://www.dallaines.com/vin-bourgogne-meursault-tete-de-cuvee-2007.html?___store=dallainesstoreview';
	var aze = self.document.location.href;
	var chaine='';var chaine2='';var chaine3='var chaine="";';
	if(aze.indexOf("?___store=",0)>0)
	{	chaine=aze.substring(aze.indexOf("?___store=",0));//chaine renvoie ?___store=oulahopfbstoreview
		chaine2='var chaine="';
		chaine3=chaine2.concat(chaine);
		chaine3=chaine3.concat('";');
	}
	
	//alert(chaine3);
	//console.log(top.location.href);

	if (top.location != self.document.location)
	{
		//on est dans une iframe
		//alert('iframe');
		//alert(top.location);//http://vinodomia.dev.be2store.com/
		//alert(self.document.location);//http://vinodomia.dev.be2store.com/catalog/category/view/s/nos-vins-blancs/id/17/?___store=vinodallaines2
		//alert(parent.document);//object
		//donc opcpartoutcache est la
		if(enable_success_message=="1"){
			
				inputButtons = "<br/><br/><input type='button' class='button' name='finish_and_checkout' id='finish_and_checkout' value='"+ok_button_label+"' style='background:"+button_bg_color+" none repeat scroll 0 0; border:1px solid "+button_border_color+"; color:"+button_font_color+"; cursor:pointer; font-family:arial,sans-serif !important; font-size:12px !important; font-size-adjust:none !important; font-stretch:normal !important; font-style:normal !important; font-variant:normal !important; font-weight:bold !important; line-height:normal !important; overflow:visible; padding:1px 8px; text-align:center; vertical-align:middle;' /><br/><br/><input type='button' class='button' name='continue_shopping' id='continue_shopping' value='"+cancel_button_label+"' style='background:"+button_bg_color+" none repeat scroll 0 0; border:1px solid "+button_border_color+"; color:"+button_font_color+"; cursor:pointer; font-family:arial,sans-serif !important; font-size:12px !important; font-size-adjust:none !important; font-stretch:normal !important; font-style:normal !important; font-variant:normal !important; font-weight:bold !important; line-height:normal !important; overflow:visible; padding:1px 8px; text-align:center; vertical-align:middle;' />";
				
				/*scriptCode = "<script type='text/javascript'>";
				scriptCode += "$('finish_and_checkout').observe('click', function(){});";
				scriptCode += "$('continue_shopping').observe('click', function(){location.href = home_url;});"
				scriptCode += "setTimeout('function(){Effect.DropOut('after-loading-success-message')});',5000);"
				scriptCode += "</script>";*/
				
				scriptCode = "<script type='text/javascript'>";scriptCode += chaine3;
				if(from=='compare_page'){	
					scriptCode += "$('finish_and_checkout').observe('click', function(){ Effect.DropOut('after-loading-success-message');window.opener.focus(); });";
					scriptCode += "$('finish_and_checkout').observe('click', function(){});";
				}else{
					//scriptCode += "$('finish_and_checkout').observe('click', function(){parent.billing.saveer();parent.document.getElementById('afficheropcreduit').style.display = 'block';parent.document.getElementById('cartpartoutcache').style.display = 'block';Element.hide('after-loading-success-message');parent.document.getElementById('afficheropcreduit').focus();});";
					scriptCode += "$('finish_and_checkout').observe('click', function(){parent.location.href = checkout_cart_url;});";//+chaine
				}
				//scriptCode += "$('continue_shopping').observe('click', function(){parent.document.getElementById('afficheropcreduit').style.display = 'block';parent.document.getElementById('afficherpanierreduit').style.display = 'block';Element.hide('after-loading-success-message');parent.billing.saveer();});";//window.location.reload();
				scriptCode += "$('continue_shopping').observe('click', function(){Element.hide('after-loading-success-message');});";//window.location.reload();

				scriptCode += "</script>";

				Element.update('success-message-container', jsonMessage+inputButtons+scriptCode);
				Element.show('after-loading-success-message');	
			}
	}
	else
	{
		//fonctionnement STD
		var productElement =document.getElementById('opcpartoutcache');
		if (productElement != null)
		{
			//pour le cart et le panier inclus partout
			if(enable_success_message=="1"){
			
				inputButtons = "<br/><br/><input type='button' class='button' name='finish_and_checkout' id='finish_and_checkout' value='"+ok_button_label+"' style='background:"+button_bg_color+" none repeat scroll 0 0; border:1px solid "+button_border_color+"; color:"+button_font_color+"; cursor:pointer; font-family:arial,sans-serif !important; font-size:12px !important; font-size-adjust:none !important; font-stretch:normal !important; font-style:normal !important; font-variant:normal !important; font-weight:bold !important; line-height:normal !important; overflow:visible; padding:1px 8px; text-align:center; vertical-align:middle;' /><br/><br/><input type='button' class='button' name='continue_shopping' id='continue_shopping' value='"+cancel_button_label+"' style='background:"+button_bg_color+" none repeat scroll 0 0; border:1px solid "+button_border_color+"; color:"+button_font_color+"; cursor:pointer; font-family:arial,sans-serif !important; font-size:12px !important; font-size-adjust:none !important; font-stretch:normal !important; font-style:normal !important; font-variant:normal !important; font-weight:bold !important; line-height:normal !important; overflow:visible; padding:1px 8px; text-align:center; vertical-align:middle;' />";
				
				/*scriptCode = "<script type='text/javascript'>";
				scriptCode += "$('finish_and_checkout').observe('click', function(){});";
				scriptCode += "$('continue_shopping').observe('click', function(){location.href = home_url;});"
				scriptCode += "setTimeout('function(){Effect.DropOut('after-loading-success-message')});',5000);"
				scriptCode += "</script>";*/
				
				scriptCode = "<script type='text/javascript'>";scriptCode += chaine3;
				if(from=='compare_page'){	
					scriptCode += "$('finish_and_checkout').observe('click', function(){ Effect.DropOut('after-loading-success-message');window.opener.focus(); });";
					scriptCode += "$('finish_and_checkout').observe('click', function(){});";
				}else{
					scriptCode += "$('finish_and_checkout').observe('click', function(){billing.saveer();document.getElementById('afficheropcreduit').style.display = 'block';document.getElementById('cartpartoutcache').style.display = 'block';Element.hide('after-loading-success-message');document.getElementById('afficheropcreduit').focus();});";
				}
				scriptCode += "$('continue_shopping').observe('click', function(){document.getElementById('afficheropcreduit').style.display = 'block';document.getElementById('afficherpanierreduit').style.display = 'block';Element.hide('after-loading-success-message');billing.saveer();});";//window.location.reload();
				
				scriptCode += "</script>";

				Element.update('success-message-container', jsonMessage+inputButtons+scriptCode);
				Element.show('after-loading-success-message');	
			}
		}
		else
		{
			if(enable_success_message=="1"){
			
				inputButtons = "<br/><br/><input type='button' class='button' name='finish_and_checkout' id='finish_and_checkout' value='"+ok_button_label+"' style='background:"+button_bg_color+" none repeat scroll 0 0; border:1px solid "+button_border_color+"; color:"+button_font_color+"; cursor:pointer; font-family:arial,sans-serif !important; font-size:12px !important; font-size-adjust:none !important; font-stretch:normal !important; font-style:normal !important; font-variant:normal !important; font-weight:bold !important; line-height:normal !important; overflow:visible; padding:1px 8px; text-align:center; vertical-align:middle;' /><br/><br/><input type='button' class='button' name='continue_shopping' id='continue_shopping' value='"+cancel_button_label+"' style='background:"+button_bg_color+" none repeat scroll 0 0; border:1px solid "+button_border_color+"; color:"+button_font_color+"; cursor:pointer; font-family:arial,sans-serif !important; font-size:12px !important; font-size-adjust:none !important; font-stretch:normal !important; font-style:normal !important; font-variant:normal !important; font-weight:bold !important; line-height:normal !important; overflow:visible; padding:1px 8px; text-align:center; vertical-align:middle;' />";
				
				/*scriptCode = "<script type='text/javascript'>";
				scriptCode += "$('finish_and_checkout').observe('click', function(){location.href = checkout_cart_url;});";
				scriptCode += "$('continue_shopping').observe('click', function(){location.href = home_url;});"
				scriptCode += "setTimeout('function(){Effect.DropOut('after-loading-success-message')});',5000);"
				scriptCode += "</script>";*/
				
				scriptCode = "<script type='text/javascript'>";scriptCode += chaine3;
				if(from=='compare_page'){	
					scriptCode += "$('finish_and_checkout').observe('click', function(){ Effect.DropOut('after-loading-success-message'); window.opener.location.href = checkout_cart_url; window.opener.focus(); });";
					scriptCode += "$('finish_and_checkout').observe('click', function(){location.href = checkout_cart_url;});";
				}else{
					scriptCode += "$('finish_and_checkout').observe('click', function(){location.href = checkout_cart_url+chaine;});";
				}
				scriptCode += "$('continue_shopping').observe('click', function(){Element.hide('after-loading-success-message');});";//window.location.reload();
				
				scriptCode += "</script>";

				Element.update('success-message-container', jsonMessage+inputButtons+scriptCode);
				Element.show('after-loading-success-message');	
			}
		}
	}
	//document.getElementById('estimerlesfdpamoi').reload;
	//document.getElementById('lollol').reload();
	return;
}

function updateAllHrefLinksToUseSetLocation(){
if (top.location != self.document.location)
	{
		//iframe
		var patt1=new RegExp("/checkout/cart/add/");
		for(i=0;i<parent.document.links.length;i++){
			if(patt1.test(parent.document.links[i])){
				url = parent.document.links[i].href;
				parent.document.links[i].href = "javascript:setLocation('"+url+"')";
			}
		}
	}
	else
	{
		var patt1=new RegExp("/checkout/cart/add/");
		for(i=0;i<document.links.length;i++){
			if(patt1.test(document.links[i])){
				url = document.links[i].href;
				document.links[i].href = "javascript:setLocation('"+url+"')";
			}
		}
	}
}
