
/*
IE Flash ActiveContent Activation Script
Author: Faisal Iqbal (chall3ng3r)
Blog: http://www.orison.biz/blog/chall3ng3r/

Feel free to modify or distribute.
*/
 
/*
Method: FlashObject
 Param1: SWF path
 Param2: Movie width
 Param3: Movie height
 Param4: BGColor
 Param5: Flashvars (Optional)
*/


function FlashObject(swf, width, height, bgcolor, id, flashvars, mobileFnc)
{
    var strFlashTag = "";
    
    if (mobileFnc != null && cafen.isMobile()) {
    	if (typeof height == 'number')
    		height = height +'px';
    	else {
			if (height.indexOf('%') == -1 && height.indexOf('px') == -1)
				height = height +'px';
		}
    	if (typeof width == 'number')
    		width = width +'px';
    	else {
			if (width.indexOf('%') == -1 && width.indexOf('px') == -1)
				width = width +'px';
		}
		document.writeln("<div style='width:"+width+";height:"+height+"' id='"+id+"'>&nbsp;</div>");
		mobileFnc(id, flashvars, swf);
    } else {
	    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 += ' 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);
	}
}
var flashImg = '/IMAGES/swfimg/';
function drawTopMenu(id, flashvars, swf) {
	var htmls = [];
	var imgUrl = '';
	if (swf.indexOf('mNum=0') > 0) 
		imgUrl = 'top_02.gif';
	else if (swf.indexOf('mNum=1') > 0) 
		imgUrl = 'top_03.gif';
	else if (swf.indexOf('mNum=2') > 0) 
		imgUrl = 'top_04.gif';
	else if (swf.indexOf('mNum=3') > 0) 
		imgUrl = 'top_05.gif';
	else if (swf.indexOf('mNum=4') > 0) 
		imgUrl = 'top_06.gif';
	else if (swf.indexOf('mNum=5') > 0) 
		imgUrl = 'top_07.gif';
	else 
		imgUrl = 'top_01.gif';
	htmls.push('<img src="'+flashImg+imgUrl +'" width=684 height=70 usemap="#mainMap" border=0>');
	htmls.push('<map name="mainMap" id="mainMap">');
	htmls.push('<area shape="rect" coords="60,0,143,40" href="/company/" title="회사소개"/>');
	htmls.push('<area shape="rect" coords="164,0,260,40" href="/product/" title="제품안내" />');
	htmls.push('<area shape="rect" coords="295,0,376,40" href="/customer/" title="고객센타" />');
	htmls.push('<area shape="rect" coords="401,0,503,40" href="/preference/" title="기술개발서" />');
	htmls.push('<area shape="rect" coords="530,0,623,40" href="/community/" title="커뮤니티" />');
	htmls.push('</map>');
	cafen.$(id).innerHTML = htmls.join("");
}

function drawSubVisual(id, flashvars, swf) {
	var htmls = [];
	var imgUrl = '';
	if (swf.indexOf('subvisual01') > 0) 
		imgUrl = 'subvisual01.gif';
	else if (swf.indexOf('subvisual02') > 0) 
		imgUrl = 'subvisual02.gif';
	else if (swf.indexOf('subvisual03') > 0) 
		imgUrl = 'subvisual03.gif';
	else if (swf.indexOf('subvisual04') > 0) 
		imgUrl = 'subvisual04.gif';
	else if (swf.indexOf('subvisual05') > 0) 
		imgUrl = 'subvisual05.gif';
	else
		imgUrl = 'subvisual01.gif';
	htmls.push('<img src="'+flashImg+imgUrl +'" width=980 height=260 border=0>');
	cafen.$(id).innerHTML = htmls.join("");
}

function drawMainVisual(id, flashvars, swf) {
	var htmls = [];
	var imgUrl = '';
	imgUrl = 'mainvisual.gif';
	htmls.push('<img src="'+flashImg+imgUrl +'" width=980 height=370 border=0>');
	cafen.$(id).innerHTML = htmls.join("");
}

