
// flash Laod
function flashX(src, w, h, swfid) {
	swf_html = '';
	swf_html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + w + '" height="' + h + '" id="' + swfid + '">';
	swf_html += '<param name="allowScriptAccess" value="sameDomain">';
	swf_html += '<param name="movie" value="' + src + '">';
	swf_html += '<param name="quality" value="high">';
	swf_html += '<param name="bgcolor" value="#FFFFFF">';
	swf_html += '<PARAM NAME="wmode" VALUE="transparent">';
	swf_html += '<PARAM NAME="base" VALUE=".">';
	swf_html += '<embed base="." src="' + src + '" quality="high" bgcolor="#FFFFFF" width="' + w + '" height="' + h + '" name="' + swfid + '" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
	swf_html += '</object>';
	document.write(swf_html);
}

// flash Laod 2
function insertFlash(swf, width, height, bgcolor, id, flashvars)
{
	var strFlashTag = new String();

	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		strFlashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		strFlashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=version=8,0,0,0" ';
		strFlashTag += 'id="' + id + '" width="' + width + '" height="' + height + '">';
		strFlashTag += '<param name="movie" value="' + swf + '"/>';

		if(flashvars != null) {strFlashTag += '<param name="flashvars" value="' + flashvars + '"/>'};
		strFlashTag += '<param name="quality" value="best"/>';
		strFlashTag += '<param name="bgcolor" value="' + bgcolor + '"/>';
		strFlashTag += '<param name="menu" value="false"/>';
		strFlashTag += '<param name="salign" value="LT"/>';
		strFlashTag += '<param name="scale" value="noscale"/>';
		// strFlashTag += '<param name="wmode" value="transparent"/>';
		strFlashTag += '<param name="allowScriptAccess" value="sameDomain"/>';
		strFlashTag += '</object>';
	}
	else
	{
		strFlashTag += '<embed src="' + swf + '" ';
		strFlashTag += 'quality="best" ';
		strFlashTag += 'bgcolor="' + bgcolor + '" ';
		strFlashTag += 'width="' + width + '" ';
		strFlashTag += 'height="' + height + '" ';
		strFlashTag += 'menu="false" ';
		strFlashTag += 'scale="noscale" ';
		strFlashTag += 'id="' + id + '" ';
		strFlashTag += 'salign="LT" ';
		//strFlashTag += 'wmode="transparent" ';
		strFlashTag += 'allowScriptAccess="sameDomain" ';
		if(flashvars != null) {strFlashTag += 'flashvars="' + flashvars + '" '};
		strFlashTag += 'type="application/x-shockwave-flash" ';
		strFlashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
		strFlashTag += '</embed>';
	}

	document.write(strFlashTag);
}


function popMSG(msg){
	var ms = msg;
	alert(ms);
}
// popup
function popupOpen(url,w,h,type){
	window.open(url ,  "openWin", "width="+w+",height="+h+",top=30,left=100,resizable=no,scrollbars="+type) ;
}

/* 파일 업로드 */
function PopUpFileUpload(tbxName, folderName, hdnName) 
{ 
	window.open ('/fileUpDown/fileUpload_1.asp?tbx='+tbxName+'&folderName='+folderName+"&hdn="+hdnName,'fileUpload','width=370, height=235, scrollbars=0');
}

/* 파일 업로드 후 지정 textbox에 파일명 삽입 */
function AddOption(tbx, text, hdn, fileSize)
{
	var form = document.frmWrite;

	//select box에 파일명 추가
	//form.fileName.options[form.fileName.options.length] = new Option(text , value+'|'+imgwidth+'|'+fileSize);
	eval("frmWrite."+tbx).value = text;
	//총파일사이즈 변경(byte)
	//form.allSizeByte.value = parseInt(form.allSizeByte.value) + fileSize;
	
	//총파일사이즈 변경(kb)
	//form.allSize.value = parseInt(form.allSizeByte.value/1024);
	eval("frmWrite."+hdn).value = fileSize;
}

function goFamily(url)
{
	if(url != ""){
		window.open(url);
	}
}

