var popup = false;

function OpenPopup(e, url, width, height, align, valign)
{
	if (popup)
		ClosePopup();

	var x = e.pageX ? e.pageX : document.body.scrollLeft + e.clientX; 
    
	if (align > 0)
		x -= width;

	var y = e.pageY ? e.pageY : document.body.scrollTop + e.clientY; 
	if (valign > 1)
		y -= height;

	var html = "<p><iframe src=\"" + url + "\" width=\"" + width + "\" height=\"" + height + "\" leftmargin=\"0\" marginheight=\"0\" marginwidth=\"0\" topmargin=\"0\"  scrolling=\"no\"  frameborder=\"0\" allowtransparency=\"true\"></iframe></p>";
	var div = document.getElementById("popup");
	
	div.style.left = x;
	div.style.top = y;
	div.style.width = width;
	div.style.height = height;
	div.innerHTML = html;
	div.style.display = "block";
	popup = true;
}

function ClosePopup()
{
	var div = document.getElementById("popup");
	div.style.display = "none";
	div.innerHTML = "";
	popup = false;
}

function BookmarkTown(e, bookmark_id, bookmark_name)
{ 
	OpenPopup(e, "/town/bookmark.php?bookmark_id=" + bookmark_id + "&bookmark_name=" + encodeURIComponent(bookmark_name), 300, 250, 0, 0);

}

function BookmarkStore(e, bookmark_id, bookmark_name, category_id, town_id)
{	

	OpenPopup(e, "/store/bookmark.proc.php?bookmark_id=" + bookmark_id + "&bookmark_name=" + bookmark_name+"&category_id="+category_id+"&town_id="+town_id+"&from=1&apitype=2", 300, 250, 0, 0);
}

function CheckEmail(email)
{
	var reg = new RegExp(/^[A-Za-z0-9]{4,12}@[A-Za-z0-9]{2,12}\.[A-Za-z0-9]{2,12}/g);
	if( !reg.test(email))
		return false;
	return true;
}

function InviteTown(e, town_id, town_name)
{
	OpenPopup(e, "/user/notice.email.php?profile_type=2&profile_id=" + town_id + "&profile_name=" + encodeURIComponent(town_name), 335, 500, 1, 0);
}

function InviteStore(e, store_id, store_name)
{
	OpenPopup(e, "/user/notice.email.php?profile_type=1&profile_id=" + store_id + "&profile_name=" + store_name, 335, 500, 1, 0);
}

function InviteUser(e)
{
	OpenPopup(e, "/user/invite.php", 335, 500, 1, 0);
}

function CheckNameDup(e)
{
	
	if (document.store_input.store_name.value == "")
	{
		alert("이름을 입력해주십시오.");
		return false;
	}
	for(i=0;i<document.store_input.store_name.value.length;i++)
	{
		store_name =document.store_input.store_name.value.charAt(i);
         //value="<?= $str_store_name ?>"
        var str = /[^0-9a-zA-Z가-힣ぁ-ん一-龥&()]/;
        store_code=store_name.charCodeAt();
		if(document.store_input.store_name.value.charAt(i)==" ")
		{
			
			alert ("이름에 공백을 삭제해주세요.");
            document.store_input.store_name.focus();
			return false;
		}
        if(str.test(store_name)) 
		{
          alert("특수문자 '"+store_name+"' 를 사용할 수 없습니다");
		  document.store_input.store_name.focus();
          return false;
		}
	}
	
	//StoreRegist(e,document.store_input.store_name.value);
	OpenPopup(e, "/store/store.name.php?store_name="+encodeURIComponent(document.store_input.store_name.value), 335, 385, 0, 0);
	//document.store_input.store_name_clone.value = document.store_input.store_name.value;
}
function RequestFriend(e, friend_id, friend_name,num)
{
//	OpenPopup(e, "/user/friend.request.php?friend_id=" + friend_id + "&friend_name=" + encodeURIComponent(friend_name), 335, 300, 1, 0);
	OpenPopup(e, "/user/follow.add.php?friend_id=" + friend_id + "&friend_name=" + encodeURIComponent(friend_name) + "&num="+num, 335, 300, 1, 0);
}

function InviteAgain(e, invite_id)
{
	OpenPopup(e, "/user/invite.again.php?invite_id=" + invite_id, 335, 300, 1, 0);
}