function drawLeftMenu(id, flashvars, swf) {
	var htmls = [];
	var menus = [];
	if (swf.indexOf('left_nav01') > 0) {
		menus.push({title : '회사소개', callUrl : 'about.html'});
		menus.push({title : '회사연혁', callUrl : 'history.html'});
		menus.push({title : '협력업체', callUrl : 'partner.html'});
		menus.push({title : '포트폴리오', callUrl : 'portfolio.html'});
	} else if (swf.indexOf('left_nav02') > 0) {
		menus.push({title : '블로그', callUrl : 'blog.html'});
		menus.push({title : '웹편집기', callUrl : 'editor.html'});
		menus.push({title : '지도', callUrl : 'map.html'});
		menus.push({title : '차트', callUrl : 'chart.html'});
		menus.push({title : '기타', callUrl : 'others.html'});
	} else if (swf.indexOf('left_nav03') > 0) {
		menus.push({title : '고객의 소리', callUrl : 'customer.html'});
		menus.push({title : 'FAQ', callUrl : 'faq.html'});
		menus.push({title : '다운로드', callUrl : 'download.html'});
	} else if (swf.indexOf('left_nav04') > 0) {
		menus.push({title : '웹편집기', callUrl : 'editor.html'});
		menus.push({title : '지도', callUrl : 'map.html'});
		menus.push({title : '차트', callUrl : 'chart.html'});
		menus.push({title : '기타', callUrl : 'others.html'});
	} else if (swf.indexOf('left_nav05') > 0) {
		menus.push({title : '공지사항', callUrl : 'notice.html'});
		menus.push({title : '업계소식', callUrl : 'bench.html'});
		menus.push({title : '질문과 답변', callUrl : 'qna.html'});
		menus.push({title : '자유게시판', callUrl : 'freeboard.html'});
	}
	var menuNo = 0;
	if (swf.indexOf('pageNum=0') > 0) 
		menuNo = 0;
	else if (swf.indexOf('pageNum=1') > 0) 
		menuNo = 1;
	else if (swf.indexOf('pageNum=2') > 0) 
		menuNo = 2;
	else if (swf.indexOf('pageNum=3') > 0) 
		menuNo = 3;
	else if (swf.indexOf('pageNum=4') > 0) 
		menuNo = 4;
	else if (swf.indexOf('pageNum=5') > 0) 
		menuNo = 5;
	for(var i = 0 ; i < menus.length; i++) {
		var currObj = menus[i];
		if (i == menuNo) {
			htmls.push('<div style="text-align:right;padding:7px 3px;border-bottom:1px solid #d5d5d5;"><a href="'+currObj.callUrl+'"><font style="font-size:14px;font-weight:bold;color:#000000">'+currObj.title+'</font></a><img src="'+flashImg+'icon_on.gif" border=0 hspace=3></div>');	
		} else {
			htmls.push('<div style="text-align:right;padding:7px 3px;border-bottom:1px solid #d5d5d5;"><a href="'+currObj.callUrl+'"><font style="font-size:14px;font-weight:normal;color:#b6b6b6">'+currObj.title+'</font></a><img src="'+flashImg+'icon_off.gif" border=0 hspace=3></div>');	
		}
	}

	cafen.$(id).innerHTML = htmls.join("");
}


function checkDelete(form) { 
	if (form.user_pw.value == '') {
		alert('관리 암호를 입력하여 주십시오');		
		form.user_pw.focus();
		return false;
	} else if (confirm('삭제하시겠습니까?')) {
		return true;
	} else 
		return false;
}

function deleteConfirm(uid, urlname) { 
	if (confirm('삭제하시게습니까?')) {
		document.location.href = urlname+'?mode=deletedb&muid='+uid;
	} 
}


function checkForm(form) {
	if (form.title.value == '') {
		alert('제목을 입력하세요.');
		form.title.focus();
		return false;
	} else if (form.user_name && form.user_name.value == '') {
		alert('이름을 입력하세요.');
		form.user_name.focus();
		return false;
	} else if (form.user_pw  && form.user_pw.value == '') {
		alert('관리 암호를 입력하세요.');
		form.user_pw.focus();
		return false;
	}
	if (!form.contents.parse())
		return false;
	else {
		form.spamCode.value = 'cafennet';
		return true;
	}
}

