$(window).resize(function(){
	if(jQuery.browser.mobile == false){	
		handleBrowserSize();
	}
});

$(document).ready(function() {
	if(jQuery.browser.mobile == false){	
		handleBrowserSize();
	}
});

function handleBrowserSize(){
	/*	margin left(10)resp. margin right(10) -> 20px	*/
	var initAllWidth = 987;
	var initMainWidth = 640;
	var initAsideWidth = 287;
	
	var win = $(window);
	var allContent = $("#allContentWraper");
	var mainContent = $("#mainContent");
	var aside = $("#asideContent");
	var asideWraper = $("#asideWraper");
	var asideWraper1 = $("#aside1");
	var asideWraper2 = $("#aside2");
	var lang = $("#langSwitcher");
	var nav = $("#navigation");
	var addThis = $("#addThisWraper");
	var tagCloud = $("#tagCloud");
	
	var blogItem = $(".blogItem");
	var blogImage = $(".blogEntryLinkImage");
	var besideImage = $(".besideImage");
	var blogTitle = $(".ellipsisPseudoWraper");
	var blogDate = $(".besideImage .dateTime");
	var blogTags = $(".catTagsWraper");
	
	var blogSingleImage = $(".imgLandscape, .imgPortrait");
	var blogSingleBackButton = $(".blogEntryBackButton");
	
	var albumTitles = $("#albumsWraper .albumTitles");
	var albumNumber = $("#albumsWraper .nr");
	var albumTime = $("#albumsWraper .length");
	
	var galeryThumb = $("#galleryPicsWraper .gallerySurroundItem");
	
	var aboutImage = $("#aboutWraper img");
	var aboutImageWraper = $("#aboutWraper .fadeImgWraper");
	var aboutImageAfter = $("#aboutWraper p");
	
	var storeSearchItem = $("#storesWraper .appleItem");
	
	var winWidth = win.width();

	if(winWidth>=987){
		aside.width(initAsideWidth);
		aside.css({"float":"left"});
		mainContent.css({"padding-left":"20px", "padding-right":"0","float":"right", "clear":"none", "margin-top":"67px"});
		$("#mainContent > h1").css({"margin":"0 0 12px 0"});
		
		asideWraper.show();
		tagCloud.show();
		
		blogTags.css({"bottom":"16px", "top":"auto","left":"133px", "right":"100px", "display":"block"});	
		besideImage.css({"float":"left","clear":"none", "margin-right":"70px", "width":"340px", "height":"100px"});
		blogItem.css({"height":"100px", "float":"none"});
		blogTitle.css({"width":"320px", "overflow":"visible", "height":"auto", "margin-top":"0px"});
		blogImage.css({"width":"100px","height":"100px","float":"left"});
		$(".ellipsisPseudoWraper").ThreeDots({ max_rows:3 });
		
		blogSingleImage.css({"clear":"none", "float":"right"});
		albumTitles.css({"margin-left":"12px", "clear":"none"});
		albumTime.show();
		galeryThumb.css({"margin": "11px"});
		aboutImageWraper.css({"clear":"none", "float":"right", "margin":"0 0 15px 15px"});
		aboutImageAfter.css({"clear":"none"});
		blogSingleBackButton.css({"top":"15px", "left":"110px"});

	} else if(winWidth<987 && winWidth>=905){
		aside.width(initAsideWidth -(initAllWidth-winWidth));
		aside.css({"float":"left"});
		mainContent.css({"padding-left":"20px", "padding-right":"0","float":"right", "clear":"none", "margin-top":"67px"});
		$("#mainContent > h1").css({"margin":"0 0 12px 0"});
		
		asideWraper.show();
		tagCloud.show();
		
		blogTags.css({"bottom":"16px", "top":"auto","left":"133px", "right":"100px", "display":"block"});	
		besideImage.css({"float":"left","clear":"none", "margin-right":"70px", "width":"340px", "height":"100px"});
		blogItem.css({"height":"100px", "float":"none"});
		blogTitle.css({"width":"320px", "overflow":"visible", "height":"auto", "margin-top":"0px"});
		blogImage.css({"width":"100px","height":"100px","float":"left"});
		$(".ellipsisPseudoWraper").ThreeDots({ max_rows:3 });
		
		blogSingleImage.css({"clear":"none", "float":"right"});
		albumTitles.css({"margin-left":"12px", "clear":"none"});
		albumTime.show();
		galeryThumb.css({"margin": "11px"});
		aboutImageWraper.css({"clear":"none", "float":"right", "margin":"0 0 15px 15px"});
		aboutImageAfter.css({"clear":"none"});
		blogSingleBackButton.css({"top":"15px", "left":"110px"});

	} else if(winWidth<905 && winWidth>=885) {
		aside.width(initAsideWidth-82);
		aside.css({"float":"left"});
		mainContent.css({"padding-left":"10px", "padding-right":"0","float":"right", "clear":"none", "margin-top":"67px"});
		$("#mainContent > h1").css({"margin":"0 0 12px 0"});
		
		asideWraper.show();
		tagCloud.show();
		
		blogTags.css({"bottom":"16px", "top":"auto","left":"133px", "right":"100px", "display":"block"});	
		besideImage.css({"float":"left","clear":"none", "margin-right":"70px", "width":"340px", "height":"100px"});
		blogItem.css({"height":"100px", "float":"none"});
		blogTitle.css({"width":"320px", "overflow":"visible", "height":"auto", "margin-top":"0px"});
		blogImage.css({"width":"100px","height":"100px","float":"left"});
		$(".ellipsisPseudoWraper").ThreeDots({ max_rows:3 });
		
		blogSingleImage.css({"clear":"none", "float":"right"});
		albumTitles.css({"margin-left":"12px", "clear":"none"});
		albumTime.show();
		galeryThumb.css({"margin": "11px"});
		aboutImageWraper.css({"clear":"none", "float":"right", "margin":"0 0 15px 15px"});
		aboutImageAfter.css({"clear":"none"});
		blogSingleBackButton.css({"top":"15px", "left":"110px"});

	} else if(winWidth<885 && winWidth>=870) {
		aside.width(initAsideWidth-82);
		aside.css({"float":"left"});
		mainContent.css({"padding-left":"0", "padding-right":"0","float":"right", "clear":"none", "margin-top":"67px"});
		$("#mainContent > h1").css({"margin":"0 0 12px 0"});
		
		asideWraper.show();
		tagCloud.show();
		
		blogTags.css({"bottom":"16px", "top":"auto","left":"133px", "right":"100px", "display":"block"});	
		besideImage.css({"float":"left","clear":"none", "margin-right":"70px", "width":"340px", "height":"100px"});
		blogItem.css({"height":"100px", "float":"none"});
		blogTitle.css({"width":"320px", "overflow":"visible", "height":"auto", "margin-top":"0px"});
		blogImage.css({"width":"100px","height":"100px","float":"left"});
		$(".ellipsisPseudoWraper").ThreeDots({ max_rows:3 });
		
		blogSingleImage.css({"clear":"none", "float":"right"});
		albumTitles.css({"margin-left":"12px", "clear":"none"});
		albumTime.show();
		galeryThumb.css({"margin": "11px"});
		aboutImageWraper.css({"clear":"none", "float":"right", "margin":"0 0 15px 15px"});
		aboutImageAfter.css({"clear":"none"});
		blogSingleBackButton.css({"top":"15px", "left":"110px"});
		
	}  else if(winWidth<870 && winWidth>=640){
		console.log("in range");
		aside.width(initAsideWidth);
		aside.css({"margin":"20px auto 0 auto", "float":"none"});
		mainContent.css({"padding-left":"0", "padding-right":"0","float":"none", "clear":"both", "margin-top":"0"});
		$("#mainContent > h1").css({"margin":"0 0 0 0"});
		
		asideWraper.hide();
		tagCloud.hide();
		
		
		
		
		
		
		blogTags.css({"bottom":"16px", "top":"auto","left":"133px", "right":"100px", "display":"block"});	
		besideImage.css({"float":"left","clear":"none", "margin-right":"70px", "width":"340px", "height":"100px"});
		blogItem.css({"height":"100px", "float":"none"});
		blogTitle.css({"width":"320px", "overflow":"visible", "height":"auto", "margin-top":"0px"});
		blogImage.css({"width":"100px","height":"100px","float":"left"});
		$(".ellipsisPseudoWraper").ThreeDots({ max_rows:3 });
		
		blogSingleImage.css({"clear":"none", "float":"right"});
		albumTitles.css({"margin-left":"12px", "clear":"none"});
		albumTime.show();
		galeryThumb.css({"margin": "11px"});
		aboutImageWraper.css({"clear":"none", "float":"right", "margin":"0 0 15px 15px"});
		aboutImageAfter.css({"clear":"none"});
		blogSingleBackButton.css({"top":"15px", "left":"110px"});
		
		
		
		
		
		
		
	} else if(winWidth<640 && winWidth>=400) {
		
		aside.width(initAsideWidth);
		aside.css({"margin":"20px auto 0 auto", "float":"none"});
		mainContent.css({"padding-left":"0", "padding-right":"0","float":"none", "clear":"both", "margin-top":"0"});
		$("#mainContent > h1").css({"margin":"0 0 0 0"});
		
		asideWraper.hide();
		tagCloud.hide();

		blogTags.css({"bottom":"auto", "top":"0px","left":"65px", "right":"100px", "display":"block"});	
		besideImage.css({"clear":"both", "margin-right":"0", "width":"100%", "height":"20px"});
		blogItem.css({"height":"80px", "float":"none"});
		blogTitle.css({"width":"100%", "overflow":"hidden", "height":"30px", "margin-top":"10px"});
		blogImage.css({"width":"40px","height":"40px"});
		$(".ellipsisPseudoWraper").ThreeDots({ max_rows:2 });
		blogSingleImage.css({"clear":"both", "float":"none"});
		albumTitles.css({"margin-left":"0", "clear":"both"});
		albumTime.hide();
		galeryThumb.css({"margin": "15px 20px"});
		aboutImageWraper.css({"clear":"both", "float":"none", "margin":"50px auto"});
		aboutImageAfter.css({"clear":"both"});
		blogSingleBackButton.css({"top":"15px", "left":"110px"});

	} else if(winWidth<400) {
		
		aside.width(initAsideWidth);
		aside.css({"margin":"20px auto 0 auto", "float":"none"});
		mainContent.css({"padding-left":"0", "padding-right":"0","float":"none", "clear":"both", "margin-top":"0"});
		$("#mainContent > h1").css({"margin":"0 0 0 0"});
		
		asideWraper.hide();
		tagCloud.hide();

		blogTags.css({"display":"none"});	
		besideImage.css({"clear":"both", "margin-right":"0", "width":"100%", "height":"20px"});
		blogItem.css({"height":"80px", "float":"none"});
		blogTitle.css({"width":"100%", "overflow":"hidden", "height":"30px", "margin-top":"10px"});
		blogImage.css({"width":"40px","height":"40px"});
		$(".ellipsisPseudoWraper").ThreeDots({ max_rows:2 });
		blogSingleImage.css({"clear":"both", "float":"none"});
		albumTitles.css({"margin-left":"0", "clear":"both"});
		albumTime.hide();
		galeryThumb.css({"margin": "15px 20px"});
		aboutImageWraper.css({"clear":"both", "float":"none", "margin":"50px auto"});
		aboutImageAfter.css({"clear":"both"});
		blogSingleBackButton.css({"top":"45px", "left":"20px"});
	}

	handleTitleHeight();
	$(".ellipsisPseudoWraper").ThreeDots({ max_rows:3 });
	$(".ellipsisPseudoWraper2").ThreeDots({ max_rows:2 });
	$(".ellipsisPseudoWraper3").ThreeDots({ max_rows:2 });

	

}


function handleTitleHeight(){

	if($(window).width()>=870){

		var mainPos = $(".pageWraper").offset();
		var mainTop = mainPos.top+1;
		$("#asideContent").css({"margin-top":mainTop+"px"});
	}
}


