///////////////////////////////////   general  //////////////////////////////////////////////
function Refresh()
{
	window.status = 'refresh...';
	document.location.reload();
}

function SendNote(recipientUid,recipientNickname)
{
	newWinHandler = window.open('/noteDesk/index.pl?action=new&recipientUid='+recipientUid+'&recipientNickname='+recipientNickname,'newWin','scrollbars=no,resizable,left=10,top=10,width=473,height=237');
}
function ViewIDCard(recipientUid,recipientNickname)
{
	cardWinHandler = window.open('/IDCards/viewer.pl?uid='+recipientUid+'&nickname='+recipientNickname,'cardWin','scrollbars=no,resizable,left=10,top=10,width=324,height=370');
}
function InviteToChat(recipientUid,recipientNickname)
{
	chatInviteWinHandler = window.open("/whosOnline/inviteToChat.htm#recipientUid="+recipientUid+";recipientNickname='"+recipientNickname+"';",'chatInviteWin','scrollbars=no,resizable,left=10,top=10,width=310,height=252');
}
function ChatNow(room, roomTheme)
{
	chatWinHandler = window.open('/kiddonet/chitchat/index.pl?room='+room+'&roomTheme='+roomTheme, 'chatWin', 'status=1,scrollbars=no,resizable,left=10,top=10,width=800,height=500');
}

function GS()
{
	GirlSenseHomePageWinHandler = window.open('http://www.girlsense.com/','GirlSenseHomePage','scrollbars=yes,toolbar=no,resizable=yes,status=no,left=10,top=10,width=800,height=600');	
}


function GetFlashFace(faceIdParam)
{
	if(faceIdParam == "")
		return;
	var swfSrc = "/IDCards/face_viewer.swf?face_id=" + faceIdParam;
	
	var flashStr = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' ID='face_maker' WIDTH='104' HEIGHT='101' ALIGN=''>";
	flashStr += "<PARAM NAME=movie VALUE='"+swfSrc+"'>";
	flashStr += "<PARAM NAME=quality VALUE=high>";
	flashStr += "<PARAM NAME=wmode VALUE=transparent>";
	flashStr += "<PARAM NAME=bgcolor VALUE=#FFFFFF>";
	flashStr += "<EMBED src='"+swfSrc+"' quality=high wmode=transparent bgcolor=#FFFFFF  WIDTH='104' HEIGHT='101' swLiveConnect=true ID='face_maker' NAME='face_maker' ALIGN='' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED>";
	flashStr += "</OBJECT>";
	
	return( flashStr );
}

function MyProfile()
{
	str = "";	
	if(my_faceId != "")
	{
		str += ("<td align=center valign=middle>" + GetFlashFace(my_faceId) + "<br><a href=\"javascript:ViewIDCard(" + uid + ",'" + nickname + "')\">See id card</a>" + "</td>");
	}
	document.write(str);
}


function ShowMyNotes()
{
	myWinHandler = window.open('/noteDesk/index.pl?action=view','myWin','scrollbars=no,resizable,left=10,top=10,width=500,height=440');
}

///////////////////////////////// viewPosts ///////////////////////////////////////

function CheckText(textObject)
{
	if(textObject.value == "Type your text here" || textObject.value == "Type your title here")
		textObject.value = "";
}
function CheckTextSize(textObject,textLimit)
{
	if(textObject.value.length>textLimit)
	{
		alert("Oops... your message is too long.")
		textObject.value = textObject.value.substr(0,textLimit);
	}
}

function InitPosts()
{
	for(i=0; i<document.forms.theForm.search.options.length; i++)
	{
		if(document.forms.theForm.search.options[i].value == document.forms.theForm.currentSearch.value)
		{
			document.forms.theForm.search.options.selectedIndex = i;
			return;
		}
	}
}

function BoardRules()
{
	//theLink = 'http://www.ign.com/board_rules.html';
	//boardRulesWinHandler = window.open(theLink,'boardRulesWin','scrollbars=auto,resizable,left=10,top=10,width=800,height=600');
	RulesDivOpen();
}

function EditPost(postId)
{
	theLink = '/premium/GSBoard/index.pl?action=editPost&postId=' + postId + "&uid=" + uid + "&nickname=" + nickname;
	editPostWinHandler = window.open(theLink,'editPostWin','scrollbars=auto,resizable,left=10,top=10,width=600,height=350');
}

