﻿function features_init() {
	var obj = document.getElementById("translucency");
	obj.tid = "";
	obj.tmp_left=0; // ??
	obj.tmp_top=0;
	obj.tmp_width=920;
	obj.tmp_height=565;
	obj.current_top=0; // ??? ??
	obj.current_left=0;
	obj.current_width=10;
	obj.current_height=10;
	obj.diff_left = 0; // ??
	obj.diff_top = 0;
	obj.diff_width = 0;
	obj.diff_height = 0;
	obj.tmp_opacity_ie=10; // ???
	obj.tmp_opacity_ff=0.1;
	obj.cmn = 0;
}
function view_learnmore(va,e) {
	var obj = document.getElementById("translucency");
	var btype=navigator.userAgent;
	obj.cmn = va;
	
	if (document.documentElement.scrollTop == 0) {
		var tmpgallery_height = document.body.scrollTop + 60;
		obj.tmp_top = tmpgallery_height;
	} else {
		var tmpgallery_height = document.documentElement.scrollTop + 60;
		obj.tmp_top = tmpgallery_height;
	}
	obj.tmp_left = (document.body.clientWidth-920)/2;
	
	if (btype.indexOf("MSIE")!=-1) { // for IE
		obj.current_top = event.y;
		obj.current_left = event.x;
		document.getElementById("translucency").style.filter="alpha(opacity=50)";
		if (btype.indexOf("MSIE 5.5")!=-1) {
			document.getElementById("translucency").style.height=document.body.scrollHeight + "px";
		} else {
			document.getElementById("translucency").style.height=document.body.clientHeight + "px";
		}
		document.getElementById("translucency").style.display="block";
		document.getElementById("features_motion_layer").style.filter="alpha(opacity="+50+")";
	} else {
		obj.current_top = e.clientY;
		obj.current_left = e.clientX;
		document.getElementById("translucency").style.opacity=0.5;
		document.getElementById("translucency").style.height=document.body.clientHeight + "px";
		document.getElementById("translucency").style.display="block";
		document.getElementById("features_motion_layer").style.opacity=0.5;
	}
	document.getElementById('features_motion_layer').style.width = obj.current_width + "px";
	document.getElementById('features_motion_layer').style.height = obj.current_height + "px";
	document.getElementById('features_motion_layer').style.left = obj.current_left + "px";
	document.getElementById('features_motion_layer').style.top = obj.current_top + "px";
	document.getElementById('features_motion_layer').style.display="block";
	document.getElementById('features_layer'+obj.cmn).style.display="none";
	obj.diff_left = obj.tmp_left - obj.current_left;
	obj.diff_top = obj.tmp_top - obj.current_top;
	obj.diff_width = obj.tmp_width - obj.current_width;
	obj.diff_height = obj.tmp_height - obj.current_height;
	test2();
}
function test2() {
	var obj = document.getElementById("translucency");
	tid=setTimeout(test2,1);
	if(obj.current_top!=obj.tmp_top || obj.current_height!=obj.tmp_height || obj.current_left!=obj.tmp_left || obj.current_width!=obj.tmp_width) {
		// ?? ??
		if(Math.abs(obj.current_top - obj.tmp_top) < 21) {
			document.getElementById('features_motion_layer').style.top = obj.tmp_top + "px";
			obj.current_top = obj.tmp_top;
			obj.diff_top = 0;
		} else {
			obj.current_top = obj.current_top + Math.round(obj.diff_top/20);
			document.getElementById('features_motion_layer').style.top = obj.current_top + "px";
		}
		// ?? ??
		if(Math.abs(obj.current_height - obj.tmp_height) < 21) {
			document.getElementById('features_motion_layer').style.height = obj.tmp_height + "px";
			obj.current_height = obj.tmp_height;
			obj.diff_height = 0;
		} else {
			obj.current_height = obj.current_height + Math.round(obj.diff_height/20);
			document.getElementById('features_motion_layer').style.height = obj.current_height + "px";
		}
		// ?? ??
		if(Math.abs(obj.current_left - obj.tmp_left) < 21) {
			document.getElementById('features_motion_layer').style.left = obj.tmp_left + "px";
			obj.current_left = obj.tmp_left;
			obj.diff_left = 0;
		} else {
			obj.current_left = obj.current_left + Math.round(obj.diff_left/20);
			document.getElementById('features_motion_layer').style.left = obj.current_left + "px";
		}
		// ?? ??
		if(Math.abs(obj.current_width - obj.tmp_width) < 21) {
			document.getElementById('features_motion_layer').style.width = obj.tmp_width + "px";
			obj.current_width = obj.tmp_width;
			obj.diff_width = 0;
		} else {
			obj.current_width = obj.current_width + Math.round(obj.diff_width/20);
			document.getElementById('features_motion_layer').style.width = obj.current_width + "px";
		}
	} else {
		clearTimeout(tid);
		// translucency
		var btype=navigator.userAgent;
		if (btype.indexOf("MSIE")!=-1) { // for IE
			document.getElementById("features_motion_layer").style.filter="alpha(opacity=100)";
		} else {
			document.getElementById("features_motion_layer").style.opacity=1;
		}
		EchoDiv();
	}
}
function LayerClose() {
	// ???
	var obj = document.getElementById("translucency");
	document.getElementById('features_motion_layer').style.display='none';
	//document.getElementById('features_layer'+obj.cmn).style.display='none';
	document.getElementById('features_layer').style.display='none';
	document.getElementById('translucency').style.display='none';
	obj.tmp_left=0;
	obj.tmp_top=0;
	obj.tmp_width=920;
	obj.tmp_height=565;
	obj.current_top=0;
	obj.current_left=0;
	obj.current_width=10;
	obj.current_height=10;
}
function closeDemo() {
	var obj = document.getElementById("translucency");
	document.getElementById('features_motion_layer').style.display='none';
	//document.getElementById('features_layer'+obj.cmn).style.display='none';
	document.getElementById('features_layer').style.display='none';
	document.getElementById('translucency').style.display='none';
	obj.tmp_left=0;
	obj.tmp_top=0;
	obj.tmp_width=920;
	obj.tmp_height=565;
	obj.current_top=0;
	obj.current_left=0;
	obj.current_width=10;
	obj.current_height=10;
}
function EchoDiv() {
	var obj = document.getElementById("translucency");
	var tmp_code = "";
	document.getElementById('features_layer'+obj.cmn).style.left = obj.tmp_left + "px";
	document.getElementById('features_layer'+obj.cmn).style.top = obj.tmp_top + "px";
	document.getElementById('features_layer'+obj.cmn).style.display="block";
	document.getElementById('features_motion_layer').style.display="none";
}

