/*-------------js_carousel.js*/

var initialLoad = true;

jQuery(document).ready(function() {

    buildHorizontalList();

    buildMainCarousel();

    buildShopCarousel();
});

function mycarousel_itemLoadCallback1(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }

		var singleshop=0;
    	var productids = $("#shopwindowids_"+carousel.options['pageBlockId']).val();

		jQuery.get(
        '/blocks/product_div',
        {
            first: carousel.first,
			productids:productids,
			singleshop:singleshop,
            last: carousel.last
        },
        function(xml) {
            mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);
            $(window).resize();
        },
        'xml'
    );

};

function mycarousel_itemAddCallback(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));

    jQuery('item', xml).each(function(i) {
        carousel.add(first + i, jQuery(this).text());
    });

    carousel.reload();
};

function buildShopCarousel() {
    var divs = $("div[id*='shopdiv_']");

	$.each(divs,function() {

		var currentId = $(this).attr('id');
		var pageBlockId = currentId.substr(8,currentId.length);

		var jqc = jQuery(this).jcarousel({
		    // Uncomment the following option if you want items
		    // which are outside the visible range to be removed
		    // from the DOM.
		    // Useful for carousels with MANY items.
		    itemVisibleOutCallback: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
                    buttonNextHTML: '<div></div>',
		    buttonPrevHTML: '<div></div>',
                    visible:1,
		    pageBlockId:pageBlockId,
		    itemLoadCallback: mycarousel_itemLoadCallback1
	});
    });
}



function horizontalList_itemLoadCallback1(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }
	    var singleshop=1;
    	var productids = $("#horizontalids_"+carousel.options['pageBlockId']).val();
    	var teaser     = $("#horizontalteaser_"+carousel.options['pageBlockId']).val();
        var brand      = $("#horizontalidsbrand_"+carousel.options['pageBlockId']).val();
        var cCode      = $("#currencyCode").val();
        var cRate      = $("#currencyRate").val();

		jQuery.get(
        '/blocks/product_div',
        {
            first: carousel.first,
			productids:productids,
			singleshop:singleshop,
                        cRate:cRate,
                        cCode:cCode,
            last:carousel.last,
            brand:brand,
            teaser:teaser
        },
        function(xml) {
            mycarousel_itemAddCallback1(carousel, carousel.first, carousel.last, xml);
           
            $(window).resize();
        },
        'xml'
    );
    //});
};

function mycarousel_itemAddCallback1(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));

    jQuery('item', xml).each(function(i) {
        carousel.add(first + i, jQuery(this).text());
    });
};


jQuery(document).ready(function() {
	var divs = $("div[id*='horizontalList_']");

	$.each(divs,function() {

		var myWidth = getWidth();

		var currentId = $(this).attr('id');
		var pageBlockId = currentId.substr(15,currentId.length);
		var visible =  (myWidth-myWidth%300)/300;

		jQuery(this).jcarousel({
		    // Uncomment the following option if you want items
		    // which are outside the visible range to be removed
		    // from the DOM.
		    // Useful for carousels with MANY items.
		    itemVisibleOutCallback1: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
			visible:visible,
			pageBlockId:pageBlockId,
		    itemLoadCallback: horizontalList_itemLoadCallback1
		});
	});
});



function mycarousel_itemLoadCallbackCarousel(carousel, state)
{

    // Check if the requested items already exist

    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }
	    var singleshop=1;

    	var productids = $("#carouselids_"+carousel.options['pageBlockId']).val();
        var teaser     = $("#carouselteaser_"+carousel.options['pageBlockId']).val();
        var brand      = $("#carouselbrand_"+carousel.options['pageBlockId']).val();
        var cCode      = $("#currencyCode").val();
        var cRate      = $("#currencyRate").val();

		jQuery.get(
        '/blocks/product_div',
        {
                        first: carousel.first,
			productids:productids,
                        brand:brand,
                        cRate:cRate,
                        cCode:cCode,
                        teaser:teaser,
			singleshop:singleshop,
                        last: carousel.last
        },
        function(xml) {
            mycarousel_itemAddCallbackCarousel(carousel, carousel.first, carousel.last, xml);
            $(window).resize();
        },
        'xml'
    );
    //});
};

function mycarousel_itemAddCallbackCarousel(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));

    jQuery('item', xml).each(function(i) {
        carousel.add(first + i, jQuery(this).text());
    });
};
/*
function mycarousel_itemAddCallbackCarousel(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));

    jQuery('item', xml).each(function(i) {
        carousel.add(first + i, jQuery(this).text());
    });
};*/