function EmailPost(postId)
{
	theLink = '/premium/GSBoard/index.pl?action=editEmail&postId=' + postId + "&uid=" + uid + "&nickname=" + nickname;
	emailPostWinHandler = window.open(theLink,'emailPostWin','scrollbars=auto,resizable,left=300,top=250,width=414,height=196');
}

function OrderByNext(direction)
{
	document.forms.theForm.limitBegin.value = parseInt(document.forms.theForm.limitBegin.value) + (parseInt(direction) * parseInt(document.forms.theForm.limit.value));
	if(document.forms.theForm.limitBegin.value < 0 )
		document.forms.theForm.limitBegin.value = '0';
	document.forms.theForm.submit();
}

function SearchPost()
{
	if(document.forms.theForm.nickname.value != "")
		document.forms.theForm.search.selectedIndex = 0;

	document.forms.theForm.limitBegin.value = '0';
				
	document.forms.theForm.submit();
}

function AddPostToFavorites(postId)
{
	theLink = '/premium/GSBoard/index.pl?action=addPostToFavorites&postId=' + postId + "&uid=" + uid + "&nickname=" + nickname;
	addPostToFavoritesWinHandler = window.open(theLink,'addPostToFavoritesWin','scrollbars=auto,resizable,left=10,top=10,width=409,height=136');
}

function RemovePostFromFavorites(postId)
{
	theLink = '/premium/GSBoard/index.pl?action=removePostFromFavorites&postId=' + postId + "&uid=" + uid + "&nickname=" + nickname;
	removePostFromFavoritesWinHandler = window.open(theLink,'removePostFromFavoritesWin','scrollbars=auto,resizable,left=10,top=10,width=409,height=136');
}


function SeeFavorites()
{
	document.forms.theForm.search.value = 'my favorites';		
	document.forms.theForm.submit();

	//theLink = '/premium/GSBoard/index.pl?action=viewPosts&$search=my favorites';
	//self.location.href=theLink;
}

function ViewComments(postId)
{
	theLink = '/premium/GSBoard/index.pl?action=viewComments&postId=' + postId + "&uid=" + uid + "&nickname=" + nickname;
	//viewCommentWinHandler = window.open(theLink,'viewCommentWin','scrollbars=yes,resizable,left=10,top=10,width=640,height=480');
	//document.getElementById('iframe_'+postId).src = theLink;
	self.location.href=theLink;
}

function NewComment(postId)
{
	if(uid == '' || uid == '0')
	{
		theLink = '/premium/login/login.pl?target='+self.location.href;
		self.location.href = theLink;
	}
	else
	{
		theLink = '/premium/GSBoard/index.pl?action=newComment&postId=' + postId + "&uid=" + uid + "&nickname=" + nickname;
		newCommentWinHandler = window.open(theLink,'newCommentWin','scrollbars=auto,resizable,left=300,top=250,width=414,height=133');
	}	
}

function FeatureUnlock(activity, merchandise)
{
	/*
	alert(activity + "\n" + merchandise)
	if(activity!="" && merchandise!="")
	{
		available_features += ("-" + merchandise);
		eval(merchandise + "()");
	}
	*/
}

function NewPost()
{
  if(premium != 1 && available_features.indexOf("NewPost") == -1 )
  {
	  FeatureUnlockOffer('GSBoardFeatures', 'NewPost', 50)
  }
  else
  {	
	theLink = '/premium/GSBoard/index.pl?action=newPost' + "&uid=" + uid + "&nickname=" + nickname;
	newPostWinHandler = window.open(theLink,'newPostWin','scrollbars=auto,resizable,left=300,top=250,width=414,height=133');
  }	
}

function OwnerMenu()
{
	OwnerMenuStr = "";
	OwnerMenuStr += ("");
	if(isOwner)
	{	
		OwnerMenuStr += ("<a href='javascript:NewPost()'>New Post</a><br>");
	}
	return (OwnerMenuStr);
}

//////////////////////////////////////// editPost  ///////////////////////////////////////
function InitPost()
{
	//InitEditor(document.getElementById('editor'));
	
	//document.forms.theForm.selectedIcon.selectedIndex = document.forms.theForm.icon.value;
	document.images.selectedIcon.src = "images/icons/" + document.forms.theForm.icon.value + ".gif";
	//document.forms.theForm.selectedStatus.selectedIndex = document.forms.theForm.status.value;
	//document.images.selectedStatus.src = "images/status/" + document.forms.theForm.status.value + ".gif";
}

