﻿ 
   
 //for localhost
 //var wsUrl =  "/Dosti/AjaxWebService/AjaxService.asmx/";     
 
 //for live
 var wsUrl =  "/AjaxWebService/AjaxService.asmx/";     
 

function CallClick(event,obj)
{
   if(event.keyCode == 13)
   {
   
       document.getElementById(obj).click();
       return false;
   }
   else
       return true;
}

function confirm_delete()
{
    if (confirm("Are you sure you want to delete this record ?")==true)
    return true;
    else
    return false;
}

function textMaxLength(obj, maxLength, evt)
{
    var charCode=(evt.which) ? evt.which : event.keyCode
    var max = maxLength - 1;
    var text = obj.value;
    if(text.length > max)
    {
        var ignoreKeys = [8,46,37,38,39,40,35,36];
        for(i=0;i<ignoreKeys.length;i++)
        {
            if(charCode==ignoreKeys[i])
            {
                return true;
            }
        }
        return false;
    }
    else
    {
        return true;
    }
}
 
function SetColor(objid)
{
//    var obj = document.getElementById(objid);
//    if(obj.value.replace(/ /g,'').length == 0) obj.style.background="lemonchiffon"; 
//    else obj.style.background="white";
}

  function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

/* added for Language Switching */

function SetLanguageID(id,code)
{if(id > 0)window.location.href='index.aspx?id='+ id + '&code=' + code;}


function SelectMultiple(ctlId,lblId)
{
   	var control = document.getElementById(ctlId);
	var strSelText='';
				
	for(var i = 0; i < control.length; i++)
	{ 				    
		if(control.options[i].selected)
		{					    					    					    					    					   
			strSelText +=control.options[i].text+', ' ;						
		}					
	}
	if (strSelText.length>0)
		strSelText=strSelText.substring(0,strSelText.length-2);
					
	if (strSelText.length==0)
	{
		if(control.options[0].selected)
		{
			strSelText =control.options[0].text ;
		}
	}
					
	var ddLabel = document.getElementById(lblId); 
	ddLabel.innerHTML = strSelText;
	ddLabel.innerText  = strSelText;
	ddLabel.title = strSelText;												
}



function openWindowCenterScreen(url,name,height,width,hasScroll,hasResize)
{
try
    {
  var sBars='no';
  var sResise='no';
  if(hasScroll!=null)
    sBars=hasScroll
  if(hasResize!=null)
    sResise=hasResize  
  var w =width; //32;
  var h =height; //96;
  var wleft = (screen.width - w) / 2;
  var wLinks = (screen.height - h) / 2;
  var win = window.open(url,name,
                            'width=' + w + ', height=' + h + ', ' +
                            'left=' + wleft + ', Links=' + wLinks + ', ' +
                            'location=no, menubar=no, ' +
                            'status=no, toolbar=no, scrollbars=' + sBars + ', resizable=' + sResise );
  // Just in case width and height are ignored
  //win.resizeTo(w, h);
  // Just in case left and Links are ignored
  win.moveTo(wleft, wLinks);
  win.focus();    
    }
    catch(e)
    {
    }
}
 

function checkString(id){
	var sfrnd = document.getElementById(id);
	if(sfrnd.value == "Search Friends"){
		sfrnd.value="";
		sfrnd.className="wdf_grayTxt";
	}
	else if(sfrnd.value == ""){
		sfrnd.className="wdf_grayTxt";
		sfrnd.value ="Search Friends";
	}
}

function checkString2(id){
	var iead = document.getElementById(id);
		if(iead.value == "emailid@domain.com"){
		iead.value="";
		iead.className="wdf_grayTxt";
	}
	else if(iead.value == ""){
		iead.className="wdf_grayTxt";
		iead.value ="emailid@domain.com";
	}
}

function checkString3(id){
	var crntsts = document.getElementById(id);
		if(crntsts.value == "What are u doing right now?"){
		crntsts.value="";
		crntsts.className="wdf_inputStatBox wdf_grayTxt";
	}
	else if(crntsts.value == ""){
		crntsts.className="wdf_inputStatBox wdf_grayTxt";
		crntsts.value ="What are u doing right now?";
	}
}

 



   function saveusershout(txtUserShout,userID,divsavecancel,hdnPrevUserShout)
    {    
     
      var txtus = $('#'+txtUserShout+'').val();
      var hdnprevus = $('#'+hdnPrevUserShout+'').val();
      
      if(txtus.trim()=='') {alert('Please enter the status'); return false; }
      
      if(txtus.trim() == "What are u doing right now?"){ alert('Please enter the status'); return false; }
      
      if(hdnprevus.toLowerCase()==txtus.toLowerCase()) { return false;}
      
      $('#'+divsavecancel+'').hide(); 
      
      $.ajax({

      type: "POST",

      url: wsUrl+"AddUserShout" ,
      
      data: '{shoutText: "' + $('#'+txtUserShout+'').val() + '",userID: "' +  userID + '"}',

      contentType: "application/json; charset=utf-8",

      dataType: "json",
        
      success: function(response) {   
                                    if(response==true) {                                                                        
                                    
                                    $('#'+hdnPrevUserShout+'').val(txtus);  
				    objStat.logActivity('Status Update','');                                  
                                    }      
                                  },
      failure: function(msg)      { }
         
    });
    
    return false;
    }    