﻿// JScript File

function bookmarksite()
{

    var url=document.location.href;
    var title=document.title;
    
    if (document.all)
    window.external.AddFavorite(url, title);
    
    else if (window.sidebar)
    window.sidebar.addPanel(title, url, "");
}

//Trim The String
function fnStringTrim(inputString)
{
	var retValue = inputString;
	
	
	// Check for spaces at the beginning of the string
	var ch = retValue.substring(0,1);
	while (ch == " ")
	{                                                  
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	
	// Check for spaces at the end of the string
	ch = retValue.substring(retValue.length-1, retValue.length); 
	while (ch == " ")                                           
	{ 
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	return retValue; // Return the trimmed string back to the user
}


function fnValidateEmail(strInputText)
{

    if(strInputText.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)!=-1)
    return true;
    else return false;
}


// XML http object for Ajax
function GetXmlHttpObject()
{  
	//alert("Using AJAX!"); 
	//xmlHttp=GetXmlHttpObject()
	var xmlHttp=null;
	try
	{ 
		// Firefox, Opera 8.0+, Safari 
		xmlHttp=new XMLHttpRequest();  
	}
	catch (e)
	{  //	alert("Using AJAX on IE!");  
		// Internet Explorer  
		try
		{    
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");   
		}
		catch (e)
		{  	
			//alert("Using AJAX! on IE-5"); 
			try
			{  
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
			}
			catch (e)
			{  
				alert("Your browser does not support AJAX!"); 
				return false;      
			}  
		}
	}
		return xmlHttp;
}



function fnGetEnterKey(field, event, CID)
{  
 
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (keyCode == 13)
     {
        document.getElementById(CID).click();
        return false;
    }	
}







 // Global variable that using across the page.
var strGlobalAvglblID, strGlobalIncrlblID, strGlobalDecrlblID, strGlobalDivMessageID, strGlobalPollAnswerdivID;
        
        function fnIncrementPlusCount(strMyVal)
            {
                // alert("strMyVal" + strMyVal);
             
              var arrMyVal=strMyVal.split("||");
              var strMyLabels = arrMyVal[0];
              var strMyCelebsID = arrMyVal[1];
           
              strGlobalIncrlblID = strMyLabels;
            
              
              xmlHttp=GetXmlHttpObject()
				if (xmlHttp==null)
				{
					alert ("Your browser does not support AJAX!");
					return;
				} 
				xmlHttp.onreadystatechange = handlePlusStateChange;
			    var  mydate = new Date();
				var url="/AjaxIncrementCount.aspx";
				url=url+"?strValue="+strMyCelebsID +"&strType=Plus&mydate=" +mydate.getTime();

				//xmlHttp.open("post","ajaxresponsepage.aspx",true);
				xmlHttp.open("GET",url,true);
				xmlHttp.send(null);
				
            }

            // This method will be called after the method has been executed
            // and the result has been sent to the client.

           function handlePlusStateChange() 
            {

                if(xmlHttp.readyState == 4) 
                {
                    if(xmlHttp.status == 200) 
                    {
  
                        // alert("xmlHttp.responseText :" + xmlHttp.responseText);
                          var strResponse = xmlHttp.responseText;
                          var arrMyResponse = strResponse.split("~");          
                        
                          
                          var strAvrgCount = arrMyResponse[0];   // Average Vote
                          var strMyDivID = arrMyResponse[1];    // getting control id for Message Container
                          var strMessageContent = arrMyResponse[2]; // getting the content for message
                          
                          // this is the case of first time Vote
                          if(strAvrgCount != "null")
                          {
                           // document.getElementById(strGlobalAvglblID).innerHTML =  strAvrgCount;
                            
                            var intPlusCount  = parseInt(document.getElementById(strGlobalIncrlblID).innerHTML);
                            var intIncrementCount = intPlusCount + 1;
                            //alert("intIncrementCount" + intIncrementCount);
                            document.getElementById(strGlobalIncrlblID).innerHTML = intIncrementCount;
                          }              
                          
                         
                          strGlobalDivMessageID = strMyDivID;
                          var strDivMessageContentID =  strGlobalDivMessageID.replace("divMessage", "divMessageContent"); //  getting control id for MessageContent Container
                           //alert("strDivMessageContentID " + strDivMessageContentID);
                        
                          document.getElementById(strGlobalDivMessageID).style.display = "block";
                          document.getElementById(strDivMessageContentID).innerHTML =  strMessageContent;
                          var t=setTimeout("fnMakeInvisible();",1000) // hiding the message after 2 sec
                    }
                }
            }
            
            function fnMakeInvisible()
            {
                 //alert('Welcome to dotnetheaven.com : ' + strGlobalDivMessageID);    
              
                 document.getElementById(strGlobalDivMessageID).style.display = "none";
                 
            }
            
            

    
      
      
        
        function fnIncrementMinusCount(strMyVal)
            {
                // alert("strMyVal" + strMyVal);
             
              var arrMyVal=strMyVal.split("||");
              var strMyLabels = arrMyVal[0];
              var strMyCelebsID = arrMyVal[1];
         
              strGlobalDecrlblID = strMyLabels;
             
              
                xmlHttp=GetXmlHttpObject()
				if (xmlHttp==null)
				{
					alert ("Your browser does not support AJAX!");
					return;
				} 
				xmlHttp.onreadystatechange = handleMinusStateChange;
			
			    var  mydate = new Date();
				var url="/AjaxIncrementCount.aspx";
				url=url+"?strValue="+strMyCelebsID +"&strType=minus&mydate=" +mydate.getTime();

				//xmlHttp.open("post","ajaxresponsepage.aspx",true);
				xmlHttp.open("GET",url,true);
				xmlHttp.send(null);
            }

            // This method will be called after the method has been executed
            // and the result has been sent to the client.

            function handleMinusStateChange()
            {
                if(xmlHttp.readyState == 4) 
                {
                    if(xmlHttp.status == 200) 
                    {
                         // alert("xmlHttp.responseText :" + xmlHttp.responseText);
                          var strResponse = xmlHttp.responseText;
                          var arrMyResponse = strResponse.split("~");          
                        
                          
                          var strAvrgCount = arrMyResponse[0];   // Average Vote
                          var strMyDivID = arrMyResponse[1];    // getting control id for Message Container
                          var strMessageContent = arrMyResponse[2]; // getting the content for message
                          
                          // this is the case of first time Vote
                          if(strAvrgCount != "null")
                          {
                            //document.getElementById(strGlobalAvglblID).innerHTML =  strAvrgCount;
                            
                            var intMinusCount  = parseInt(document.getElementById(strGlobalDecrlblID).innerHTML);
                            var intDecrementCount = intMinusCount + 1;
                            //alert("intIncrementCount" + intIncrementCount);
                            document.getElementById(strGlobalDecrlblID).innerHTML = intDecrementCount;
                          }              
                          
                         
                          strGlobalDivMessageID = strMyDivID;
                          var strDivMessageContentID =  strGlobalDivMessageID.replace("divMessage", "divMessageContent"); //  getting control id for MessageContent Container
                           //alert("strDivMessageContentID " + strDivMessageContentID);
                        
                          document.getElementById(strGlobalDivMessageID).style.display = "block";
                          document.getElementById(strDivMessageContentID).innerHTML =  strMessageContent;
                          var t=setTimeout("fnMakeInvisible();",1000) // hiding the message after 2 sec
                    }
                }
            }
            
            
            
            
            
function fnIncrementAbuseCount(strMyVal)
{
     //alert("strMyVal" + strMyVal);
 
 

  var answer = confirm ("Do you want to report this as abusive..");
  if(answer)
   {
        xmlHttp=GetXmlHttpObject()
	    if (xmlHttp==null)
	    {
		    alert ("Your browser does not support AJAX!");
		    return;
	    } 
	    xmlHttp.onreadystatechange = handleCommentStateChange;
        var  mydate = new Date();
	    var url="/AjaxIncrementAbuseCount.aspx";
	    url=url+"?strValue="+strMyVal +"&mydate=" +mydate.getTime();

	    //xmlHttp.open("post","ajaxresponsepage.aspx",true);
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	
}


function fnIncrementPollAbuseCount(strMyVal)
{
     //alert("strMyVal" + strMyVal);
 
 

  var answer = confirm ("Do you want to report this as abusive..");
  if(answer)
   {
        xmlHttp=GetXmlHttpObject()
	    if (xmlHttp==null)
	    {
		    alert ("Your browser does not support AJAX!");
		    return;
	    } 
	    xmlHttp.onreadystatechange = handleCommentStateChange;
        var  mydate = new Date();
	    var url="/AjaxIncrementAbuseCount.aspx";
	    url=url+"?strPollValue="+strMyVal +"&mydate=" +mydate.getTime();
	    //alert(url);
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	
}

// This method will be called after the method has been executed
// and the result has been sent to the client.

function handleCommentStateChange() 
{

    if(xmlHttp.readyState == 4) 
    {
        if(xmlHttp.status == 200) 
        {

            // alert('This comment Recorded as Abuse , Thanks for your response')
        }
    }
}  


 function fnStarOneShowHide(strShowCntrl,strHideCntrl)
    {
         //alert('Welcome to dotnetheaven.com : ' + strGlobalDivMessageID);    
      
        // document.getElementById(strShowCntrl).style.display = "block";
         //document.getElementById(strHideCntrl).style.display = "none";
         
           $('#'+ strHideCntrl).hide('slow');
           $('#'+ strShowCntrl ).show('slow');


       }



       function fnInsertPollVote(strPollId, strAnsID, strPollAnswerdivID) {
           //alert("strPollId : " + strPollId);
          // alert("strAnsID : " + strAnsID);



           strGlobalPollAnswerdivID = strPollAnswerdivID;

           xmlHttp = GetXmlHttpObject()
           if (xmlHttp == null) {
               alert("Your browser does not support AJAX!");
               return;
           }
           xmlHttp.onreadystatechange = handleInsertPollStateChange;
           var mydate = new Date();
           var url = "/ajaxpollresult.aspx";
           url = url + "?pollid=" + strPollId + "&ansid=" + strAnsID + "&mydate=" + mydate.getTime();

           //xmlHttp.open("post","ajaxresponsepage.aspx",true);
           xmlHttp.open("GET", url, true);
           xmlHttp.send(null);

       }

       // This method will be called after the method has been executed
       // and the result has been sent to the client.

       function handleInsertPollStateChange() {

           if (xmlHttp.readyState == 4) {
               if (xmlHttp.status == 200) {

                   var strResponse = xmlHttp.responseText;
                   document.getElementById(strGlobalPollAnswerdivID).style.display = "block";
                   document.getElementById(strGlobalPollAnswerdivID).innerHTML = strResponse;
                   
               }
           }
       }        
           
   