var recentlySubmitPostFlag = false;
function SubmitPost()
{
	if(recentlySubmitPostFlag)
	{
		//alert("post already submited :)");
		return;
	}
	recentlySubmitPostFlag = true;
	
	//document.forms.theForm.content.value = document.all.editor.getContent();
    
	if(document.forms.theForm.content.value == "Type your text here")
		document.forms.theForm.content.value = "";
    
	if(document.forms.theForm.title.value == "" || document.forms.theForm.content.value == "")
	{
		alert("Please complete the form!");	
		return;
	}
	if(document.forms.theForm.title.value.length > 24)
	{
		alert("Please shorten the title!");	
		return;
	}
	if(document.forms.theForm.content.value.length > 100)
	{
		alert("Please shorten the content!");	
		return;
	}
	
	BlackFilterAjax.onResult = function(text, responseText)
	{
		if (responseText !== "OK")
		{
			alert('Please don\'t use inappropriate words!');
			recentlySubmitPostFlag = false;
			return;	
		}
		else
		{
			SubmitPostOK();
		}
	}
	
	/// checking ///
	var str = document.forms.theForm.title.value + " " + document.forms.theForm.content.value;
	BlackFilterAjax.check(str,'GSBoardPosts');
}

function SubmitPostOK()
{
	
	document.forms.theForm.submit();
}

function SetIcon(theIcon)
{
	//selectedIcon = document.forms.theForm.selectedIcon.options[document.forms.theForm.selectedIcon.selectedIndex].value;
	selectedIcon = theIcon;
	document.images.iconSelectionButton.src = "images/editor/icons_empty_out.gif";
	document.images.selectedIcon.src = "images/icons/" + selectedIcon + ".gif";
	document.forms.theForm.icon.value = selectedIcon;
	IconsDivClose();
}

function IconsDivOpen()
{
	document.getElementById('iconsDiv').style.display = 'block';
}

function IconsDivClose()
{
	document.getElementById('iconsDiv').style.display = 'none';
}

function IconsMenu()
{
	divClose_out = new Image()
	divClose_out.src = 'images/general/close_out.gif';
	divClose_over = new Image()
	divClose_over.src = 'images/general/close_over.gif';	
	
	IconsSelectStr = "";
	
	IconsSelectStr += ("<div id='iconsDiv' style='position:absolute;left:-250px;top:10px; z-index:444444; background-Image: url(images/icons/bg.gif); background-repeat: no-repeat; width:250px; height:64px; display:none;' >");
	IconsSelectStr += ("<a href='javascript:IconsDivClose()'><img src='images/general/close_out.gif' name=iconsDivCloseButton id=iconsDivCloseButton border=0 style='position:absolute;left:230px;top:5px; width:11px; height:11px;'  onmouseover='javascript:iconsDivCloseButton.src=divClose_over.src' onmouseout='javascript:iconsDivCloseButton.src=divClose_out.src'></a><br>");	
	for(i=1; i<17; i++)
	{
		IconsSelectStr += ("<a href='javascript:SetIcon(" + i + ")'><img src='images/icons/" + i + ".gif' border=0 align=absmiddle hspace=0 vspace=0 width=25></a>\n");
		if(i==8)
			IconsSelectStr += ("<br>\n");
	}
	IconsSelectStr += ("</div>");	
	/*
	IconsSelectStr += ("<select name='selectedIcon' onChange='javascript:SetIcon()'>");
	IconsSelectStr += ("<option value='0'>--- Select Icon ---</option>");
	IconsSelectStr += ("<option value='1'>smiling</option>");
	IconsSelectStr += ("<option value='2'>upset</option>");
	IconsSelectStr += ("<option value='3'>winking</option>");
	IconsSelectStr += ("<option value='4'>teasing</option>");
	IconsSelectStr += ("<option value='5'>laughing</option>");
	IconsSelectStr += ("</select><br><br>");
	*/
	return(IconsSelectStr);	
}

function StatusMenu()
{
	StatusSelectStr = "";
	StatusSelectStr += ("<select name='selectedStatus' onChange='javascript:SetStatus()'>");
	StatusSelectStr += ("<option value='0'>public post</option>");
	StatusSelectStr += ("<option value='1'>private post</option>");
	StatusSelectStr += ("</select>");
	
	return(StatusSelectStr);	
}

function NotifyMenu()
{
	NotifyChecked = ( notify=="1" ? " checked " : " ");
	NotifyStr = ("<input type=checkbox name='notify' " + NotifyChecked + " style='border:none;'> notify me when a comment has been submitted");
	return(NotifyStr);	
}

