// Common js-scripts for blog-functions

function toggleBlogEntry(meid,objid)
{
	var obj = document.getElementById(objid);
	var me = document.getElementById(meid);

	if( obj.style.display != 'none' )
	{
      obj.style.display="none";
	  me.innerHTML = '<img src="/__files/img/icons/plus.gif" width="9" height="9" border="0" Alt="Visa texten" title=\"Visa texten\">';
	}
	else
	{
	  obj.style.display="block";
	  me.innerHTML = '<img src="/__files/img/icons/minus.gif" width="9" height="9" border="0" Alt="Göm texten" title=\"Göm texten\">';
	}
}


function blogReply(divname)
{
	var obj = document.getElementById(divname + 'link');
    obj.style.display = 'none';
	obj = document.getElementById(divname);
    obj.style.display = 'block';

    tinyMCE.execCommand('mceFocus',true,'blogreplyarea');
}

function blogPreview(formname,fieldname)
{
	document.forms[formname].elements[fieldname].value = 1;
    document.forms[formname].submit();
}

function blogLinkVote(bid,score,ret,uid)
{
  if( uid == 0 )
  {
    badMessage("Du måste vara inloggad för att kunna betygsätta en länk");
  }
  else
  {
    document.location = '/__batch/bloglinkvote.html?id=' + bid + '&score=' + score + '&ret=' + escape(ret);
  }
}

function blogPollVote(bid,alt,ret,uid)
{
  if( uid == 0 )
  {
    badMessage("Du måste vara inloggad för att rösta");
  }
  else
  {
    document.location = '/__batch/blogpollvote.html?id=' + bid + '&alt=' + alt + '&ret=' + escape(ret);
  }
}

function blogRssFeedIcon(args)
{
	//document.writeln('<div class="blogrssicon"><a href="/rss/?' + args + '" target="_blank" title="Denna kategori som RSS-flöde"><img src="/__files/img/icons/feed-icon14x14.png" alt="Denna kategori som RSS-flöde" width="14" height="14" border="0">&nbsp;Kategorin&nbsp;som&nbsp;RSS</a><br>');
	document.writeln('<div class="blogrssicon"><a href="/rss/' + args + '" target="_blank" title="Visa/Spara RSS-flöde"><img src="/__files/img/icons/rss-feed.gif" border="0" alt="Visa/Spara RSS-flöde" width="66" height="17" style="padding-top:4px;"></a>&nbsp;');
	document.writeln('<a href="http://fusion.google.com/add?feedurl=' + escape('http://' + window.location.host + '/rss/' + args) + '" title="Lägg till på Google"><img src="/__files/img/icons/add-to-google-plus.gif" width="104" height="17" border="0" alt="Lägg till på Google" style="padding-top:4px;"></a></div>');
}

function blogFlagNew()
{
	document.writeln('<img src="/__files/img/icons/new.gif" alt="Inlägget är nytt eller uppdaterat sedan din förra inloggning!" width="15" height="10" border="0" title="Inlägget är nytt eller uppdaterat sedan din förra inloggning!">');
}

function blogFlagNewComment()
{
	document.writeln('<img src="/__files/img/icons/newcom.gif" alt="Inlägget har nya kommentarer" width="15" height="10" border="0" title="Inlägget har nya kommentarer">');
}

function blogDeleteEntry(bid,ret)
{
  if( confirm("Vill du verkligen ta bort inlägget?") )
  {
    document.location = '/__batch/blogdelete.html?id=' + bid + '&ret=' + escape(ret);
  }
}

function blogDeleteComment(bid,rid,ret)
{
  if( confirm("Vill du verkligen ta bort kommentaren?") )
  {
    document.location = '/__batch/blogcommentdelete.html?id=' + bid + '&rid=' + rid + '&ret=' + escape(ret);
  }
}

function blogDeleteCat(cid,ret)
{
  if( confirm("Vill du verkligen ta bort forumet och alla dess diskussioner?") )
  {
    document.location = '/__batch/blogcategorydelete.html?id=' + cid + '&ret=' + escape(ret);
  }
}

function blogDeleteItem(iid,bid,ret)
{
  if( confirm("Vill du verkligen ta bort filen/bilden?") )
  {
    document.location = '/__batch/bloggalleryitemdelete.html?id=' + iid + '&bid=' + bid + '&ret=' + escape(ret);
  }
}

function blogDeleteGalleryItemComment(iid,rid,ret)
{
  if( confirm("Vill du verkligen ta bort kommentaren?") )
  {
    document.location = '/__batch/bloggalleryitemcommentdelete.html?id=' + iid + '&rid=' + rid + '&ret=' + escape(ret);
  }
}

function blogEditCat(cid)
{
  window.open('/mina-sidor/skapa/kategori/?id=' + cid,'catedit','resizeable=yes,scrollbars=yes,status=no,width=340,height=280');
}

function blogEditItem(iid,text)
{
  var com = prompt("Kommentar till bilden",text);
  if( com != null )
  {
    subreq_obj = document.getElementById("itemdesc");
    subreq_makeRequest('/__batch/editimagedesc.html?id=' + iid + '&text=' + escape(com),0);
  }
}

function blogRotateItem(iid,dir)
{
  subreq_obj = document.getElementById("showimage");
  goodMessage('Bilden roteras... vänta!');
  subreq_makeRequest('/__batch/rotateimage.html?id=' + iid + '&dir=' + dir,5);
}

function blogChangeVideoTip()
{
  // Google 3750097931738895654
  // YouTube XKPvHWpdoaI

  var box = document.forms['blogform'].blognum;
  var boxvalue = box.options[box.selectedIndex].value;
  var obj = document.getElementById("videotip");

  if( boxvalue == 1 )
  {
    obj.innerHTML = 'XKPvHWpdoaI';
  }
  else
  {
    obj.innerHTML = '3750097931738895654';
  }
}
