/*
____________________________________
¤¤¤ Common JS: Template byBrick™ ¤¤¤
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*/

 // jQuery 
 /*$(document).ready(function(){
 
 
	
 }); */
 
 function printContactLink() {
	var lnkContactMail = '';
	lnkContactMail += 'felanmalan';
	lnkContactMail += '@';
	lnkContactMail += 'loudden.se';
	var contactContainer = document.getElementById('contactLink');
	if(contactContainer){
		contactContainer.innerHTML = '<a href="mailto:' + lnkContactMail + '">' + lnkContactMail + '</a>';
	}
}

 
 function changePageHeight(){
		
	var objBottom = document.getElementById("bottom");
	if(objBottom){
		var defaultHeight = 50;
		var iBottomHeight = document.body.offsetHeight - objBottom.offsetTop - 20;	//document.getElementById("bottom").style.paddingTop - document.getElementById("bottom").style.paddingBottom;
		if (iBottomHeight > defaultHeight) {
			objBottom.style.height = iBottomHeight + 'px';
		}
		else {
			objBottom.style.height = defaultHeight;
		}
	}
	
	/*alert(
		'body.offsetHeight: ' + document.body.offsetHeight + '\n' +
		'page.offsetHeight: ' + document.getElementById("page").offsetHeight + '\n' +
		'bottom.offsetHeight: ' + document.getElementById("bottom").offsetHeight + '\n' +
		'bottom.offsetTop: ' + document.getElementById("bottom").offsetTop + '\n' +
		'bottom.height: ' + document.getElementById("bottom").style.height + '\n' +
		'bottom.paddingTop: ' + document.getElementById("bottom").style.paddingTop + '\n' +
		'bottom.paddingBottom: ' + document.getElementById("bottom").style.paddingBottom + '\n' +
		''
	);*/
	
	
}
 
 
 var prevThemePic = -1;
 function ThemePic() {
	/* IMAGES IS LOADED ON defatul.htm */
	/*var aThemes = new Array(2);
            aThemes[0]= 'images/pic_page_start_theme1a.jpg';
            aThemes[1]= 'images/pic_page_start_theme1a.jpg';*/
    if(prevThemePic == -1){
		RndPic = Math.floor(Math.random()*aThemes.length);
	}
	else{
		RndPic = prevThemePic + 1;
		if(RndPic >= aThemes.length) { RndPic = 0;}
	}
	
	var objThemePicHolder = document.getElementById("themePicHolder")
	if (objThemePicHolder){
		objThemePicHolder.style.backgroundImage = "url(" + aThemes[RndPic] + ")";
	}
	prevThemePic = RndPic;
	
	LoadThemePic();
}

function LoadThemePic() {
	setTimeout('ThemePic()', 5000);
}


function showById(objId){
	var obj = document.getElementById(objId);
	if(obj){
		obj.style.display = "block";
	}
}


function hideById(objId){
	var obj = document.getElementById(objId);
	if(obj){
		obj.style.display = "none";
	}
}

function toggleShowHideById(objId){
	var obj = document.getElementById(objId);
	if(obj){
		if(obj.style.display == "block"){
			obj.style.display = "none";
		}
		else {
			obj.style.display = "block";
		}
	}
}


function listProperties(obj, strFind){
  var i = 0;
  var msg = "";
  for(itm in obj){
    if(i > 50){
      alert(msg);
      i = 0;
      msg = "";
    }	
		if(strFind.length > 0){
			if(itm.toLowerCase().indexOf(strFind.toLowerCase()) > -1){	//search for lower case part of item name
				msg += itm + "\n";	
				i++;
			}
		}
		else {
			msg += itm + "\n";	
			i++;
		}

  }
  alert(msg);
}