function SetStatus()
{
	selectedStatus = document.forms.theForm.selectedStatus.options[document.forms.theForm.selectedStatus.selectedIndex].value;
	document.images.selectedStatus.src = "images/status/" + selectedStatus + ".gif";
	document.forms.theForm.status.value = selectedStatus;
}

function BgcolorSelectChange()
{
	selectedBgcolor = document.forms.theForm.bgcolorSelect.options[document.forms.theForm.bgcolorSelect.selectedIndex].value;
	document.all.editor.setBackgroundColor(selectedBgcolor); document.all.editor.frameWindow.focus();
}

sFontSize=2;
function ChangeFontSize(direction)
{
	sFontSize += direction;
	document.all.editor.setFontSize(sFontSize); 
}


////////////////////////////////////////  viewComments  //////////////////////////////////

function InitComments()
{
	
}

///////////////////////////////////////  editComment  ////////////////////////////////////

function InitComment()
{
	
}

function MainBoard()
{
	theLink = '/premium/GSBoard/index.pl';
	//mainBoardWinHandler = window.open(theLink,'mainBoardWin','scrollbars=auto,resizable,left=10,top=10,width=800,height=600');
	self.location.href=theLink;
}

function SubmitComment()
{
	if(document.forms.theForm.content.value == "Type your text here")
		document.forms.theForm.content.value = "";

	if(document.forms.theForm.content.value == "")
	{
		alert("Please complete the form!");	
		return;
	}
	if(document.forms.theForm.content.value.length > 100)
	{
		alert("Please shorten the content!");	
		return;
	}
	
	
	BlackFilterAjax.onResult = function(text, responseText)
	{
		if (responseText !== "OK")
		{
			alert('Please don\'t use inappropriate words!');
			recentlySubmitPostFlag = false;
			return;	
		}
		else
		{
			SubmitPostOK();
		}
	}
	
	/// checking ///
	BlackFilterAjax.check(document.forms.theForm.content.value,'GSBoardComments');
}

/////////////////////////////////////  editEmail  //////////////////////////////////////

function InitEmail()
{
	
}

function SubmitEmail()
{
	if(document.forms.theForm.recipient1.value != '' && document.forms.theForm.recipient1.value.indexOf('@') == -1)
	{
		alert("Please enter a correct e-mail address.");	
		return;
	}	
	if(document.forms.theForm.recipient2.value != '' && document.forms.theForm.recipient2.value.indexOf('@') == -1)
	{
		alert("Please enter a correct e-mail address.");	
		return;
	}	
	if(document.forms.theForm.recipient3.value != '' && document.forms.theForm.recipient3.value.indexOf('@') == -1)
	{
		alert("Please enter a correct e-mail address.");	
		return;
	}	

	document.forms.theForm.submit();
}

function EntryDivClose()
{
	document.getElementById('entryDiv').style.display = 'none';
}

function RulesDivOpen()
{
	document.getElementById('rulesDiv').style.display = 'block';
}
function RulesDivClose()
{
	document.getElementById('rulesDiv').style.display = 'none';
}


function ViewBoutiqueByNickname(nickname)
{
	var thelink = "http://www.girlsense.com/premium/eBoutiques/viewer.pl?nickname=" + nickname;
	ViewMyBoutiqueWinHandler = window.open(thelink, 'ViewMyBoutiqueWin', 'scrollbars=yes,toolbar=yes,resizable=yes,status=yes,left=10,top=10,width=795,height=550');	
}

function ViewGSIDCardByNickname(nickname)
{
	if(nickname == null)
		nickname = '';
	var thelink = "http://www.girlsense.com/premium/GSIDCards/viewer.pl?nickname=" + nickname;
	ViewGSIDCardWinHandler = window.open(thelink, 'ViewGSIDCardWin', 'scrollbars=no,toolbar=no,resizable=yes,status=no,left=10,top=10,width=525,height=453');	
}
function ViewGSIDCard(uidCreator)
{
	if(uidCreator == null)
		uidCreator = '';
	var thelink = "http://www.girlsense.com/premium/GSIDCards/viewer.pl?uidCreator=" + uidCreator;
	ViewGSIDCardWinHandler = window.open(thelink, 'ViewGSIDCardWin', 'scrollbars=no,toolbar=no,resizable=yes,status=no,left=10,top=10,width=525,height=453');		
}

function Feedback()
{
	FeedbackWinHandler = window.open('http://www.girlsense.com/tools/feedback/index_ActivityTemplate.pl?project=gsActivity&referrer=GSBoard','FeedbackWin','scrollbars=yes,toolbar=no,resizable=yes,status=yes,left=10,top=10,width=640,height=480');	
}

