﻿function bodyHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

var LangSelectionHasBeenClicked = false;
var LangSelectionOpened = false;

document.onclick = function(){
	if(!LangSelectionHasBeenClicked){
		//document.getElementById('select-language-option-2').style.display = 'none';
		LangSelectionOpened = false;
	}
}

function openLanguageSelection() {
	if(!LangSelectionOpened){
		LangSelectionHasBeenClicked = true;
		LangSelectionOpened = true;
		//document.getElementById('select-language-option-2').style.display = 'block';
		setTimeout('LangSelectionHasBeenClicked=false', 100);
	}
	else{
		//document.getElementById('select-language-option-2').style.display = 'none';
		LangSelectionOpened = false;
	}
	
}

function checkEmailAddress(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   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 CloseMessageBox(){
	document.getElementById('message-box-wrapper').style.display = 'none';
	document.getElementById(currentMessageBoxImageID).style.display = 'none';
}
var currentMessageBoxImageID = false;
function OpenMessageBox(str, imageID){
	currentMessageBoxImageID = imageID;
	var image = document.getElementById(imageID);
	var messageBox = document.getElementById('message-box');
	var textSpan = document.getElementById('message-box-text');
	var wrapper = document.getElementById('message-box-wrapper');
	var website = document.getElementById('website-wrapper');
	image.style.display = 'block';
	wrapper.style.visibility = 'hidden';
	wrapper.style.display = 'block';
	messageBox.style.marginTop = (website.offsetHeight-messageBox.offsetHeight)/2 + 'px';
	wrapper.style.visibility = 'visible';
	//textSpan.innerHTML = str;
}
	