function buildMainCarousel() {
    var divs    = $("div[id*='productsCarousel_']");

	$.each(divs,function() {

		var myWidth = getWidth();

		var currentId = $(this).attr('id');
		var pageBlockId = currentId.substr(17,currentId.length);
		var visible =  (myWidth-myWidth%300)/300 - 1;
		var scroll  = 3;

                if(visible<=2) {
                    scroll = visible;
                }

		jQuery(this).jcarousel({
		    // Uncomment the following option if you want items
		    // which are outside the visible range to be removed
		    // from the DOM.
		    // Useful for carousels with MANY items.
		    itemVisibleOutCallbackCarousel: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
			visible:visible,
                        scroll:scroll,
			pageBlockId:pageBlockId,
	        buttonNextHTML: '<div></div>',
	        buttonPrevHTML: '<div></div>',
		    itemLoadCallback: mycarousel_itemLoadCallbackCarousel
		});
	});
}

function horizontalList_itemLoadCallbackCarousel(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }
	    var singleshop=1;
    	var productids = $("#promoids_"+carousel.options['pageBlockId']).val();

		jQuery.get(
        '/blocks/product_div',
        {
            first: carousel.first,
			productids:productids,
			singleshop:singleshop,
            last: carousel.last
        },
        function(xml) {
            mycarousel_itemAddCallbackCarousel(carousel, carousel.first, carousel.last, xml);
            $(window).resize();
        },
        'xml'
    );
    //});
};

function buildHorizontalList() {

    	var divs = $("div[id*='promoCarousel_']");

	$.each(divs,function() {

		var myWidth = getWidth();

		var currentId = $(this).attr('id');
		var pageBlockId = currentId.substr(14,currentId.length);
		var visible =  (myWidth-myWidth%300)/300 - 1;
		var scroll  = 3;

                if(visible<=2) {
                    scroll = visible;
                }

		jQuery(this).jcarousel({
		    // Uncomment the following option if you want items
		    // which are outside the visible range to be removed
		    // from the DOM.
		    // Useful for carousels with MANY items.
		    itemVisibleOutCallbackCarousel: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
			visible:6,
                        scroll:scroll,
			pageBlockId:pageBlockId,
	        buttonNextHTML: '<div></div>',
	        buttonPrevHTML: '<div></div>',
		    itemLoadCallback: horizontalList_itemLoadCallbackCarousel
		});
	});
}

function hotel_itemLoadCallbackCarousel(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }
    	var storeids = $("#hotelids_"+carousel.options['pageBlockId']).val();
		jQuery.get(
        '/blocks/hotel_div',
        {
            first: carousel.first,
            storeids:storeids,
            last: carousel.last
        },
        function(xml) {
            hotel_itemAddCallbackCarousel(carousel, carousel.first, carousel.last, xml);
            $(window).resize();
        },
        'xml'
    );
    //});
};

function hotel_itemAddCallbackCarousel(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));

    jQuery('item', xml).each(function(i) {
        carousel.add(first + i, jQuery(this).text());
    });
};

jQuery(document).ready(function() {

	var divs = $("div[id*='hotelCarousel_']");

	$.each(divs,function() {

		var currentId = $(this).attr('id');
		var pageBlockId = currentId.substr(14,currentId.length);

		jQuery(this).jcarousel({
		    // Uncomment the following option if you want items
		    // which are outside the visible range to be removed
		    // from the DOM.
		    // Useful for carousels with MANY items.
		    itemVisibleOutCallbackCarousel: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
			visible:6,
			pageBlockId:pageBlockId,
	        buttonNextHTML: '<div></div>',
	        buttonPrevHTML: '<div></div>',
		    itemLoadCallback: hotel_itemLoadCallbackCarousel
		});
	});
});



function hotel_itemLoadCallbackList(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }
    	var storeids = $("#horizontalhotelids_"+carousel.options['pageBlockId']).val();
		jQuery.get(
        '/blocks/hotel_div',
        {
            first: carousel.first,
			storeids:storeids,
            last: carousel.last
        },
        function(xml) {
            hotel_itemAddCallbackCarousel(carousel, carousel.first, carousel.last, xml);
            $(window).resize();
        },
        'xml'
    );
    //});
};

function hotel_itemAddCallbackList(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));

    jQuery('item', xml).each(function(i) {
        carousel.add(first + i, jQuery(this).text());
    });
};

