 function makecolorchange(url)
{
$('#workover').remove();
$('#newimgover').remove();
$('#makecolor').remove();
$('#product').prepend('<img id="workover" src="/img/layout/progress.gif" style="position:absolute; top: 200px; left: 50%; z-index: 5" />').prepend('<img id="newimgover" src="' + url + '" style="position:absolute; z-index: 6" />').prepend('<div id="makecolor">Obrázek je pouze ilustrační.</div>');
$('.price').hide();
}

function deletecolorchange()
{}

var selectboxy = new Array();

$(document).ready(function()
{
	//fix menu for iPads and iPhones
	$("#hMenu a:not([href])").click(function(e){
		e.preventDefault();
		$(this).parent().mouseover();
	});
	
	//zalozky
	if(window.location.hash!="") {
		hash = window.location.hash.replace("#", "");
		
		switch(hash) {
			case "popis":
				show('1',$("#zalozka1L"));
				break;
			case "specifikace":
				show('2',$("#zalozka2L"));
				break;
			case "barvy":
				show('3',$("#zalozka3L"));
				break;
			case "fotogalerie":
				show('4',$("#zalozka4L"));
				break;
			case "vase-kola":
				show('5',$("#zalozka5L"));
				break;
			case "rb-plus":
				show('6',$("#zalozka6L"));
				break;
		}
	}
	
	//RB plus (former draft supported mouse-sticky tooltip, client prefers static
	
	tOffset = 596;
	lOffset = 90;
	
	tmouseOffset = -22;
	lmouseOffset = -22;
	
	//mouse enter, mouse leave
	$(".clickb").hover(function(e){											  
		this.content = $(this).html();
		$(this).html("");									  
		$("#zalozka6").append('<div id="rbplus_tooltip">'+ this.content +'</div>');
		$("#rbplus_tooltip").css("display", "none");
		
		this.l = parseInt(e.pageX) - parseInt($("#zalozka6").offset().left);
		this.t = parseInt(e.pageY) - parseInt($("#zalozka6").offset().top);
		
		$("#rbplus_tooltip")
		.css("top",(this.t + tOffset) + "px")
		.css("left",(this.l + lOffset) + "px")
		.fadeIn("fast");
	},
	function(){
		$(this).html(this.content);
		$("#rbplus_tooltip").fadeOut("fast").remove();
	});
	
	//prichyceni k mysi na mousemove
	$(".clickb").mousemove(function(e){
		this.l = parseInt(e.pageX) - parseInt($("#zalozka6").offset().left);
		this.t = parseInt(e.pageY) - parseInt($("#zalozka6").offset().top);
		
		$("#rbplus_tooltip")
		.css("top",(this.t + tOffset + tmouseOffset) + "px")
		.css("left",(this.l + lOffset + lmouseOffset) + "px");
	});
	
	/*
	//menu tooltip function declaration
	tt_tOffset = 10;
	tt_lOffset = 10;
	tt_tmouseOffset = 1;
	tt_lmouseOffset = 1;
	shiftMenu = 40;	
					    
	$("a.tooltip span em").hover(function(e){											  
		this.tit = $(this).parent().parent().attr("title");
		$(this).parent().parent().attr("title", "");									  
		$("#menu").append('<div id="tooltip">'+ this.tit +'</div>');
		
		this.top = parseInt($(this).css("top"));
		this.left = parseInt($(this).css("left"));
		
		this.l = parseInt(e.pageX) - parseInt($("#menu").offset().left);
		this.t = parseInt(e.pageY) - parseInt($("#menu").offset().top);
		
		$("#tooltip")
		.css("top",(this.t + tt_tOffset) + "px")
		.css("left",(this.l + tt_lOffset) + "px")
		.fadeIn("fast");		
	},
	function(){
		$(this).parent().parent().attr("title", this.tit); 
		$("#tooltip").remove();
	});
	
	$("a.tooltip").mousemove(function(e){
		this.top = parseInt($(this).css("top"));
		this.left = parseInt($(this).css("left"));
		
		this.l = parseInt(e.pageX) - parseInt($("#menu").offset().left);
		this.t = parseInt(e.pageY) - parseInt($("#menu").offset().top);
		
		$("#tooltip")
		.css("top",(this.t + tt_tOffset + tt_tmouseOffset) + "px")
		.css("left",(this.l + tt_lOffset + tt_lmouseOffset) + "px");
	});
	
	*/
	
	/* REDESIGN OCT 2011 - MENU PART */
	
	/*
	//bind hover box interaction and data fetching from array
	$(".fourth a").hover(
		function () {
			var prid = $(this).attr("id");
			var pr = prod_ids[prid].split("|");
			var detailbox = '<div id="detailbox"><div id="det_row"><h5 id="det_name">&nbsp;</h5><p id="det_weight_cont">Váha: <span id="det_weight">&nbsp;</span></p><p id="det_price_cont">Cena: <span id="det_price">&nbsp;</span></p></div><div class="clb"></div><img id="det_img" alt="noimg" src="/img/transparent.png" /></div>';
			$("#hMenu").append(detailbox);
			$("#detailbox").css("top", ($("#menu").height() + shiftMenu) + "px");
			$("#det_price").html(pr[0]);
			$("#det_name").html(pr[1]);
			$("#det_img").attr("src",pr[2]).attr("alt",pr[1]);
			$("#det_weight").html(pr[3]);
			//$("#detailbox").show();
	}, 
	function () {
		$("#detailbox").remove();
	});
	
	*/
	
	/* END REDESIGN OCT 2011 - MENU PART */

$('.productbarvy').mouseout(function() {
	$('#workover').remove();
	$('#newimgover').remove();
	$('#makecolor').remove();
	$('.price').show();
});


	$("a[rel=group],a.fancy").fancybox({'transitionIn'		: 'none','transitionOut'		: 'none','titlePosition' 	: 'over','hideOnContentClick':  'false','padding' : '0','titleFormat'       : function(title, currentArray, currentIndex, currentOpts)	{    return '<span id="fancybox-title-over">' +  (currentIndex + 1) + ' / ' + currentArray.length + ' | ' + title + '</span>';		}});
	$("a[rel=mainbikefoto]").fancybox({	'transitionIn'		: 'none','transitionOut'		: 'none','hideOnContentClick':  'false','padding' : '0','titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {    return '<span id="fancybox-title-over">' +  (currentIndex + 1) + ' / ' + currentArray.length + ' | ' + title + '</span>';}});
	$(".aurlimage a").fancybox({'transitionIn':'none','transitionOut':'none','hideOnContentClick':'false','padding' : '0','titleFormat'       : function(title, currentArray, currentIndex, currentOpts)	{    return '<span id="fancybox-title-over">' +  (currentIndex + 1) + ' / ' + currentArray.length + ' | ' + title + '</span>';}	});
	$("#tabulkalink a").fancybox({	'width'	: '50%','height': '70%',  'autoScale'  : false,  'transitionIn'	: 'elastic','transitionOut'	: 'elastic','type'				: 'iframe',	'padding': '0',	'hideOnContentClick':  	false});
	//$('#fader').cycle({ fx:    'fade', speed:  3000, random: 1 });
	$('#fader').cycle({ random: 1, fx:    'fade', speed:  3800 });

 	$("#proceeed").attr("disabled","disabled").fadeTo("fast", 0.5);
 	$("#souhlasspodm").click(function(){
        if ($("#souhlasspodm").is(":checked"))   {  $("#proceeed").removeAttr('disabled').fadeTo("fast", 1);;
        }else{   $("#proceeed").attr("disabled","disabled").fadeTo("fast", 0.5);;
        }});


$("#shippinginf").css("display","none");
$("#checkme").click(function(){
        if ($("#checkme").is(":checked"))
        {
            $("#shippinginf").show("fast");
        }else{
            $("#shippinginf").hide("fast");
        }});

$(".abox").click(function(){
	var idg = $(this).attr("id");
	var idgg = "#b" + idg;
	var typ = $("#ramset").val();

    setHeight(idgg);

	$("div.abox[id!="+ idg +"],div.ibox").fadeOut("fast");
	if($(idgg).css("display")!="none")
	{	closeit("b"+idg );
	}else{
		$(idgg).show();
		$(this).addClass("plusactive");
		selectboxy["b"+ idg] = $("#b"+ idg +" select").attr("selectedIndex");
	}

	$("#temp_vaha").val($(idgg).find('.hiddenvaha').val());

	if(typ=="Set"){

		var pctos = $("select option[value='']:selected").length;
		if(pctos >= 5){
			$(".dodinfo").html("<br />* Z cenově zvýhodněného setu lze odstranit max. 3 komponenty. Pro individuální konfigurace nás kontaktuje.");
			$("select option[value='']").not(":selected").attr("disabled","disabled").text("Nelze odstranit *");
		}else{
			$(".dodinfo").html("");
			$("select option[value='']").not(":selected").removeAttr('disabled').text("Odstranit ze setu");
		}

	 }else{

	  	var pctos = $("select option[value!='']:selected").length;
	  	//if(pctos >= 3){ alert("ano"); }
	 }

});
$(".ibox").click(function(){
	var idg = $(this).attr("id");
	var idgg = "b" + idg;

	$("div.ibox[id!="+ idg +"],div.abox").fadeOut("fast");
	if($('#'+idgg).css("display")!="none")
	{	closeiti("b"+idg );
	}else{
		$("#"+idgg).show();
		$(this).addClass("plusactive");
	}
});

$(".zalozka select").change(function(){	ajaxity(this);});
$(".zalozka select").keyup(function(){	ajaxity(this);});
$("#categorychange").change(function()
{
	if($(this).val() == "18")
	{
		$("#hiddenme").show();
	}else{
		$("#hiddenme").hide();
	}

});


$(".change").click(function(){
	var idkc = $(this).parents(".aboxdiv").attr("id");
	var koef = $("#koef").val();
	var typ = $("#ramset").val();

	selectboxy[idkc] = $("#"+ idkc +" select").attr("selectedIndex");
	ajaxity('#' + idkc + ' select');

	$(this).parents(".aboxdiv").find('.hiddenvaha').val($("#temp_vaha").val());

	revalprices();

	$('#' + idkc).fadeOut("fast");
	$("div").removeClass("plusactive");
	$(".abox,.ibox").fadeIn("fast");

	if($("#" + idkc +" select option[value^='*']:selected").length > 0)
	{
			$('#c' + idkc).html('<span class="blue">' + $('#' + idkc).find(".anazev").text() + '</span>');
	}else if($("#" + idkc +" select option[value='']:selected").length > 0)
	{
			$('#c' + idkc).html('<span class="blue">' + $('#' + idkc).find(".anazev").text() + '</span>');
	}else{
			$('#c' + idkc).html($('#' + idkc).find(".anazev").text());
	}



});

$(".close").click(function(){
	var idkc = $(this).parents(".aboxdiv").attr("id");
	closeit(idkc);
});
$(".closei").click(function(){
	var idkc = $(this).parents(".aboxdiv").attr("id");
	closeiti(idkc);
});

$("#logold").hide();

$("input[name='customer']").change(function(){
	if ($("input[name='customer']:checked").val() == '1'){
        $("#logold").hide();
        $("#regnew").show();
}
    else if ($("input[name='customer']:checked").val() == '2'){
        $("#regnew").hide();
    	$("#logold").show();}
});




});

$(window).load(function () {

  var r1 = $("input[id*=shipping_0_firstname]").val();
  var r2 = $("input[id*=shipping_0_lastname]").val();
  var r3 = $("input[id*=shipping_0_address1]").val();
  var r4 = $("input[id*=shipping_0_city]").val();
  var r5 = $("input[id*=shipping_0_postal]").val();

  var e1 = $("input[id*=billing_firstname]").val();
  var e2 = $("input[id*=billing_lastname]").val();
  var e3 = $("input[id*=billing_address1]").val();
  var e4 = $("input[id*=billing_city]").val();
  var e5 = $("input[id*=billing_postal]").val();

  if(
	r1 != e1 &&
	r2 != e2 &&
	r3 != e3 &&
	r4 != e4 &&
	r5 != e5
  )
  { $("#checkme").attr("checked","checked");
  	//show the hidden div
    $("#shippinginf").show("fast");
  }else{
  	$("input[id*=shipping_0_firstname]").val("");
	$("input[id*=shipping_0_lastname]").val("");
  }

  $("#pricechange").text($("span.kcena").text());


});

function ajaxity(a)
{	var krz = $("#krz").val();
	var valuesx = $(a).val();
	var thises = $(a);
	var prodid = $("#productid").val();
	var typ = $("#ramset").val();
	if(valuesx != undefined)
	{

	valuesx = valuesx.split('*@*');
	var idkcx = $(a).parents(".aboxdiv").attr("id");
	var inpity = $(a).parents(".a").find(".change");

	$(inpity).attr("disabled","disabled");

	$.ajax({type:"GET",url:"/ajax_zmena.php",data:{idk:valuesx[3],idp:prodid}, success: function(html){
	   		reval = html.split('|');
	  		var cen = parseInt(reval[0]);
	  		var hmotnost = parseInt(reval[1]);
	   		var inddex = selectboxy[$(a).parents(".aboxdiv").attr("id")];
	   		var puvcen = $(thises).find('option:eq('+ inddex +')').val();
	   		var puvhmotnost = $(a).parents(".aboxdiv").find('.hiddenvaha').val();
	   		if(puvcen == ""){ puvcen = "empty*@*0*@*0";}
	   		if(puvhmotnost == ""){ puvhmotnost = 0;}

	   		puvcen = puvcen.split('*@*');
	   		puvcen = parseInt(puvcen[1]);


	   		var vyslc = (puvcen - cen)*(-1);
	   		var vyslhmotnost = (puvhmotnost - hmotnost)*(-1);

	   		$("#temp_vaha").val(hmotnost);

	   		if(typ=="Rám")
			{
			    var pctos = $("select option[value!='']").length;
			  	if(pctos >= 5)
			  	{
			  		var namecpt = $(a).prevAll(".mainname").html();
			   		if(
				   		namecpt == "Rám" ||
				   		namecpt == "Tlumič" ||
				   		namecpt == "Frame" ||
				   		namecpt == "Shock-absorber"
			   		)
				   	{

				   	}else{

			  			vyslc = vyslc * 0.9;

				   	}
			  	}
			}
			vyslc=Math.round(vyslc/krz);

	   		if(vyslc >= "0")		{$("#"+idkcx + " .acenprefix").html("+");}else{$("#"+idkcx + " .acenprefix").html("");}
	   		if(vyslhmotnost >= "0")	{$("#"+idkcx + " .ahmotprefix").html("+");}else{$("#"+idkcx + " .ahmotprefix").html("");}
	   		$("#"+idkcx + " .acena").html(vyslc);
	  		$("#"+idkcx + " .ahmotnost").html(vyslhmotnost);
		  		if(reval[2]=="blank.gif" || reval[2]=="deleted.gif"){
		  		$("#"+idkcx + " .aurlimage").html('<img hspace="5" vspace="5" align="left" src="/uploads/Products/komponenty/thumb_' + reval[2] +'"  class="aimage" alt="' + htmlspecialchars(reval[4]) + '" title="' + htmlspecialchars(reval[4]) + '" />');
		  		}else if (reval[2]==""){
		  		$("#"+idkcx + " .aurlimage").html('');
		  		}else{
		  		$("#"+idkcx + " .aurlimage").html('<a href="/uploads/Products/komponenty/' + reval[2] + '" title="' + reval[4] + '"><img hspace="5" vspace="5" align="left" src="/uploads/Products/komponenty/thumb_' + reval[2] +'"  class="aimage" alt="' + htmlspecialchars(reval[4]) + '" title="' + htmlspecialchars(reval[4]) + '" /></a>');
		  		}
	  		$("#"+idkcx + " .apopis").html(reval[3]);
	  		$("#"+idkcx + " .anazev").html(reval[4]);

	  	if(typ=="Set"){

	        var pctos = $("select option[value='']:selected").length;
			if(pctos >= 5){$("select option[value='']").not(":selected").attr("disabled","disabled").text("Nelze odstranit *");
			}else{$("select option[value='']").not(":selected").removeAttr('disabled').text("Odstranit ze setu");}

	  	}else{

	  		var pctos = $("select option[value!='']:selected").length;
	  		//if(pctos >= 3){ alert("ano"); }

	  	}
			$(".aurlimage a").fancybox({'transitionIn':'none','transitionOut':'none','hideOnContentClick':'false','padding' : '0','titleFormat'       :  function(title, currentArray, currentIndex, currentOpts)	{    return '<span id="fancybox-title-over">' +  (currentIndex + 1) + ' / ' + currentArray.length + ' | ' + title + '</span>';}});

			$(inpity).removeAttr("disabled");
	   }
	 });
	}
}
function closeit(a)
{
	$('#' + a + ' select option').attr('selected', "false");
	$('#' + a + ' select option:eq('+ selectboxy[a] +')').attr('selected', 'selected');
	ajaxity('#' + a + ' select');
	$('#' + a).fadeOut("fast");
	$("div").removeClass("plusactive");
	$(".abox,.ibox").fadeIn("fast");
}
function closeiti(a)
{
	$('#' + a).fadeOut("fast");
	$("div").removeClass("plusactive");
	$(".ibox,.abox").fadeIn("fast");
}
function callit(a,b)
{
	$(a).children("div").html(b);
	return 'true';
}
function sh_bubble (a)
{
	$(a).show().delay(3000).fadeOut();
}
function validcart (){
	var krz = $("#krz").val();
	var typ = $("#ramset").val();

	if (typeof(stopcart) == "undefined")
	{

	}else{
		if(stopcart == true)
		{
			alert ("Nelze objednat aktuální výběr, nějaké důležité komponenty kola nejsou skladem.");
			return false;
		}
	}

	if(typ=="Rám")
	{
	    var pctos = $("select option[value!='']:selected").length;
	  	if(pctos >= 5)
	  	{

	  	$("select option[value!='']:selected").each(function(ind) {

			   	var namecpt = $(this).parent().prevAll(".mainname").html();
			   		if(
				   		namecpt == "Rám" ||
				   		namecpt == "Tlumič" ||
				   		namecpt == "Frame" ||
				   		namecpt == "Shock-absorber"
			   		)
				   	{

				   	}else{

					    var valik = $(this).val();
					    valik = valik.split('*@*');
				   		var cenchange = parseInt(valik[1]);
				   		cenchange = (cenchange)*(0.9);
				   		var newval = valik[0] + "*@*" + cenchange + "*@*" +  valik[2] + "*@*" + valik[3];
				   		$(this).val(newval);

				   	}

	  	});
	  	$("input[name*='_attrib_']").each(function(ind) {
	  		 	var namecpt = $(this).parent().prevAll(".mainname").html();
			   		if(
				   		namecpt == "Rám" ||
				   		namecpt == "Tlumič" ||
				   		namecpt == "Frame" ||
				   		namecpt == "Shock-absorber"
			   		)
				   	{

				   	}else{

		    var valik = $(this).val();
		    valik = valik.split('*@*');
	   		var cenchange = parseInt(valik[1]);

	   		cenchange = (cenchange)*(0.9);
	   		var newval = valik[0] + "*@*" + cenchange + "*@*" +  valik[2] + "*@*" + valik[3];
	   		$(this).val(newval);
				   	}
	  	});
	  	return true;
	  	}
	}else{

		if(krz > 1)
		{
		$("select option[value!='']:selected").each(function(ind) {

		    var valik = $(this).val();
		    valik = valik.split('*@*');
			var cenchange = parseInt(valik[1]);

			cenchange = (cenchange);
			var newval = valik[0] + "*@*" + cenchange + "*@*" +  valik[2] + "*@*" + valik[3];
			$(this).val(newval);

	  	});
	  	$("input[name*='_attrib_']").each(function(ind) {

		    var valik = $(this).val();
		    valik = valik.split('*@*');
	   		var cenchange = parseInt(valik[1]);

	   		cenchange = (cenchange);
	   		var newval = valik[0] + "*@*" + cenchange + "*@*" +  valik[2] + "*@*" + valik[3];
	   		$(this).val(newval);

	  	});
		}

	 	return true;
	}

}
function revalprices (){
	var typ = $("#ramset").val();
	var cprice = 0;
	var chmotnost = 0;
	var pevneprices = 0;
	var explh = 0;


	$(".hiddenvaha").each(function(ind) {
			explh = parseInt($(this).val());
			chmotnost = chmotnost + explh;
	});
	$("select option[value!='']:selected").each(function(ind) {
			var expl = $(this).val();
			//alert($(this).text());
			if(expl == ""){ expl = "empty*@*0*@*0";}
	   		expl = expl.split('*@*');
	   		expl = parseInt(expl[1]);

		   		if(typ=="Rám")
				{
					var namecpt = $(this).parent().prevAll(".mainname").html();
					//alert(namecpt);
			   		if(
				   		namecpt == "Rám" ||
				   		namecpt == "Tlumič" ||
				   		namecpt == "Frame" ||
				   		namecpt == "Shock-absorber"
			   		)
			   		{
			   			//alert("abc");
			   			pevneprices = pevneprices + expl;
			   		}else{
			   			cprice = cprice + expl;
			   		}
				}else{
			   			cprice = cprice + expl;
			   	}

	});
	$("input[name*='_attrib_']").each(function(ind) {
			var expl = $(this).val();
			if(expl == ""){ expl = "empty*@*0*@*0";}
	   		expl = expl.split('*@*');
	   		expl = parseInt(expl[1]);
	   		if(typ=="Rám")
				{
			   		var namecpt = $(this).parent().prevAll(".mainname").html();
			   		if(
				   		namecpt == "Rám" ||
				   		namecpt == "Tlumič" ||
				   		namecpt == "Frame" ||
				   		namecpt == "Shock-absorber"
			   		)
			   		{
			   			//alert("abc");
			   			pevneprices = pevneprices + expl;
			   		}else{
			   			cprice = cprice + expl;
			   		}
				}else{
			   			cprice = cprice + expl;
			   	}
	});

	var koef = $("#koef").val();
	var typ = $("#ramset").val();
	var krz = $("#krz").val();

		if(typ=="Rám")
		{
		    var pctos = $("select option[value!='']:selected").length;
		    //alert  (pctos);
		  	if(pctos >= 5)
		  	{
		  		cprice = cprice * 0.9;
		  	}
		}
		cprice = cprice + pevneprices;

	cprice=Math.round(cprice/krz);
	chmotnost=(Math.round(Math.round(chmotnost)/10)/100);
	chmotnost=String(chmotnost);

	chmotnost = chmotnost.replace(".", ",");

	$(".kcena").text(cprice);
	$(".khmotnost").text(chmotnost);
	$("#pricechange").text(cprice);



}

function setHeight(which) {
    var div = $(which);
    div.css({height: div.height()});
}

function htmlspecialchars (string, quote_style, charset, double_encode) {
    // Convert special characters to HTML entities
    //
    // version: 1008.1718
    // discuss at: http://phpjs.org/functions/htmlspecialchars    // +   original by: Mirek Slugen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Nathan
    // +   bugfixed by: Arno
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Ratheous
    // +      input by: Mailfaker (http://www.weedem.fr/)
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
    // +      input by: felix    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
    // %        note 1: charset argument not supported
    // *     example 1: htmlspecialchars("<a href='test'>Test</a>", 'ENT_QUOTES');
    // *     returns 1: '&lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;'
    // *     example 2: htmlspecialchars("ab\"c'd", ['ENT_NOQUOTES', 'ENT_QUOTES']);    // *     returns 2: 'ab"c&#039;d'
    // *     example 3: htmlspecialchars("my "&entity;" is still here", null, null, false);
    // *     returns 3: 'my &quot;&entity;&quot; is still here'
    var optTemp = 0, i = 0, noquotes= false;
    if (typeof quote_style === 'undefined' || quote_style === null) {        quote_style = 2;
    }
    string = string.toString();
    if (double_encode !== false) { // Put this first to avoid double-encoding
        string = string.replace(/&/g, '&amp;');    }
    string = string.replace(/</g, '&lt;').replace(/>/g, '&gt;');

    var OPTS = {
        'ENT_NOQUOTES': 0,        'ENT_HTML_QUOTE_SINGLE' : 1,
        'ENT_HTML_QUOTE_DOUBLE' : 2,
        'ENT_COMPAT': 2,
        'ENT_QUOTES': 3,
        'ENT_IGNORE' : 4    };
    if (quote_style === 0) {
        noquotes = true;
    }
    if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags        quote_style = [].concat(quote_style);
        for (i=0; i < quote_style.length; i++) {
            // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
            if (OPTS[quote_style[i]] === 0) {
                noquotes = true;            }
            else if (OPTS[quote_style[i]]) {
                optTemp = optTemp | OPTS[quote_style[i]];
            }
        }        quote_style = optTemp;
    }
    if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
        string = string.replace(/'/g, '&#039;');
    }    if (!noquotes) {
        string = string.replace(/"/g, '&quot;');
    }

    return string;}
