function loadFlashObject(objectName){
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="' + objectName + '"');
	document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"');
	document.write('WIDTH="' + fileWidth + '" HEIGHT="' + fileHeight + '">');
	document.write('<PARAM NAME=movie VALUE="' + fileURL + '">');
	document.write('<PARAM NAME=quality VALUE=high>');
	document.write('<PARAM NAME=bgcolor VALUE=' + bgcolor + '>');
	document.write('<PARAM NAME=wmode VALUE=transparent>'); 
	document.write('<PARAM NAME=allowScriptAccess VALUE=sameDomain>'); 
	document.write('<PARAM NAME=flashvars VALUE="' + flashVars + '">');
	document.write('<EMBED FLASHVARS="' + flashVars + '"');
	document.write('src="' + fileURL + '" quality="high" bgcolor=' + bgcolor + ' WIDTH="' + fileWidth + '" HEIGHT="' + fileHeight + '"');
	document.write('name="' + objectName + '" ALIGN="" TYPE="application/x-shockwave-flash" wmode="transparent" allowScriptAccess="sameDomain"');
	document.write('PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
	document.write('</EMBED>');
	document.write('</OBJECT>');
}	


function fullscreenHide() {
	var fullscreenLayerObj = document.getElementById('fullscreenLayer');
	
	fullscreenLayerObj.style.display = 'none';	
}

function fullscreenShow() {
	var fullscreenLayerObj = document.getElementById('fullscreenLayer');

	//Get page height
	if (window.innerHeight) {// Firefox
		pageHeight = window.innerHeight;
    if (window.scrollMaxY > 0){
      pageHeight += window.scrollMaxY;		
    }
	} 
	else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		pageHeight = document.body.scrollHeight;
	} 
	else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		pageHeight = document.documentElement.clientHeight;
  }
	 
	//set fullscreenLayer and display
	fullscreenLayerObj.style.height = pageHeight + 'px';
	fullscreenLayerObj.style.display = 'block';
}

function imagePopup(sourceObj) {
	var contentObj = document.getElementById('fullscreenContent');	
	var popupObj = document.getElementById('imagePopup');
	var popupImgObj = document.getElementById('imagePopup_img');
	var source = sourceObj.src;
	
	var topMargin = 100;

	//find page offset if user has scrolled download
	contentObj.style.top = '0px';
	if (window.pageYOffset) //Firefox
		contentObj.style.top = (window.pageYOffset + topMargin) + 'px';
	else if (document.body.scrollTop)
		contentObj.style.top = (document.body.scrollTop + topMargin) + 'px';
	else if (document.documentElement.scrollTop)
		contentObj.style.top = (document.documentElement.scrollTop + topMargin) + 'px';
	else
		contentObj.style.top = topMargin + 'px';

	//cut '_sm.jpg' from image name
	source = source.slice(0, source.indexOf('_sm.jpg'));
    source = source + '.jpg';
    
	//set image source
	popupImgObj.src = source;
	
	popupObj.style.display = 'block';
	fullscreenShow();	
}

function imagePopupVertical(sourceObj) {
	var contentObj = document.getElementById('fullscreenContent');	
	var popupObj = document.getElementById('imagePopupVertical');
	var popupImgObj = document.getElementById('imagePopupVertical_img');
	var source = sourceObj.src;
	
	var topMargin = 20;

	//find page offset if user has scrolled download
	contentObj.style.top = '0px';
	if (window.pageYOffset) //Firefox
		contentObj.style.top = (window.pageYOffset + topMargin) + 'px';
	else if (document.body.scrollTop)
		contentObj.style.top = (document.body.scrollTop + topMargin) + 'px';
	else if (document.documentElement.scrollTop)
		contentObj.style.top = (document.documentElement.scrollTop + topMargin) + 'px';
	else
		contentObj.style.top = topMargin + 'px';

	//cut '_sm.jpg' from image name
	source = source.slice(0, source.indexOf('_sm.jpg'));
    source = source + '.jpg';
    
	//set image source
	popupImgObj.src = source;
	
	popupObj.style.display = 'block';
	fullscreenShow();	
}

function imagePopdown() {
	var popupObj = document.getElementById('imagePopup');
	var popupImgObj = document.getElementById('imagePopup_img');
	var popupVerticalObj = document.getElementById('imagePopupVertical');
	var popupImgVerticalObj = document.getElementById('imagePopupVertical_img');

	//load blank image source
	popupImgObj.src = 'http://www.chantinlun.com/portfolio/images/content/blankDot.gif';
	popupImgVerticalObj.src = 'http://www.chantinlun.com/portfolio/images/content/blankDot.gif';
	
	popupObj.style.display = 'none';
	popupVerticalObj.style.display = 'none';
	fullscreenHide();	
}