jQuery(document).ready(function() {

	var divs = $("div[id*='horizontalHotelList_']");

	$.each(divs,function() {

		var myWidth = getWidth();

		var currentId = $(this).attr('id');
		var pageBlockId = currentId.substr(20,currentId.length);
		var visible =  (myWidth-myWidth%300)/300;

		jQuery(this).jcarousel({
		    // Uncomment the following option if you want items
		    // which are outside the visible range to be removed
		    // from the DOM.
		    // Useful for carousels with MANY items.
		    hotel_itemAddCallbackList: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
			visible:6,
			pageBlockId:pageBlockId,
		    itemLoadCallback: hotel_itemLoadCallbackList
		});
	});
});




function bigHorizontalList_itemLoadCallback(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }

	var singleshop=3;
    	var productids = $("#bighorizontalids_"+carousel.options['pageBlockId']).val();
    	var teaser     = $("#bighorizontalteaser_"+carousel.options['pageBlockId']).val();
        var cCode      = $("#currencyCode").val();
        var cRate      = $("#currencyRate").val();

		jQuery.get(
        '/blocks/product_div',
        {
            first: carousel.first,
			productids:productids,
			singleshop:singleshop,
                        cRate:cRate,
                        cCode:cCode,
            last:carousel.last,
            teaser:teaser
        },
        function(xml) {
            mycarousel_itemAddCallbackBig(carousel, carousel.first, carousel.last, xml);
            $(window).resize();
        },
        'xml'
    );
    //});
};

function mycarousel_itemAddCallbackBig(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));

    jQuery('item', xml).each(function(i) {
        carousel.add(first + i, jQuery(this).text());
    });
    carousel.reload()
};


jQuery(document).ready(function() {
	var divs = $("div[id*='bigHorizontalList_']");
	$.each(divs,function() {

		var myWidth = getWidth();

		var currentId = $(this).attr('id');
		var pageBlockId = currentId.substr(18,currentId.length);
		var visible =  (myWidth-myWidth%530)/530;

		jQuery(this).jcarousel({
		    mycarousel_itemAddCallbackBig: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
			visible:visible,
                        bigPictures:1,
			pageBlockId:pageBlockId,
		    itemLoadCallback: bigHorizontalList_itemLoadCallback
		});
	});
});



function hotel_itemLoadCallbackListBig(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }
    var singleshop = 3;
    	var storeids = $("#bighorizontalhotelids_"+carousel.options['pageBlockId']).val();
		jQuery.get(
        '/blocks/hotel_div',
        {
            singleshop:singleshop,
            first: carousel.first,
            storeids:storeids,
            last: carousel.last
        },
        function(xml) {
            hotel_itemAddCallbackListBig(carousel, carousel.first, carousel.last, xml);
            $(window).resize();
        },
        'xml'
    );
    //});
};

function hotel_itemAddCallbackListBig(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));

    jQuery('item', xml).each(function(i) {
        carousel.add(first + i, jQuery(this).text());
    });

    carousel.reload()
};

jQuery(document).ready(function() {
	var divBigHotels = $("div[id*='bigHorizontalHotelList_']");

	$.each(divBigHotels,function() {
		var myWidth = getWidth();

		var currentId = $(this).attr('id');
		var pageBlockId = currentId.substr(23,currentId.length);
		var visible =  (myWidth-myWidth%530)/530;

		jQuery(this).jcarousel({
                        hotel_itemAddCallbackListBig: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
			visible:visible,
                        bigPictures:1,
			pageBlockId:pageBlockId,
                        itemLoadCallback:hotel_itemLoadCallbackListBig
		});
	});
});

$(document).ready(function(){
    	var divs = $("div[id*='promoCarousel_']");
        var urlbase = $("#urlbase").val();

	$.each(divs,function() {

		var currentId = $(this).attr('id');
		var pageBlockId = currentId.substr(14,currentId.length);

                var update = $("#updateCounter_"+pageBlockId).val();
                if(update == 1) {
                    var displaycounter = $("#counter_"+pageBlockId).val();

                    $.post(urlbase+"ajax/updatePromoCarouselCounter/"+displaycounter+"/"+pageBlockId);
                }
         });
});

    function getWidth() {
        var myWidth = 0;

        if( typeof( window.innerWidth ) == 'number' ) {
            //Non-IE
            myWidth = window.innerWidth;
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
            myWidth = document.body.clientWidth;
        }

        return myWidth;
    }

/*--------------------------js_carousel.js end--------------------------------*/


/*--------------------------functions.js start--------------------------------*/



function isNumber( value )
{
    var fieldValueInt = parseInt (value);
    var fieldValueFloat = parseFloat (value);
    if(value == fieldValueInt || value == fieldValueFloat ){
        return true;
    }else{
        return false;
    }
}