function gallery_view() {
	var tabs = document.getElementById("visual_sum_tab");
	var btns = tabs.getElementsByTagName("a");
	var imgLayer = document.getElementById("visual_image");
	var visual_vr = document.getElementById("visual_vr");
	for (var i=0; i<btns.length; i++) {
		btns[i].onclick = function() {	
			var imgs = this.getAttribute("href");
			var img_type = imgs.substring(imgs.lastIndexOf(".")+1,imgs.lastIndexOf(".")+4);
			var chageImg = imgLayer.firstChild;
			if (img_type=="jpg" || img_type=="JPG" || img_type=="gif" || img_type=="GIF") {
				var chageImg = imgLayer.firstChild;
				visual_vr.style.display = "none";
				imgLayer.style.display = "block";
				if(chageImg.nodeType!=1) {
					chageImg = chageImg.nextSibling;
				}
				chageImg.setAttribute("src",imgs);
			} else {
				visual_vr.style.display = "block";
				imgLayer.style.display = "none";
				var obj = document.getElementById("visual_vr");
				var txt_tmp = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%">';
				txt_tmp = txt_tmp + '<param name="movie" value="'+imgs+'" />';
				txt_tmp = txt_tmp + '<param name="wmode" value="transparent" />';
				txt_tmp = txt_tmp + '<param name="allowScriptAccess" value="always" />';
				txt_tmp = txt_tmp + '<!--[if !IE]> <-->';
				txt_tmp = txt_tmp + '<object type="application/x-shockwave-flash" data="'+imgs+'" width="100%" height="100%">';
				txt_tmp = txt_tmp + '<param name="wmode" value="transparent" />';
				txt_tmp = txt_tmp + '<param name="allowScriptAccess" value="always" />';
				txt_tmp = txt_tmp + '</object>';
				txt_tmp = txt_tmp + '<!--> <![endif]-->';
				txt_tmp = txt_tmp + '</object>';
				obj.innerHTML=txt_tmp;
			}
			return false;
		}
	}
}
function color_view() {
	var tabs = document.getElementById("visual_sum_tab_color");
	var btns = tabs.getElementsByTagName("a");
	var imgLayer = document.getElementById("visual_image");
	var visual_vr = document.getElementById("visual_vr");
	for (var i=0; i<btns.length; i++) {
		btns[i].onclick = function() {	
			var imgs = this.getAttribute("href");
			var img_type = imgs.substring(imgs.lastIndexOf(".")+1,imgs.lastIndexOf(".")+4);
			var chageImg = imgLayer.firstChild;
			if (img_type=="jpg" || img_type=="JPG" || img_type=="gif" || img_type=="GIF") {
				var chageImg = imgLayer.firstChild;
				visual_vr.style.display = "none";
				imgLayer.style.display = "block";
				if(chageImg.nodeType!=1) {
					chageImg = chageImg.nextSibling;
				}
				chageImg.setAttribute("src",imgs);
			} else {
				visual_vr.style.display = "block";
				imgLayer.style.display = "none";
				var obj = document.getElementById("visual_vr");
				var txt_tmp = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%">';
				txt_tmp = txt_tmp + '<param name="movie" value="'+imgs+'" />';
				txt_tmp = txt_tmp + '<param name="wmode" value="transparent" />';
				txt_tmp = txt_tmp + '<param name="allowScriptAccess" value="always" />';
				txt_tmp = txt_tmp + '<!--[if !IE]> <-->';
				txt_tmp = txt_tmp + '<object type="application/x-shockwave-flash" data="'+imgs+'" width="100%" height="100%">';
				txt_tmp = txt_tmp + '<param name="wmode" value="transparent" />';
				txt_tmp = txt_tmp + '<param name="allowScriptAccess" value="always" />';
				txt_tmp = txt_tmp + '</object>';
				txt_tmp = txt_tmp + '<!--> <![endif]-->';
				txt_tmp = txt_tmp + '</object>';
				obj.innerHTML=txt_tmp;
			}
			return false;
		}
	}
}
function gallery_close() {
	var imgLayer = document.getElementById("visual_image");
	var visual_vr = document.getElementById("visual_vr");
	visual_vr.style.display = "block";
	imgLayer.style.display = "none";	
}

