﻿// JScript File

var xmlHttp;
var username;
var imagepath;


function add_friend(userid,friendid,name,image)
{
   username=name;
   imagepath=image;
   xmlHttp=GetXmlHttpObject();
   if (xmlHttp==null)
   {
     alert("Your browser does not support AJAX!");
     return;
   } 
   url="http://www.slideworld.com/add_friend.ashx";
   url=url+"?userid="+userid;
   url=url+"&friendid="+friendid;
   url=url+"&sid="+Math.random();  
   xmlHttp.onreadystatechange=stateChangedaddfriend;
   xmlHttp.open("GET",url,true);
   xmlHttp.send(null);
}

function stateChangedaddfriend() 
{ 
    if (xmlHttp.readyState==1)
     {  	  
	  //document.getElementById('img_owner').src="http://www.slideworld.org/IMAGES/ajaxLoader.gif";  
      
     }
    if (xmlHttp.readyState==4)
     {   
     
     document.getElementById('div_username').innerHTML="<b>"+username+"</b> is now your friend.";
     document.getElementById('div_username').style.display="block";
      document.getElementById('img_owner').src="http://www.slideworld.com/thumbnail2.aspx?width=60&file="+imagepath;
     //alert(xmlHttp.responseText);
     }
}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function setRating(ArticleID,Rating, bit)
 {
       for(i=0;i<5;i++)
        {
           var loop=i+1;
           var a=document.getElementById("RatingIcon-" + loop );
           if(i<Rating)
           {            
               a.className="icncuteon";             
           }
           else
           {
              a.className="icncuteoff";
           }
        } 
        //alert("hi hello")        
        ajaxpage_get('../rating_ajax.ashx?Rating='+ Rating +'&ArticleID='+ArticleID, 'spRate', '','');
   
   }
  function showNotes(val1)
  {
       if(val1==true)
       { 
            document.getElementById("notes").style.display = "block";
            document.getElementById("notesController1").style.display = "block";
            document.getElementById("notesController").style.display = "none";  
       }
       else 
       {  
            document.getElementById("notes").style.display = "none";
            document.getElementById("notesController").style.display = "block";
            document.getElementById("notesController1").style.display = "none"; 
       }
      return false;
  }
  function show_sharing_options(val1)
  {
       if(val1==true)
       { 
            document.getElementById("share").style.display = "block";
            document.getElementById("shareController1").style.display = "block";
            document.getElementById("shareController").style.display = "none";  
       }
       else 
       {  
            document.getElementById("share").style.display = "none";
            document.getElementById("shareController").style.display = "block";
            document.getElementById("shareController1").style.display = "none"; 
       }
      return false;
  }
 function lnk11(copyField)
 {
      var copytext=document.getElementById(copyField);
      document.getElementById(copyField).focus();
      document.getElementById(copyField).select();
      var CopiedTxt = copytext.value;
      window.clipboardData.setData("Text",CopiedTxt); 
      return false;
 }
  function validate()
    {
         if(document.getElementById("txt_comment").value == "")
         {
         alert("Please enter some comments.");
         document.getElementById("txt_comment").focus();
         return false;
         } 
     }
  function postcomments()
  {
  //alert("fdgfdgdf");
  document.getElementById("post_comment").style.display = "block";
   document.getElementById("post_button").style.display = "none";
  }
  function Canclecomments()
  {
  //alert("fdgfdgdf");
   document.getElementById("post_comment").style.display = "none";
   document.getElementById("post_button").style.display = "block";
  }