function echeck(str){
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

   if(reg.test(str) == false) {
      return false;
   }
   return true;

}
function echeck2(str) {


		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){

		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){

		    return false
		 }

		 if (str.indexOf(" ")!=-1){

		    return false
		 }

 		 return true
	}

    function fbs_click() {
        u=location.href;
        t=document.title;
        window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
        return false;
    }

    function textCounter( field, countfield, maxlimit ) {
      if ( field.value.length > maxlimit )
      {
        field.value = field.value.substring( 0, maxlimit );
        //alert( 'Го поминавте бројот на дозволени карактери.' );
        return false;
      }
      else
      {
        countfield.value = maxlimit - field.value.length;
      }
    }

    function redirect(where)
    {
        window.location = where;
    }

    function getHelpIcon(name)
    {
        var helpIcon = ' <span>';
    helpIcon +="<a name='helper' title='"+name+"' href='#'><img width='16px' height='16px' src='/images/help.png'/></a>";
    helpIcon +='  </span>';
    return helpIcon;
    }

    function replaceall(find,replacechar,originalString){
	for (i=0;i<originalString.length;i++){
		originalString=originalString.replace(find,replacechar);
	}
	return originalString;
}

function initializeCheckBoxFields(opt1, opt2, opt3)
{
   var checkboxOptions = '<select id="checkbox_select">';
   checkboxOptions += '<option value=0>'+opt1+'</option>'
   checkboxOptions += '<option value=1>'+opt2+'</option>'
   checkboxOptions += '<option value=2>'+opt3+'</option>'
   checkboxOptions += '</select>'
   $(".subtitulo:last").append(checkboxOptions);
   $('#checkbox_select').change(function(){
       if($('#checkbox_select').val() == 1){
           $("input[name=number]").attr('checked', true);
       }
       if($('#checkbox_select').val() == 2){
            $("input[name=number]").attr('checked', false);
       }
   });

}

function wordwrap( str, int_width, str_break, cut ) {

    var m = ((arguments.length >= 2) ? arguments[1] : 75   );
    var b = ((arguments.length >= 3) ? arguments[2] : "\n" );
    var c = ((arguments.length >= 4) ? arguments[3] : false);

    var i, j, l, s, r;

    str += '';

    if (m < 1) {
        return str;
    }

    for (i = -1, l = (r = str.split(/\r\n|\n|\r/)).length; ++i < l; r[i] += s) {
        for(s = r[i], r[i] = ""; s.length > m; r[i] += s.slice(0, j) + ((s = s.slice(j)).length ? b : "")){
            j = c == 2 || (j = s.slice(0, m + 1).match(/\S*(\s)?$/))[1] ? m : j.input.length - j[0].length || c == 1 && m || j.input.length + (j = s.slice(m).match(/^\S*/)).input.length;
        }
    }

    return r.join("\n");
}

function showLang(lang)
{
    $("#"+lang+"_page").val(1);
    $("div[name=lang]").hide();
    $("#"+lang).show();
}

function popitup(url) {
	newwindow=window.open(url,"name","location=1,status=1,scrollbars=1,width=800,height=600,screenX=400,screenY=400");
	//newwindow.moveTo(0,0);
	if (window.focus) {newwindow.focus()}
	return false;
}

function showMethod(id, storeId)
{
    url = '/shipping_info/index/'+id+'/'+storeId;
    newwindow=window.open(url,"name","location=1,status=1,scrollbars=1,width=800,height=600,screenX=400,screenY=400");
    if (window.focus) {newwindow.focus()}
	//return false;
}

function loadProgress() {

         var html = '<div id="fancy_overlay_1" class="progress" style="opacity: 0.3; display: block;">';
         html += '<img id="progress_image"  width="40px" height="40px" style="margin-top:300px;padding-left:5px;padding-top:5px;" src="/images/icon-loading-animated_04.gif" alt="" />';
         html += '</div>';
         $(html).appendTo("body");
    }

function hideProgress()
{
    $("#fancy_overlay_1").remove();
}



function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   }
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

function expandCategories(id)
{

    if(id){
        var elid = id;
    }else{
        var elid = 1;
    }
             $("#ygtvc"+elid+" .ygtvlabel").each(function(){
                var id = $(this).attr('id');
                var ids = id.split('ygtvlabelel');

                if($("#ygtvc"+ids[1]).css('display') == 'none' ){

                      //YAHOO.widget.TreeView.getNode('taskTreeView' , 2).toggle();
                      YAHOO.widget.TreeView.getNode('taskTreeView' , ids[1]).toggle();

                      var checked = $("#ygtv"+ids[1]+" .ygtvcheck2");

                      if( checked.length == 0 ){
                            YAHOO.widget.TreeView.getNode('taskTreeView' , ids[1]).toggle();
                      }
                }

                if($("#ygtvc"+ids[1]).hasClass('ygtvchildren')){
                    expandCategories(ids[1]);
                }





             })
}






