
/*
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)
{
    var strFlashTag = "";
    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);
}
 
  

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("")
	);						
}

