/* ---------- set general page layout according to browser ---------- */
function setLayoutForBrowser() {
	if (navigator.appName == 'Microsoft Internet Explorer')

	var browser = navigator.appName;
	var browserVersion = navigator.appVersion;
	document.write(browser);
	document.write('<br />');
	document.write(browserVersion);
}


/* ---------- fade in / fade out effect ---------- */
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;
	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

/* ---------- change the opacity of an element for different browsers ---------- */
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

/* ---------- set styles for main navigation bar according to current page ---------- */


function mainNavStyles() {
	var index = /index/;
	var company = /company-profile/;
	var history = /history/;
	var clients = /clients/;
	var partners = /partners/;
	var careers = /careers/;
	var services = /services/;
	var packages = /packages/;
	var news = /news/;
	var archive = /archive/;
	var testimonials = /testimonials/;
	var facilities = /facilities/;
	var services = /services/;
	var galleries = /galleries/;
	var faqs = /faqs/;
	var contact = /contact/;
	var URL = location.pathname;
	if(URL.search(index) != -1) {
		document.getElementById('linkHome').setAttribute('class', 'currentPage');
	}
	if(URL.search(company) != -1 || URL.search(history) != -1 || URL.search(clients) != -1 || URL.search(partners) != -1 || URL.search(careers) != -1) {
		document.getElementById('linkAbout').setAttribute('class', 'currentPage');
	}
	if(URL.search(services) != -1 || URL.search(packages) != -1) {
		document.getElementById('linkServices').setAttribute('class', 'currentPage');
    }

    if (URL.search(packages) != -1 || URL.search(news) != -1) {
        document.getElementById('linkPackages').setAttribute('class', 'currentPage');
    }
	
	if(URL.search(news) != -1 || URL.search(archive) != -1) {
		document.getElementById('linkNews').setAttribute('class', 'currentPage');
	}
	if(URL.search(testimonials) != -1) {
		document.getElementById('linkTestimonials').setAttribute('class', 'currentPage');
	}
	if(URL.search(facilities) != -1) {
		document.getElementById('linkFacilities').setAttribute('class', 'currentPage');
	}
	if(URL.search(services) != -1) {
		document.getElementById('linkServices').setAttribute('class', 'currentPage');
    }
   
	if(URL.search(galleries) != -1) {
		document.getElementById('linkGalleries').setAttribute('class', 'currentPage');
	}
	if(URL.search(faqs) != -1) {
		document.getElementById('linkFAQs').setAttribute('class', 'currentPage');
	}
	if(URL.search(contact) != -1) {
		document.getElementById('linkContact').setAttribute('class', 'currentPage');
	}
}

/* ---------- set background for "father & son" image ---------- */
function fatherSonImage() {
	var searchIndex = /index.html/;
	var URL = location.pathname;
	var matchIndex = URL.search(searchIndex);
	if(matchIndex == -1) {
		document.getElementById('fatherSon').style.backgroundImage='url(/assets/images/father-son-2.jpg)';
		document.getElementById('fatherSon').style.zIndex='2';
	}
}

/* ---------- reset image dimensions ----------
function imageThumb(imageSrc, imageAlt) {
	var img = new Image();
	img.src = imageSrc;
	imageWidth = img.width;
	imageHeight = img.height;
	if (imageWidth > imageHeight) {
	    thumbWidth = '120';
	    var a = 120 / imageWidth;
		thumbHeight =  a * imageHeight;
	} else {
		thumbHeight = '120';
		var b = 120 / imageHeight;
		thumbWidth = b * imageWidth;
	}
	document.write('<img src="'+imageSrc+'" alt="'+imageAlt+'" width="'+thumbWidth+'" height="'+thumbHeight+'" />');
}
 */

/* ---------- show or hide lightbox for viewing images in "Gallery" page ---------- */
function lightbox(imageSrc) {
	var windowWidth = getBrowserWindowSize();
	var leftPosition = (windowWidth.width / 2) - 350
	var leftPosition = leftPosition+'px';
	document.getElementById('lightbox').style.visibility='visible';
	document.getElementById('lightbox').style.left=leftPosition;
	document.getElementById('lightboxImage').src=imageSrc;
}
function getBrowserWindowSize()
{
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 {width:myWidth, height:myHeight};
}