function printSelection(node,notincludeCss){

  var content=node.innerHTML
  var pwin=window.open('','print_content','width=100,height=100');

  pwin.document.open();

  var html = '';
  if(!notincludeCss)
  {    html += '<link rel="stylesheet" href="/css/blueprint/screen.css" type="text/css" media="screen, projection"/>';
      html += '<link rel="stylesheet" href="/css/blueprint/print.css" type="text/css" media="print"/>';
      html += '<link rel="stylesheet" href="/css/mycustom.css" type="text/css" media="print" />';

      html +='<style type="text/css" media="print">';


    //  html +='#'+node+'{';
    //  html +='size: landscape;';
    //  html +='margin: 2cm;}';



      html += '@page port {size: portrait;}';
      html += '@page land {size: landscape;}';

      html += '.portrait {page: port;}';

      html += '.landscape {page: land;}';

      html += '</style>';
   }
  pwin.document.write('<html><head>'+html+'</head><body onload="window.print()">'+content+'</body></html>');


  //pwin.document.write('<html><body onload="window.print()">'+content+'</body></html>');
  pwin.document.close();

  setTimeout(function(){pwin.close();},1000);

}


function printPublicSelection(node,notincludeCss){

  var content=node.innerHTML
  var pwin=window.open('','print_content','width=100,height=100');

  pwin.document.open();

  var html = '';
  if(!notincludeCss)
  {    html += '<link rel="stylesheet" href="/css/public/tabs.css" type="text/css" />';
       html +='  <link rel="stylesheet" href="/css/jquery.tooltip.css" type="text/css"/>';

       html +='  <link rel="stylesheet" href="/css/yui-grids/reset-fonts-grids.css" type="text/css" media="screen, projection"/>';
       html +='  <link rel="stylesheet" href="/css/yui-grids/grids-min.css" type="text/css" media="screen, projection"/>';
       html +='  <link rel="stylesheet" href="/css/public/main.css" type="text/css" media="screen, projection"/>';
       html +='  <link rel="stylesheet" href="/css/public/main_menu.css" type="text/css" media="screen, projection"/>';

      html +='<style type="text/css" media="print">';


    //  html +='#'+node+'{';
    //  html +='size: landscape;';
    //  html +='margin: 2cm;}';



      html += '@page port {size: portrait;}';
      html += '@page land {size: landscape;}';

      html += '.portrait {page: port;}';

      html += '.landscape {page: land;}';

      html += '</style>';
   }
  pwin.document.write('<html><head>'+html+'</head><body onload="window.print()">'+content+'</body></html>');


  //pwin.document.write('<html><body onload="window.print()">'+content+'</body></html>');
  pwin.document.close();

  setTimeout(function(){pwin.close();},1000);

}

 function mathCapchaFristNum()
 {

       return    Math.floor(Math.random()*11);
  }

 function mathCapchaSecountNum()
  {

        return     Math.floor(Math.random()*11);
  }

 function mathCapchaOperator()
  {
      var operators = new Array("+","-","x");
      var index = Math.floor(Math.random()*3);
      return   operators[index];
  }

   function mathCapchaOperation(operationString)
    {
           var operators = operationString.split(" ");
           var num1 = Number(operators[0]);
           var num2 = Number(operators[2]);

          switch(operators[1])
          {
              case '+':
                  return num1+num2
                  break;
              case '-':
                  return num1-num2
                  break;

              case 'x':
                  return num1*num2
                  break;

              default: return 0;

          }
   }

   function createCaptcha(captchaContainer, result){

       $(captchaContainer).text(mathCapchaFristNum()+' '+mathCapchaOperator()+' '+mathCapchaSecountNum());
       $(result).val(mathCapchaOperation($(captchaContainer).text()));
   }


function isArray(obj) {
    return (obj.constructor.toString().indexOf('Array') != -1);
}


/*
 * js/hoverintent.js
 **/

(function($){
	/* hoverIntent by Brian Cherne */
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};

})(jQuery);



/**
 * /js/superfish.js
 */


/*
 * Superfish v1.4.8 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */

;(function($){
	$.fn.superfish = function(op){

		var sf = $.fn.superfish,
			c = sf.c,
			//$arrow = $(['<span class="',c.arrowClass,'"> </span>'].join('')),
			over = function(){
				var $$ = $(this), menu = getMenu($$);
				clearTimeout(menu.sfTimer);
				$$.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function(){
				var $$ = $(this), menu = getMenu($$), o = sf.op;
				clearTimeout(menu.sfTimer);
				menu.sfTimer=setTimeout(function(){
					o.retainPath=($.inArray($$[0],o.$path)>-1);
					$$.hideSuperfishUl();
					if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
				},o.delay);
			},
			getMenu = function($menu){
				var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
				sf.op = sf.o[menu.serial];
				return menu;
			};
			//addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };

		return this.each(function() {
			var s = this.serial = sf.o.length;
			var o = $.extend({},sf.defaults,op);
			o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
				$(this).addClass([o.hoverClass,c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
			});
			sf.o[s] = sf.op = o;

			$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {

			})
			.not('.'+c.bcClass)
				.hideSuperfishUl();

			var $a = $('a',this);
			$a.each(function(i){
				var $li = $a.eq(i).parents('li');
				$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
			});
			o.onInit.call(this);

		}).each(function() {
			var menuClasses = [c.menuClass];
			if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
			$(this).addClass(menuClasses.join(' '));
		});
	};

	var sf = $.fn.superfish;
	sf.o = [];
	sf.op = {};
	sf.IE7fix = function(){
		var o = sf.op;
		if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
			this.toggleClass(sf.c.shadowClass+'-off');
		};
	sf.c = {
		bcClass     : 'sf-breadcrumb',
		menuClass   : 'sf-js-enabled',
		anchorClass : 'sf-with-ul',
		arrowClass  : 'sf-sub-indicator',
		shadowClass : 'sf-shadow'
	};
	sf.defaults = {
		hoverClass	: 'sfHover',
		pathClass	: 'overideThisToUse',
		pathLevels	: 1,
		delay		: 800,
		animation	: {opacity:'show'},
		speed		: 'normal',
		autoArrows	: true,
		dropShadows : true,
		disableHI	: false,		// true disables hoverIntent detection
		onInit		: function(){}, // callback functions
		onBeforeShow: function(){},
		onShow		: function(){},
		onHide		: function(){}
	};
	$.fn.extend({
		hideSuperfishUl : function(){
			var o = sf.op,
				not = (o.retainPath===true) ? o.$path : '';
			o.retainPath = false;
			var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').hide().css('visibility','hidden');
			o.onHide.call($ul);
			return this;
		},
		showSuperfishUl : function(){
			var o = sf.op,
				sh = sf.c.shadowClass+'-off',
				$ul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility','visible');
			sf.IE7fix.call($ul);
			o.onBeforeShow.call($ul);
			$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
			return this;
		}
	});

})(jQuery);

//======================================
/*--------------------------functions.js end--------------------------------*/


/*--------------------------/js/script_functions.js start--------------------------------*/
    $(document).ready(function(){


           $("#book_arrangement").click(function(){

            var quantity = $("input[name=quantity]").val();
            var sizeId = $("select[name=sizes] option[selected]").attr('id');

            var url = '/patuvanje/aranzmani/cartarrangement?pvsid='+sizeId+'&qty='+quantity;
            window.location = url;


          });


         //labeliranje na inpust-pass i input-email
            $('#password-clear').show();
            $('#password-password').hide();

            $('#password-clear').focus(function() {
                   $('#password-clear').hide();
                   $('#password-password').show();
                   $('#password-password').focus();
                   $('#password-password').css("color","#000000");

            });

            $('#password-password').blur(function() {
                       if($('#password-password').val() == '') {
                                $('#password-clear').show();
                                $('#password-password').hide();
                       }
             });



            $('.email-email').addClass("inactive");
            var text = $('.email-email').val();

            $('.email-email').focus(function(){

                   $(this).addClass("focused");
                   $(this).removeClass("inactive");
                   $(this).removeClass("active");
                   $(this).css("color","#000000");
                     if($(this).val() == text ) {
                         $(this).val("");
                     }


             });
             $('.email-email').blur(function(){
                   $(this).removeClass("focused");
                           if($(this).val() == "") {
                                $(this).val(text);
                                $(this).addClass("inactive");
                                $(this).css("color","gray");
                         } else {
                             $(this).addClass("active");
                      };
              });

        $("select[name=variant]").change(function(){
            var id = $(this).attr("id");
            var idArray = id.split('_');

            var hideElement = true;
            var variantsJson = $("input[name=variantsJson_"+idArray[1]+"]").val();
            var variants = eval("("+unescape(variantsJson)+")");
            var variantId = $("#"+id+" option[selected]").attr('id');
            var sizes = variants[variantId]['sizes'];
            html= '';
           $.each(sizes, function(i,n){
               if(n['size_name'] != ''){
                   hideElement = false;
               }
                html += '<option id="'+i+'" value="'+n['price']+'_'+n['teaser_price']+'">'+n['size_name']+'</option>';
           });

           $("#sizes_"+idArray[1]).html(html);

           if(hideElement){
               //$("#sizes_"+idArray[1]).parents().hide();
               $("#sizes_"+idArray[1]).parents("div[name=siz_con]").hide();
           }else{
               //$("#sizes_"+idArray[1]).show();
               $("#sizes_"+idArray[1]).parents("div[name=siz_con]").show();
           }

       });


            $('a[name=helper]').tooltip({
                track: true,
                delay: 0,
                showURL: false,
                showBody: " - ",
                fade: 250
            });


              $("#opinion_popup").show();
              $("#opinion_popup a").fancybox({
                    'hideOnContentClick': false,
                     'frameWidth': 400,
                     'frameHeight': 400
               });

    });