function RequestAgain(e, friend_id, friend_name)
{
	OpenPopup(e, "/user/friend.request.again.php?friend_id=" + friend_id + "&friend_name=" + encodeURIComponent(friend_name), 335, 300, 1, 0);
}

function DeleteFriend(e, friend_id, friend_name,num)
{   
	OpenPopup(e, "/user/friend.delete.php?friend_id="  + friend_id + "&friend_name=" + encodeURIComponent(friend_name) + "&num="+num, 260, 300, 1, 0);
}


function BlockFollower(e, friend_id, friend_name)
{
	OpenPopup(e, "/user/follower.block.php?friend_id="  + friend_id + "&friend_name=" + encodeURIComponent(friend_name), 310, 300, 1, 0);
}

function UnblockFollower(e, friend_id, friend_name)
{
	OpenPopup(e, "/user/follower.unblock.php?friend_id="  + friend_id + "&friend_name=" + encodeURIComponent(friend_name), 310, 300, 1, 0);
}

function AcceptFriend(e, friend_id, friend_name)
{
	OpenPopup(e, "/user/friend.proc.php?friend_id="  + friend_id + "&friend_name=" + encodeURIComponent(friend_name), 280, 200, 0, 0);
}

function RejectFriend(e, friend_id, friend_name)
{
	OpenPopup(e, "/user/friend.reject.proc.php?friend_id="  + friend_id + "&friend_name=" + encodeURIComponent(friend_name), 280, 200, 0, 0);
}

function LoginLeft(e)
{
	// OpenPopup(e, "/user/alert.login.php", 300, 200, 1, 0);
	if (confirm("로그인 후 이용 가능한 서비스입니다. 로그인하시겠습니까?"))
	{
		document.location = "/user/login.php?url=" + encodeURIComponent(document.location);
	}
}

function LoginRight(e)
{
	// OpenPopup(e, "/user/alert.login.php", 300, 200, 0, 0);
	if (confirm("로그인 후 이용 가능한 서비스입니다. 로그인하시겠습니까?"))
	{ 
		document.location = "/user/login.php?url=" + encodeURIComponent(document.location);
	}
}

function UploadStoreImage(e, store_id,user_id,user_name)
{
	OpenPopup(e, "/store/upload.php?store_id=" + store_id + "&user_id=" + user_id + "&user_name=" + encodeURIComponent(user_name), 320, 350, 0, 0);
}

function OpenMap(e, store_id)
{
	OpenPopup(e, "/store/map.php?store_id=" + store_id, 620, 540, 0, 0);
}

function ChangeUserEmail(e, user_id, user_name, user_email)
{
	OpenPopup(e, "/user/edit.proc.email.ajax.php?user_id="  + user_id + "&user_name=" + encodeURIComponent(user_name) + "&user_email=" + encodeURIComponent(user_email), 380, 300, 0,0);
}

function ScrapToStory(e, post_id, item_id,type)
{ 
	OpenPopup(e, "/user/story.scrap.php?post_id="  + post_id + "&item_id="  + item_id + "&type=" + type, 400, 300, 1,0);
}

/*function WriteConfirm(e)
{   
	var txt_story = document.getElementById("txt_story");
	var icon_type = document.getElementById("icon_type");

//	if(trim(txt_story.value) == "" || writable==0) {
	if(trim(txt_story.value) == "") {
		alert("내용을 입력하세요.");
		txt_story.focus();
		return false;
	}

	if(/@[^\s|&]+(\s|$)/.test(txt_story.value)){
		OpenPopup(e, "/user/quick.post.proc.php?content="  +  encodeURIComponent(txt_story.value)  + "&icon_type="  + icon_type.value+ "&type=1&from=1", 400, 300, 1,0);
	}else{
		var type=1;
		var confirm=1;

		OpenPopup(e, "/user/story.proc.php?content="  +  encodeURIComponent(txt_story.value) + "&icon_type="  + icon_type.value+ "&confirm=" + confirm+"&type="+type, 400, 300, 1,0);
	}
}*/



////////////////////////20100601 kingka 북마크 끊을때
	function  DeleteBookmark(e, store_id, store_name,type){
		OpenPopup(e, "/store/bookmark.delete.php?store_id="+store_id+"&store_name="+store_name+"&type="+type, 300, 250, 0, 0);

	}




///////////////////task/index.php


