$(document).ready(function () {
	dynamicWidth();
	dynamicHeight();
});
$(window).resize(function () {
	dynamicWidth();
});


function dynamicWidth() {
    var browserWidth = getBrowserWidth();
	
	
    if (browserWidth <= 1100){
        addEmbeddedStyle('#headerBackground #icon { float:left; }');
        addEmbeddedStyle('#headerBackground #logo { float:none; }');
    } else {
		addEmbeddedStyle('#headerBackground #icon { float:right; }');
        addEmbeddedStyle('#headerBackground #logo { float:left; }');
	}
}

function dynamicHeight() {
	var browserHeight = getBrowserHeight();
	
	if (browserHeight < 740){
        addEmbeddedStyle('#wrapper { margin-top:42px; }');
    } else {
		addEmbeddedStyle('#wrapper { margin-top:100px; }');
    }
	
	/*
    if ((browserWidth >= 750) && (browserWidth <= 950)){
        changeLayout("wide");
    }
	*/
}


function getBrowserWidth() {
    if (window.innerWidth){
        return window.innerWidth;}  
    else if (document.documentElement && document.documentElement.clientWidth != 0){
        return document.documentElement.clientWidth;    }
    else if (document.body){return document.body.clientWidth;}      
        return 0;
}
function getBrowserHeight() {
    if (window.innerHeight){
        return window.innerHeight;}  
    else if (document.documentElement && document.documentElement.clientHeight != 0){
        return document.documentElement.clientHeight;    }
    else if (document.body){return document.body.clientHeight;}      
        return 0;
}


function addEmbeddedStyle(style_str) {
	var head = document.getElementsByTagName('head')[0],
	    style = document.createElement('style'),
	    rules = document.createTextNode(style_str);

	style.type = 'text/css';
	
	if(style.styleSheet)
	    style.styleSheet.cssText = rules.nodeValue;
	else style.appendChild(rules);
	
	head.appendChild(style);
}

/*
function changeLayout(description){
   var i, a;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++){
	   if(a.getAttribute("title") == description){a.disabled = false;}
	   else if(a.getAttribute("title") != "default"){a.disabled = true;}
   }
}
*/
