function all_check(){ 
	var checkName=document.getElementsByName('aCheck[]');

	for(i=0;i<checkName.length;i++){
		if(checkName[i].type=="checkbox") {	
			if(!checkName[i].checked) { checkName[i].checked="checked";
			} else checkName[i].checked="";
		}
	} 
}


function c_result(value,type,mode2){
	var counter=0;
	var a_no="";
	var checkName=document.getElementsByName('aCheck[]');

	for(i=0;i<checkName.length;i++){
		if(checkName[i].checked) {
			if(a_no)	a_no=a_no+","+checkName[i].value;
			else a_no=checkName[i].value;
			counter++;
		}
	}

	if(counter==0) alert("Ã¼Å©¹Ú½º¸¦ ¼±ÅÃÇÏ¼¼¿ä.");
	else{
		if(type=="note") open('./note_admin.php?a_no='+a_no+'&m_no='+value+'&mode2='+mode2+'','noteWin','width=500,height=300,scrollbars=no,status=no');
		else open('./board/article_admin.php?corea='+value+'&a_no='+a_no+'','articleWin','width=400,height=570,scrollbars=no,status=no');
	}
}

function c_report(corea,no,cno){

	if(cno) open('./report.php?corea='+corea+'&no='+no+'&cno='+cno,'reportWin','width=450,height=480,scrollbars=no,status=no');
	else open('./report.php?corea='+corea+'&no='+no,'reportWin','width=450,height=480,scrollbars=no,status=no');
}

function origin_imgView(src,width,height){
	if(width>screen.width-100 && height>screen.height-100){
		SCwidth=screen.width-100;
		SCheight=screen.height-100;
		scrollbar="scrollbars=yes";
	}
	else if(width<screen.width-100 && height>screen.height-100){
		SCwidth=width;
		SCheight=screen.height-100;
		scrollbar="scrollbars=yes";
	}
	else if(width>screen.width-100 && height<screen.height-100){
		SCwidth=screen.width-100;
		SCheight=height;
		scrollbar="scrollbars=yes";
	}else{
		SCwidth=width;
		SCheight=height;
		scrollbar="scrollbars=no";
	}
	img_origin=window.open("","","width="+SCwidth+",height="+SCheight+",status=no,toolbar=no,"+scrollbar+",resizable=yes");
	img_origin.document.write("<html><title>¿øº»º¸±â</title>"
	+"<body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0><table border=0 cellspacing=0 cellpadding=0><tr><td>"
	+"<a href='javascript:self.close();'><img src='"+src+"' width="+width+" height="+height+" border=0 alt='Å¬¸¯ÇÏ½Ã¸é ´ÝÈü´Ï´Ù.'></a></td></tr></table>"
	+"</body></html>");
}



function add_Friendfunc(m_no,num){	
	if(num==1){
		var str="Ä£±¸·Î Ãß°¡ÇÏ½Ã°Ú½À´Ï±î?";

		if(confirm(str)==true) {
			window.open('http://www.eyecg.com/jb/add_friend.php?add_m='+m_no+'&mode=1','','width=10,height=10,scrollbars=no,resizable=no');
		}	
	}else{
		var str="Ä£±¸¿¡¼­ Á¦¿Ü ÇÏ½Ã°Ú½À´Ï±î?";

		if(confirm(str)==true) {
			window.open('http://www.eyecg.com/jb/add_friend.php?add_m='+m_no+'&mode=2','','width=10,height=10,scrollbars=no,resizable=no');
		}	
	}
}


function Urltoclip(meintext){
	if (window.clipboardData){ 

	// the IE-manier
	window.clipboardData.setData("Text", meintext);

	// waarschijnlijk niet de beste manier om Moz/NS te detecteren;
	// het is mij echter onbekend vanaf welke versie dit precies werkt:
	}
	else if (window.netscape){

		// dit is belangrijk maar staat nergens duidelijk vermeld:
		// you have to sign the code to enable this, or see notes below
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

		// maak een interface naar het clipboard
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;

		// maak een transferable
		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;

		// specificeer wat voor soort data we op willen halen; text in dit geval
		trans.addDataFlavor('text/unicode');

		// om de data uit de transferable te halen hebben we 2 nieuwe objecten nodig om het in op te slaan
		var str = new Object();
		var len = new Object();

		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);

		var copytext=meintext;

		str.data=copytext;

		trans.setTransferData("text/unicode",str,copytext.length*2);

		var clipid=Components.interfaces.nsIClipboard;

		if (!clip) return false;

		clip.setData(trans,null,clipid.kGlobalClipboard);

	}
	alert("ÁÖ¼Ò°¡ º¹»çµÇ¾ú½À´Ï´Ù.\n\nÁÖ¼ÒÁÙ¿¡¼­ Ctrl+V ¸¦ ÀÌ¿ëÇÏ½Ê½Ã¿À.");
	return false;
}


function insertComma(pay){ 
       var idx=0; 
       arrRev = new Array(); 
       var lpay = ""; 
       pay = pay.toString(); 
       arr = pay.split(""); 
       //alert("arr" + arr); 
       //alert(arr.length); 
       for(i = arr.length; i > 0 ; i--){ 
           arrRev[idx] = arr[i-1]; 
           //alert(arrRev[idx] + "=>" + idx); 
           idx++; 
           if((idx ==3 || idx == 7 || idx == 11 || idx == 15 || idx == 19) && (i != 1)){ 
               arrRev[idx] = ","; 
               //alert(arrRev[idx] + "=>" + idx); 
               idx++; 
           } 
       } 
       //alert(arrRev.length); 
       for(i=arrRev.length; i>0; i--){ 
           lpay += arrRev[i-1]; 

       } 
       return lpay; 
}

function number_format(str) { 
	str+=""; 

	var objRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');  

	while(objRegExp.test(str)) 	{ 
		str = str.replace(objRegExp, '$1,$2'); 
	}  

	return str; 
}

String.prototype.replaceAll = function(targetStr,replaceStr){ 
    thisStr = this.toString(); 
    var idx = thisStr.indexOf( targetStr ); 
    while ( idx > -1 ) { 
        thisStr = thisStr.replace( targetStr, replaceStr ); 
        idx = thisStr.indexOf( targetStr ); 
    } 
    return thisStr; 
}

function cart_result(type){
	var counter=0;
	var a_no="";
	var checkName=document.getElementsByName('aCheck[]');

	for(i=0;i<checkName.length;i++){
		if(checkName[i].checked) {
			if(a_no)	a_no=a_no+","+checkName[i].value;
			else a_no=checkName[i].value;
			counter++;
		}
	}

	if(counter==0) alert("Ã¼Å©¹Ú½º¸¦ ¼±ÅÃÇÏ¼¼¿ä.");
	else{
		if(type=="pay") location.href='?pid=payment&cartinfor='+a_no+'&mode=pay';
		else if(type=="delete") location.href='?pid=payment&cartinfor='+a_no+'&mode=del';
	}
}
