﻿// JScript File

function goto_rate_page(id,cat,rate)
{

    var page
    if (cat=="0" || cat==0) page="articles.aspx"
    if (cat=="1" || cat==1) page="cartoons.aspx"
    if (cat=="2" || cat==2) page="jokes.aspx"
    if (cat=="3" || cat==3) page="novels.aspx" 
    if (cat=="4" || cat==4) page="poems.aspx"     


  window.location="ratelink.aspx?id="+ parseInt(id) +"&cat="+ parseInt(cat) +"&rateval="+ parseInt(rate) +"&prev="+ page
}

function comment_box()
{
	    tinyMCE.init({
		    mode : "textareas",
		    theme : "advanced",
		    skin : "o2k7",
		    plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

		    // Theme options
		    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,forecolor,emotions,",
		    theme_advanced_buttons2 : "",
		    theme_advanced_buttons3 : "",

		    theme_advanced_toolbar_location : "top",
		    theme_advanced_toolbar_align : "left",
		    theme_advanced_statusbar_location : "bottom",
		    theme_advanced_resizing : true,

		    // Example content CSS (should be your site CSS)
		    content_css : "css/content.css",

		    // Drop lists for link/image/media/template dialogs
		    template_external_list_url : "lists/template_list.js",
		    external_link_list_url : "lists/link_list.js",
		    external_image_list_url : "lists/image_list.js",
		    media_external_list_url : "lists/media_list.js",
		    relative_urls : true,
            remove_script_host : false,
            document_base_url : "http://www.phoewa.com/",
            convert_urls : false,

		    // Replace values for the template plugin
		    template_replace_values : {
			    username : "Some User",
			    staffid : "991234"
		    }
	    });
}

//function goto_rate_page(id,link_page,cat,rate)

function post_box()
{
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		skin : "o2k7",
		skin_variant : "black",
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",

		theme_advanced_fonts : "Arial=arial,Arial Black=arial black,Courier New=courier new,Tahoma=tahoma,Times New Roman=times new roman,Verdana=verdana,Zawgyi-One=Zawgyi-One,zawgyi1=zawgyi1",

		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "bullist,numlist,|,sub,sup,|,charmap,emotions,iespell,|,link,unlink,image,code,|,forecolor,backcolor",		
		theme_advanced_buttons3 : "",		                             
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example word content CSS (should be your site CSS) this one removes paragraph margins
		content_css : "css/word.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",
		relative_urls : true,
        remove_script_host : false,
        document_base_url : "http://www.phoewa.com/",
        convert_urls : false,

		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
}

function change()
{
    var val = document.getElementById("sel_cat").value
    if ( val == "3" || val==3 ) 
    {
        document.getElementById("div_desc").style.display="block";
     }else
     {
        document.getElementById("div_desc").style.display="none";     
     }
}

function aa()
{
    alert("aa")
}

/// Font theme
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);


var min=8;
var max=16;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}