function addToCart(productId)
{
    // var productId = $(a).attr('name');
            var productVariantSizeId = $("#sizes_"+productId+" option[selected]").attr('id');
            $("input[name=productVariantSizeId]").val(productVariantSizeId);
            $("form[name=addtocart_form_"+productId+"]").submit();

}
function setVariantSizeForm(productId)
{
    //$("input[name=variantsJson_"+productId+"]").remove();
    addToCart(productId);
}
function submitAddToCartForm(e,productId)
{

    if(e.which == 13)
    {
        addToCart(productId);
    }
    return false;
}

 function verifySeal() {
     var bgHeight = "433";
     var bgWidth = "536";
     var url = "https://seal.godaddy.com:443/verifySeal?sealID=BXYShLOr9KW5lnpVRLqDpl0onBfdi8ZkmHm7NGKcSuhPfQ7gTtr";
     window.open(url,'SealVerfication','location=yes,status=yes,resizable=yes,scrollbars=no,width=' + bgWidth + ',height=' + bgHeight);
 }

//==========================================================================
//Preloaded images
Image1= new Image(180,30)
Image1.src = "/images/redesign_elements/unselected_tab.png"

Image2= new Image(183,31)
Image2.src = "/images/redesign_elements/shopping_selected_tab.png"

Image3 = new Image(183,31)
Image3.src = "/images/redesign_elements/patuvanje_selected_tab.png"

Image4= new Image(183,31)
Image4.src = "/images/redesign_elements/nastani_selected_tab.png"

Image5= new Image(183,31)
Image5.src = "/images/redesign_elements/shopping_selected_tab_hover.png"

Image6= new Image(183,31)
Image6.src = "/images/redesign_elements/patuvanje_selected_tab_hover.png"

Image7= new Image(183,31)
Image7.src = "/images/redesign_elements/nastani_selected_tab_hover.png"

Image8= new Image(16,17)
Image8.src = "/images/redesign_elements/drop_blue.png"

Image9= new Image(16,17)
Image9.src = "/images/redesign_elements/drop_red.png"

Image10= new Image(16,17)
Image10.src = "/images/redesign_elements/drop_green.png"

Image11= new Image(16,17)
Image11.src = "/images/redesign_elements/drop_blue_hover.png"

Image12= new Image(16,17)
Image12.src = "/images/redesign_elements/drop_red_hover.png"

Image13= new Image(16,17)
Image13.src = "/images/redesign_elements/drop_green_hover.png"

Image14= new Image(30,30)
Image14.src = "/images/redesign_elements/left_blue.png"

Image15= new Image(30,30)
Image15.src = "/images/redesign_elements/left_blue_hover.png"

Image16= new Image(30,30)
Image16.src = "/images/redesign_elements/left_blue_active.png"

Image17= new Image(30,30)
Image17.src = "/images/redesign_elements/right_blue.png"

Image18= new Image(30,30)
Image18.src = "/images/redesign_elements/right_blue_hover.png"

Image19= new Image(30,30)
Image19.src = "/images/redesign_elements/right_blue_active.png"

Image20= new Image(30,30)
Image20.src = "/images/redesign_elements/left_red.png"

Image21= new Image(30,30)
Image21.src = "/images/redesign_elements/left_red_hover.png"

Image22= new Image(30,30)
Image22.src = "/images/redesign_elements/left_red_active.png"

