﻿// JScript File

var xmlHttp;
var username;
var imagepath;
function showemailbox(elementId,spanid)
{
      if( document.getElementById(elementId).checked==true)
      {
       document.getElementById(spanid).style.display='block';
      }
      else
      {
       document.getElementById(spanid).style.display='none';
      }
}
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.org/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.org/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_name").value == "")
         {
             alert("Please enter your name.");
             document.getElementById("txt_name").focus();
             return false;
         } 
         if(document.getElementById("txt_email").value == "")
         {
             alert("Please enter your Email.");
             document.getElementById("txt_email").focus();
             return false;
         }
//         else
//         {
//           emailValid('txt_email');
//         }
         if(document.getElementById("txt_comment").value == "")
         {
             alert("Please enter some comments.");
             document.getElementById("txt_comment").focus();
             return false;
         }          
   }
   
  function validate_Twitt()
  {
        
         
         if(document.getElementById("txt_twitteruser").value == "")
         {
             alert("Please enter Your Twitter UserName.");
             document.getElementById("txt_twitteruser").focus();
             return false;
         } 
         
         if(document.getElementById("txt_twitterpass").value == "")
         {
             alert("Please enter Your Twitter Password.");
             document.getElementById("txt_twitterpass").focus();
             return false;
         }
          
         if(document.getElementById("Textarea1").value == "")
         {
             alert("Please enter some comments.");
             document.getElementById("Textarea1").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";
  }
  
  function emailValid(obj){
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj.value))
	{
	    return (true)	
	}
	else
	{
	    alert("This is not a valid E-Mail id.");
		return (false);
	}
}