﻿function StartModifyEvent(){
 
	$("div#worldCup_pop").load("/popup/event_modify.html").show();
}

function ModifyEvent(){

	if (isLogin == false)
	{
		if (confirm("로그인 후 이용해 주시기 바랍니다.\n로그인하시겠습니까?"))
		{
			loginpop();
			return;
		};
		return;
	}

 modifymember();

}

function IntroModify(){

	 


	if (isLogin==false)
	{
		if (confirm("로그인 후 이용해 주시기 바랍니다.\n로그인하시겠습니까?"))
		{
			loginpop();
			return;
		};
		return;
	}

eCode = "";
sendToIntro();



}


function sendToIntro(){

	 
	$.post("/event/1007_IntroModify.aspx", {"ei" : eCode},function(data){
		 
		  
		if (data == "-1")
		{
			//로그인 해야 함
			alert("로그인이 필요합니다.");		

		}
		else if (data=="1")
		{
			//이벤트 정상 참여함
			alert("친구에게 소개하기 이벤트를 통해 방문하셨습니다.\n회원님의 다른 친구분들에게 이벤트를 소개해 보세요.");

		}
		else if (data=="2")
		{
			//같은 IP임
			alert("친구들에게 알려주세요.\n본인의 링크로 접근하셨습니다.");

		}
		else if (data.length == 10 )
		{
		 
		
		CopyPath_2("http://www.cocacola.co.kr/?ei="+data);

		 alert("URL이 복사되었습니다.\nctrl+v로 친구들에게 알려 주세요.");


		}else
			{
			//오류 사항

			alert("죄송합니다. 이벤트 참여 도중 오류가 발생하였습니다.\n다시 시도해 주시기 바랍니다.");
		}
			
	});
}

function ModifyWinner(){

window.open("/popup/pop_myinfo_event.html","eventWinner","width=659, height=577").focus();
}

function CloseIntro(){

$("div#worldCup_pop").hide();
}



 //클립보드
function CopyPath_2(val) {

   meintext = val;//eval(inputPath + ".value");

   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); 

  } 


  

}

//팝업

$(function(){

if ( location.href.toLowerCase().indexOf("e=intro") > 5 || location.href.toLowerCase().indexOf("ei=") > 5)
{
}else{
//window.open("/popup/popup_myinfo.html","myinfo","width=527, height=400,status=0,resizable=1").focus();
}
 
//NoticePopup(370,305,'/popup/pop_superstar_k2.html','n_01','p1',0,0   ); 
//NoticePopup(400,338,'/popup/pop_wish_card.html','n_01','p1',0,0   ); 
//PollWidget
});


//PollWidget

function pollWidget(){
	window.open("/popup/pollWidgetStart.html","poll","width=730, height=600, resizable=1").focus();
}

function NoticePopup(pWidth, pHeight, filename, cookiename,wn, l, t)
{	
 
	if ( getCookie(cookiename) != "done" ) {
		winl = (screen.width - pWidth) / 2;
		wint = (screen.height - pHeight) / 2;
                                          if (l != undefined ) winl = l;
                                          if (t != undefined ) wint = t;
 
		winprops = 'width='+pWidth+',height='+pHeight+',top='+wint+',left='+winl+',scrollbars=no ,resizable=no' ;
		win = window.open(filename, wn, winprops).focus() ;
	}
}



function getCookie( name ){
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
		if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
		endOfCookie = document.cookie.length;
		return unescape( document.cookie.substring( y, endOfCookie ) );
	}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
		break;
	}
		return "";
}

// 쿠키를 만듭니다. 아래 closeWin() 함수에서 호출됩니다
function setCookie( name, value, expiredays ) 
{ 
var todayDate = new Date(); 
todayDate.setDate( todayDate.getDate() + expiredays ); 
document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 
 
function GoUrl(s){
	var url = "";
 	url = "http://www.cenovis.co.kr/Event/EventView.aspx?Id=18";
	
	if (url != ""){
	opener.location.href=url;
	}
	
	window.close();
}

