//
//  ------------------------------------------
//  Designed and Developed by J.Kiem Vu
//
//  mistervu.com
//  j.kiem.vu@gmail.com
//  ------------------------------------------
//

//mouse events

$(function() {
	$('div#wieden').mouseenter(setBackgroundImage_wk).mouseleave(setBackgroundDefault);
	$('div#ringling').mouseenter(setBackgroundImage_dc).mouseleave(setBackgroundDefault);
	$('div#schooling_content').mouseenter(setBackgroundImage_rcad).mouseleave(setBackgroundDefault);
	$(window).resize(setBackgroundImage);
});

//set background fn

function setBackgroundImage_wk() {
	var documentSize = getDocumentSize()
	var screenWidth = documentSize[0];
	var screenHeight = documentSize[1];

	var backgroundImage = 'bg-3000';
	if (screenWidth <= 1024) {
		backgroundImage = 'bg-1024';
	} 
	else if (screenWidth <= 1440) {
		backgroundImage = 'bg-1440';
	}
	else if (screenWidth <= 1680) {
		backgroundImage = 'bg-1680';
	}
	else if (screenWidth <= 1920) {
		backgroundImage = 'bg-1920';
	}
	
	$('html').css('backgroundImage', 'url(wk/images/' + backgroundImage + '.jpg)');
}

function setBackgroundImage_dc() {
	var documentSize = getDocumentSize()
	var screenWidth = documentSize[0];
	var screenHeight = documentSize[1];

	var backgroundImage = 'bg-3000';
	if (screenWidth <= 1024) {
		backgroundImage = 'bg-1024';
	} 
	else if (screenWidth <= 1440) {
		backgroundImage = 'bg-1440';
	}
	else if (screenWidth <= 1680) {
		backgroundImage = 'bg-1680';
	}
	else if (screenWidth <= 1920) {
		backgroundImage = 'bg-1920';
	}
	
	$('html').css('backgroundImage', 'url(dc/images/' + backgroundImage + '.jpg)');
}

function setBackgroundImage_rcad() {
	var documentSize = getDocumentSize()
	var screenWidth = documentSize[0];
	var screenHeight = documentSize[1];

	var backgroundImage = 'bg-3000';
	if (screenWidth <= 1024) {
		backgroundImage = 'bg-1024';
	} 
	else if (screenWidth <= 1440) {
		backgroundImage = 'bg-1440';
	}
	else if (screenWidth <= 1680) {
		backgroundImage = 'bg-1680';
	}
	else if (screenWidth <= 1920) {
		backgroundImage = 'bg-1920';
	}
	
	$('html').css('backgroundImage', 'url(rcad/images/' + backgroundImage + '.jpg)');
}

function getDocumentSize() {
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = [w,h];
	return arrayPageSize;
}

function setBackgroundDefault() {
	$('html').css('backgroundImage', 'url(images/b_grain.jpg)');
}