window.customMiniLogin = true;
$(document).ready(function(){
	//$("head").prepend("<link href='http://fonts.googleapis.com/css?family=Dancing+Script:400,700' rel='stylesheet' type='text/css'>");
	$(".pnlLogo img").attr("src","/assets/shop_images/logo.png");
	if ($("body").hasClass("Default")) {
		$(".pnlNotis .hlkNotLink").each(function(){
			if ($(this).html().length > 0){
				$(this).wrap('<div class="hlkNotLinkWrap"/>');
			}
		});
	}
});

$(window).load(function() {
	stretchLastInside($(".pnlPageNavigation, .pnlTools"),$(".pnlPageheader"));
	if ($("body").hasClass("Default")) {
        lineUpObjectsInside($(".pnlNotis2, .pnlNotis3, .pnlNotis4, .pnlNotis5, .pnlNotis6, .pnlNotis7, .pnlNotis8, .pnlNotis9, .pnlNotis10, .pnlNotis11, .pnlNotis12, .pnlNotis13, .pnlNotis14, .pnlNotis15, .pnlNotis16, .pnlNotis17, .pnlNotis18, .pnlNotis19, .pnlNotis20"), $(".pnlMain"));
    }else if ($("body").hasClass("dept")){
		$(".minibildslayoutkol").each(function(){
			lineUpObjectsInside($(this).find(".minibildkoldiv"),$(this));
		});
	}
});
function stretchLastInside(objects,inside){
	var maxWidth = $(inside).outerWidth() - ($.browser.mozilla?1:0);
	var totWidth = 0;
	for (var i=0;i<objects.length-1;i++){
		totWidth += $(objects[i]).outerWidth(true);
	}
	$(objects[objects.length-1]).outerWidth(maxWidth - totWidth);
}
function fixLinesAndHeight(lineObjects,additionalClass){
	var height = 0;
	var captionHeight = 0;
	var textHeight = 0;
	var imgHeight = 0;
	var totMax = 0;
	for (var j = 0; j < lineObjects.length; j++) {
		if (lineObjects[j].find(".notCaption").height() > captionHeight) {
			captionHeight = lineObjects[j].find(".notCaption").height();
		}
		//if (lineObjects[j].find(".notText").height() > textHeight) {
			//textHeight = lineObjects[j].find(".notText").height();
		//}
		//if (lineObjects[j].find(".hlkNotPicture").height() > imgHeight) {
			//imgHeight = lineObjects[j].find(".hlkNotPicture").height();
		//}
		//if ((captionHeight + textHeight + imgHeight)>totMax){
			//totMax = captionHeight + textHeight + imgHeight;
		//}
	}
	for (var j = 0; j < lineObjects.length; j++) {
		lineObjects[j].find(".notCaption").height(captionHeight);
		//lineObjects[j].find(".notText").height(textHeight);
		//lineObjects[j].find(".hlkNotPicture").height(imgHeight);
		if (additionalClass){
			lineObjects[j].addClass(additionalClass);
		}
		if (j < (lineObjects.length - 1)){
			lineObjects[j].addClass("notisBorderRight");
		}
	}
	for (var j = 0; j < lineObjects.length; j++) {
		if (lineObjects[j].height() > height) {
			height = lineObjects[j].height();
		}
	}
	for (var j = 0; j < lineObjects.length; j++) {
		lineObjects[j].height(height);
	}
}
function lineUpObjectsInside(objects, inside) {
    var maxWidth = inside.width();
    var lineObjects = new Array();
    var currWidth = 0;
    $(objects).each(function() {
        if (($(this).outerWidth(true) + currWidth) > maxWidth) {
            fixLinesAndHeight(lineObjects,"notisBorderBottom");
            lineObjects = new Array();
            currWidth = 0;
        }
        currWidth += $(this).outerWidth(true);
        lineObjects[lineObjects.length] = $(this);
    });
	fixLinesAndHeight(lineObjects);
}