//function view_learnmore_digitas(loaderSwf, templateSwf, flashID, first_load, xmlDir, xmlName, e) {
function view_learnmore_digitas(loaderSwf, flashID, first_load, xmlDir, xmlName, e) {
	var obj = document.getElementById("translucency");
	var btype=navigator.userAgent;
	
	if (document.documentElement.scrollTop == 0) {
		var tmpgallery_height = document.body.scrollTop + 60;
		obj.tmp_top = tmpgallery_height;
	} else {
		var tmpgallery_height = document.documentElement.scrollTop + 60;
		obj.tmp_top = tmpgallery_height;
	}
	obj.tmp_left = (document.body.clientWidth-920)/2;
	
	if (btype.indexOf("MSIE")!=-1) { // for IE
		obj.current_top = event.y;
		obj.current_left = event.x;
		document.getElementById("translucency").style.filter="alpha(opacity=50)";
		if (btype.indexOf("MSIE 5.5")!=-1) {
			document.getElementById("translucency").style.height=document.body.scrollHeight + "px";
		} else {
			document.getElementById("translucency").style.height=document.body.clientHeight + "px";
		}
		document.getElementById("translucency").style.display="block";
		document.getElementById("features_motion_layer").style.filter="alpha(opacity="+50+")";
	} else {
		obj.current_top = e.clientY;
		obj.current_left = e.clientX;
		document.getElementById("translucency").style.opacity=0.5;
		document.getElementById("translucency").style.height=document.body.clientHeight + "px";
		document.getElementById("translucency").style.display="block";		
		document.getElementById("features_motion_layer").style.opacity=0.5;
	}
	document.getElementById('features_motion_layer').style.width = obj.current_width + "px";
	document.getElementById('features_motion_layer').style.height = obj.current_height + "px";
	document.getElementById('features_motion_layer').style.left = obj.current_left + "px";
	document.getElementById('features_motion_layer').style.top = obj.current_top + "px";
	document.getElementById('features_motion_layer').style.display="block";
	document.getElementById('features_layer').style.display="none";
	obj.diff_left = obj.tmp_left - obj.current_left;
	obj.diff_top = obj.tmp_top - obj.current_top;
	obj.diff_width = obj.tmp_width - obj.current_width;
	obj.diff_height = obj.tmp_height - obj.current_height;

	var obj = document.getElementById("features_layer");
	var txt_tmp = '<object id="'+flashID+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="920" height="565">';
		txt_tmp = txt_tmp + '<param name="movie" value="'+loaderSwf+'" />';
		txt_tmp = txt_tmp + '<param name="wmode" value="transparent" />';
		//txt_tmp = txt_tmp + '<param name="flashvars" value="main_file='+templateSwf+'" />';
		txt_tmp = txt_tmp + '<param name="flashvars" value="first_load='+first_load+'&amp;config_file='+xmlName+'&amp;xml_dir='+xmlDir+'" />';
		txt_tmp = txt_tmp + '<param name="allowfullscreen" value="true" />';
		txt_tmp = txt_tmp + '<!--[if !IE]> <-->';
		txt_tmp = txt_tmp + '<object id="'+flashID+'" type="application/x-shockwave-flash" data="'+loaderSwf+'" width="920" height="565">';
		txt_tmp = txt_tmp + '<param name="wmode" value="transparent" />';
		//txt_tmp = txt_tmp + '<param name="flashvars" value="main_file='+templateSwf+'" />';
		txt_tmp = txt_tmp + '<param name="flashvars" value="first_load='+first_load+'&amp;config_file='+xmlName+'&amp;xml_dir='+xmlDir+'" />';
		txt_tmp = txt_tmp + '<param name="allowfullscreen" value="true" />';
		txt_tmp = txt_tmp + '</object>';
		txt_tmp = txt_tmp + '<!--> <![endif]-->';
		txt_tmp = txt_tmp + '</object>';
		obj.innerHTML=txt_tmp;
		test3();
		
		//EchoDiv2();
}
function test3() {
	var obj = document.getElementById("translucency");
	tid=setTimeout(test3,1);
	if(obj.current_top!=obj.tmp_top || obj.current_height!=obj.tmp_height || obj.current_left!=obj.tmp_left || obj.current_width!=obj.tmp_width) {
		// ?? ??
		if(Math.abs(obj.current_top - obj.tmp_top) < 21) {
			document.getElementById('features_motion_layer').style.top = obj.tmp_top + "px";
			obj.current_top = obj.tmp_top;
			obj.diff_top = 0;
		} else {
			obj.current_top = obj.current_top + Math.round(obj.diff_top/20);
			document.getElementById('features_motion_layer').style.top = obj.current_top + "px";
		}
		// ?? ??
		if(Math.abs(obj.current_height - obj.tmp_height) < 21) {
			document.getElementById('features_motion_layer').style.height = obj.tmp_height + "px";
			obj.current_height = obj.tmp_height;
			obj.diff_height = 0;
		} else {
			obj.current_height = obj.current_height + Math.round(obj.diff_height/20);
			document.getElementById('features_motion_layer').style.height = obj.current_height + "px";
		}
		// ?? ??
		if(Math.abs(obj.current_left - obj.tmp_left) < 21) {
			document.getElementById('features_motion_layer').style.left = obj.tmp_left + "px";
			obj.current_left = obj.tmp_left;
			obj.diff_left = 0;
		} else {
			obj.current_left = obj.current_left + Math.round(obj.diff_left/20);
			document.getElementById('features_motion_layer').style.left = obj.current_left + "px";
		}
		// ?? ??
		if(Math.abs(obj.current_width - obj.tmp_width) < 21) {
			document.getElementById('features_motion_layer').style.width = obj.tmp_width + "px";
			obj.current_width = obj.tmp_width;
			obj.diff_width = 0;
		} else {
			obj.current_width = obj.current_width + Math.round(obj.diff_width/20);
			document.getElementById('features_motion_layer').style.width = obj.current_width + "px";
		}
	} else {
		clearTimeout(tid);
		// translucency
		var btype=navigator.userAgent;
		if (btype.indexOf("MSIE")!=-1) { // for IE
			document.getElementById("features_motion_layer").style.filter="alpha(opacity=100)";
		} else {
			document.getElementById("features_motion_layer").style.opacity=1;
		}
		EchoDiv2();
	}
}
function EchoDiv2() {
	var obj = document.getElementById("translucency");
	var tmp_code = "";
	document.getElementById('features_layer').style.left = obj.tmp_left + "px";
	document.getElementById('features_layer').style.top = obj.tmp_top + "px";
	document.getElementById('features_layer').style.display="block";
	document.getElementById('features_motion_layer').style.display="none";	
	
}