Image23= new Image(30,30)
Image23.src = "/images/redesign_elements/right_red.png"

Image24= new Image(30,30)
Image24.src = "/images/redesign_elements/right_red_hover.png"

Image25= new Image(30,30)
Image25.src = "/images/redesign_elements/right_red_active.png"

Image26= new Image(30,30)
Image26.src = "/images/redesign_elements/left_green.png"

Image27= new Image(30,30)
Image27.src = "/images/redesign_elements/left_green_hover.png"

Image28= new Image(30,30)
Image28.src = "/images/redesign_elements/left_green_active.png"

Image29= new Image(30,30)
Image29.src = "/images/redesign_elements/right_green.png"

Image30= new Image(30,30)
Image30.src = "/images/redesign_elements/right_green_hover.png"

Image31= new Image(30,30)
Image31.src = "/images/redesign_elements/right_green_active.png"

Image32= new Image(130,26)
Image32.src = "/images/redesign_elements/normal_blue.png"

Image33= new Image(130,26)
Image33.src = "/images/redesign_elements/blue.png"

Image34= new Image(30,30)
Image34.src = "/images/redesign_elements/blue_hover.png"

Image35= new Image(130,26)
Image35.src = "/images/redesign_elements/normal_red.png"

Image36= new Image(130,26)
Image36.src = "/images/redesign_elements/red.png"

Image37= new Image(30,30)
Image37.src = "/images/redesign_elements/red_hover.png"

Image38= new Image(130,26)
Image38.src = "/images/redesign_elements/normal_green.png"

Image39= new Image(130,26)
Image39.src = "/images/redesign_elements/green.png"

Image40= new Image(30,30)
Image40.src = "/images/redesign_elements/green_hover.png"
//=============================================================================



/*--------------------------script_functions.js end--------------------------------*/


/*--------------------------date_picker_invoke.js start--------------------------------*/
    function setDateWidgets(json){
        var dates = Array();

    var jsonDates = json
    var noShow = Array();

    noShow[0] = false;
    noShow[1] = '';

    var doShow = Array();
    doShow[0] = true;
    doShow[1] = '';

    $("#datepicker").datepicker({
    	beforeShowDay: function(originalDate) {
    	var setter = 1;

				for(i in jsonDates.dates) {
					var dateObject   = new Date(originalDate);
					var date = new Date(jsonDates.dates[i].date);

			  		if((dateObject.getDate() == date.getDate()) && (dateObject.getMonth() == date.getMonth()) ) {
						setter = 0;
					}
				}

				if(setter==0) {
					return doShow;
				} else {
					return noShow;
				}
    	},

    	onSelect:   function(dateText, inst) {

    		var activeDate = new Date(dateText);

			for(i in jsonDates.dates) {
				var date = new Date(jsonDates.dates[i].date);

		  		if((activeDate.getDate()==date.getDate()) && (activeDate.getMonth()==date.getMonth())) {
					setter = i;
				}


			}
                        location.href=jsonDates.dates[setter].url;
    	}
    });
}

/*--------------------------date_picker_invoke.js end--------------------------------*/


/*--------------------------follow_us.js end--------------------------------*/



$(document).ready(function(){


     $('.email-bilten').addClass("inactive");

     var text = $('.email-bilten').val();

     $('.email-bilten').focus(function(){

               $(this).addClass("focused");
               $(this).removeClass("inactive");
               $(this).removeClass("active");
               $(this).css("color","#000000");
               if($(this).val() == text ) {
                           $(this).val("");
                   }
         });
         $('.email-bilten').blur(function(){
                                $(this).removeClass("focused");
                                 if($(this).val() == "") {
                                         $(this).val(text);
                                         $(this).addClass("inactive");
                                        $(this).css("color","gray");
                                 } else {
                                        $(this).addClass("active");
                                };
                        });
          $('.email-blog').addClass("inactive");

     var text = $('.email-blog').val();

     $('.email-blog').focus(function(){

               $(this).addClass("focused");
               $(this).removeClass("inactive");
               $(this).removeClass("active");
               $(this).css("color","#000000");
               if($(this).val() == text ) {
                           $(this).val("");
                   }


         });
         $('.email-blog').blur(function(){
                                $(this).removeClass("focused");
                                 if($(this).val() == "") {
                                         $(this).val(text);
                                         $(this).addClass("inactive");
                                        $(this).css("color","gray");
                                 } else {
                                        $(this).addClass("active");
                                };
                        });

});


/*--------------------------follow_us.js end--------------------------------*/