var init_maxwidth = 700;

function checkRainImg(max_width) {
	if (max_width != undefined)
		init_maxwidth = max_width;
	var objs = document.getElementsByTagName('img');
	var imgobjs = [];
	var className = 'cafenimg_resize';
	for(var i =0; i < objs.length; i++) 
		if (objs[i].className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 
			imgobjs.push(objs[i]);
	var len = imgobjs.length;
	for(var i = 0 ; i < len; i++) loadRainImg(imgobjs[i]);
	checkMore();
}

function imgView(img_obj) {
	window.open('/UPLOADS/pop_imgview.php?img='+img_obj.src, 'viewImg', 'width=100,height=100');
}

function checkMore() {
	var objs = document.getElementsByTagName('div');
	var moreobjs = [];
	var className = 'moretitle';
	for(var i =0; i < objs.length; i++) 
		if (objs[i].className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 
			moreobjs.push(objs[i]);
	var len = moreobjs.length;
	for(var i = 0 ; i < len; i++) 
		moreobjs[i].onclick = showHideMore;	
}

function showHideMore() {
	if (this.linkObj == null) {
		this.linkObj = document.getElementById(this.id +'_contents');
		this.isHide = true;
		this.orgText = this.innerHTML;
	} 
	if (!this.isHide) {
		this.innerHTML = this.orgText;
		this.linkObj.style.display = 'none';
		this.isHide = true;
	} else {
		this.innerHTML = '&gt; 숨기기';
		this.linkObj.style.display = 'block';
		this.isHide = false;
	}
}

function loadRainImg(imgobj) {
	try {
		if (imgobj.width > init_maxwidth) {
			imgobj.height = Number(imgobj.height * init_maxwidth / imgobj.width);
			imgobj.width = 	init_maxwidth;
			imgobj.style.width=init_maxwidth;
			imgobj.style.height=Number(imgobj.height * init_maxwidth / imgobj.width);
			imgobj.style.cursor= 'pointer';
			imgobj.onclick= function () {imgView(this)};
		} else if (imgobj.width > (init_maxwidth - 30)) {
			imgobj.style.cursor= 'pointer';
			imgobj.onclick= function () {imgView(this)};
		} else {
			imgobj.style.cursor= '';
			imgobj.onclick= null;
		}
	} catch(ex) {}
}

function RainImgError(obj) {
	obj.style.display = 'none';
}

function extendObj(destination, source) {
	for (property in source) {
		destination[property] = source[property];
	}
	return destination;
}

function getLogs(siteid, pageid, options) {
	options = extendObj({font: '#aaaaaa', axis : '#d6d6d6', grid : '#efefef', bg : '#ffffff', line:'#279b2f',type: 'linedot', width : 150, height: 100, label :'date_c', num: 7}, options);
	options.siteid = siteid;
	options.pageid = pageid;
	var tmpDate = new Date(); 
	options.viewid = tmpDate.getYear() + '/' +tmpDate.getMonth() +'/' + tmpDate.getDay() +'/' + tmpDate.getHours() + '/' + tmpDate.getMinutes();
	var flash_url = 'http://service2.cafen.net/images/open-flash-chart.swf';
	var datas = [];
	for(var idx in options)
		datas.push(idx + '=' + encodeURIComponent(options[idx]));
	document.write(['<object id="_rainsitelogs" type="application/x-shockwave-flash" data="', flash_url, '" width="',options.width,'" height="',options.height,'" style="-moz-user-focus: ignore;">',
		'<param name="movie" value="', flash_url , '" />',
		'<param name="bgcolor" value="" />',
		'<param name="wmode" value="transparent" />',
		'<param name="quality" value="high" />',
		'<param name="menu" value="false" />',
		'<param name="allowScriptAccess" value="always" />',
		'<param name="flashvars" value="data='+encodeURIComponent('http://chart.cafen.net/sitelogs/?' + datas.join('&'))+'" />',
		'</object>'].join("")
	);						
}