/*mouseR button ***************************************************************/  
if(jQuery) (function(){$.extend($.fn, {rightClick: function(handler) {$(this).each( function() {$(this).mousedown( function(e) {var evt = e;$(this).mouseup( function() {$(this).unbind('mouseup');if( evt.button == 2 ) {handler.call( $(this), evt );return false;} else {return true;}});});$(this)[0].oncontextmenu = function() {return false;}});return $(this);},rightMouseDown: function(handler) {$(this).each( function() {$(this).mousedown( function(e) {if( e.button == 2 ) {handler.call( $(this), e );return false;} else {return true;}});$(this)[0].oncontextmenu = function() {return false;}});return $(this);},rightMouseUp: function(handler) {$(this).each( function() {$(this).mouseup( function(e) {if( e.button == 2 ) {handler.call( $(this), e );return false;} else {return true;}});$(this)[0].oncontextmenu = function() {return false;}});return $(this);},noContext: function() {$(this).each( function() {$(this)[0].oncontextmenu = function() {return false;}});return $(this);}});})(jQuery);  
$(document).ready( function() {$("img").rightClick(function(e){}).noContext(); $(document).bind('keydown', 'ctrl+a', function(){return false;}).bind('keydown', 'ctrl+c', function(){return false;});  });
/*****************************************************************************/
(function($){
	
	$(document).ready(function(){
		//gnb
		$("#gnb").mouseover(function(){
			$(this).css("height","245px");
		});

		//FAQ
		$(".accordion li.question").each(function(i){
			$(this).toggle(
				function(){
					$(".accordion li.question").removeClass("on")
					$(this).addClass("on");
					$(".accordion li.question").next('.answer').css('display','none');
					$(this).next('.answer').css('display','block');
					// idx 값을 rel 에 담아서 넘어옴 - str

					//alert($(this).attr('rel'));
//					faqViewCount($(this).attr('rel'));

					// idx 값을 rel 에 담아서 넘어옴 - end
				},function(){
					$(this).next('.answer').css('display','none');
					$(this).removeClass("on");
				}
			);
		});

		//lnb
		$("#aside .lnb li").each(function(){
			
			$(this).mouseover(function(){
				$("#aside .lnb li").removeClass("on");
				$(this).addClass("on");
			});
		});
		$('#aside .lnb li:not(.on) img').mouseover(function(){
			var filename = $(this).attr('src');
			$(this).attr('src',filename.replace('.gif','_on.gif'));
		});
		$('#aside .lnb li:not(.on) img').mouseout(function(){
			var filename = $(this).attr('src');
			$(this).attr('src',filename.replace('_on.gif','.gif'));
		});

		//게시판 탭메뉴
		$('.board_tabmn li').each(function(){
			$('.board_tabmn li').mouseover(function(){
				var filename = $(this).find("img").attr('src');
				$('.board_tabmn li:not(".on")').removeClass('on');
				$(this).addClass('on');
				$(this).find('img').attr('src',filename.replace('_off.gif','_on.gif'));
			});
			$('.board_tabmn li:not(".on")').mouseout(function(){
				$(this).removeClass('on');
				var filename = $(this).find("img").attr('src');
				$(this).find('img').attr('src',filename.replace('_on.gif','_off.gif'));
			});
		});

		//FAQ 검색 정렬 선택
		$('.board_choice li').css('display','none');
		$('.board_choice li:first').css('display','block');
		$('.board_search div').css('overflow','hidden').css('height','16px');

		$('.board_choice li').click(function(){
			$('.board_search div').css('overflow','visible').css('height','65px');
			if($('.board_choice li:visible').length > 1){
				$(this).css('display','block').siblings().css('display','none');
				$('.board_search div').css('overflow','hidden').css('height','16px');
			}else{
				$('.board_choice li').css('display','block');
				
			}
		});

		
		$('.thumb_intro li dt').each(function(){
			$(this).mouseover(function(){
				$('.thumb_intro li dt').each(function(){
					var filenm = $(this).find("img").attr('src');
					$(this).find('img').attr('src',filenm.replace('_on.jpg','_off.jpg'));
				});
				$('.thumb_intro li dd').css("display","none");
				$('.thumb_intro li dt .bl').css("display","none");
				$(this).next(".pic").css("display","block");
				$(this).find(".bl").css("display","block");
				var filename = $(this).find("img").attr('src');
				$(this).find('img').attr('src',filename.replace('_off.jpg','_on.jpg'));
			});
		});

		//인증서 팝업 2011-06-21

		$(".auc li dt").each(function(i){
				$(".auc li dd:not(.on)").css("display","none");
			$(this).click(function(){
				$(".auc li dt").removeClass('on');
				$(this).addClass('on');
				$(".auc li dd").css('display','none');
				$(".auc li dd:eq("+i+")").css('display','block');
			});
		});

/*
		$(".auc li dt").each(function(){
				$(".auc li dd:not(.on)").css("display","none");
			$(this).toggle(function(){
				$(".auc li dd").css("display","none");
				$(".auc li dt").removeClass("on");
				$(this).next("dd").css("display","block");
				$(this).addClass("on");
			},function(){
				$(this).next('.answer').css('display','none');
				$(this).removeClass("on");
			});
		});

*/
		
		//렌즈 설계 장점
		$(".accordion_lens dl dt").each(function(){
			$(this).toggle(function(){
				$(".accordion_lens dl dd.cont").css("display","none");
				$(this).next("dd").css("display","block");
				$(".accordion_lens dl dt").css("display","block");
				$(this).css("display","none");
			},function(){
			});
		});

		//로드맵
		$(".rmap_list li.question").each(function(){
			$(this).toggle(
				function(){
					$(".rmap_list li.question").next('.answer').css('display','none');
					$(this).next('.answer').css('display','block');
					$(this).addClass("on");
				},function(){
					$(this).next('.answer').css('display','none');
					$(this).removeClass("on");
				}
			);
		});


		
		$(".ex_list li:not(.on)").each(function(){
			$(this).mouseover(function(){
				$(".ex_list li:not(.on)").find('span').css("display","none");
				$(this).find('span').css("display","block");
			});
			$(this).mouseout(function(){
				$(".ex_list li:not(.on)").find('span').css("display","none");
			});
		});

		$('a.player').click(function(){
			var popupid = $(this).attr('rel');
			$('#' + popupid).fadeIn();
			$('body').append('<div id="fade"></div>');
			$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
			var popuptopmargin = ($('#' + popupid).height() + 10) /4;
			var popupleftmargin = ($('#' + popupid).width() + 10) / 2;
			$('#' + popupid).css({
				'margin-top' : -popuptopmargin,
				'margin-left' : -popupleftmargin
				});
			});
		
		$('.popmd .clse').click(function(){
			$('#fade ,#popup01 , #popup02').fadeOut()
				return false;
		});

		//검색창 기본값
		$("#header input.keytxt").focus(function(){$(this).val("");});
		$("#header input.keytxt").blur(function(){
			var value="키워드 검색";
			if($(this).val()=="") {$(this).val(value);}
		});

		//no mouse right button
		//$("html").rightClick(function(e){}).noContext();
		//no key
		//$(document).bind('', 'ctrl+a', function(){return false;}).bind('', 'ctrl+c', function(){return false;});
		//no drag
		//$(document).mousedown(function(){$(document).mousemove(function(e){return false;});});
	});
})(jQuery);
