﻿function ArticleClickTracking(sourceurl,TargetURL,ip,sessionID,email,page,section,sub_section,Target)
{
        /*alert(sourceurl);
        alert(TargetURL);
        alert(ip);
        alert(sessionID);
        alert(email);
        alert(page;)
        alert(section);
        alert(sub_section);
        alert(Target);*/
                if (page=='' ||page== null)
        page='Home'
         $.ajax({
        type: "POST",    
        
        //url: "http://www.milletapes.com/Homev2.aspx/TrackUserClick",    
        url: "http://www.milletapes.com/WS_BGProcess.asmx/TrackUserClick",
        data: "{'SourceURL':'"+sourceurl+"','TargetURL':'"+TargetURL+"','IPAddress':'"+ip+"','SessionID':'"+sessionID+"','Page':'"+page+"','Section':'"+section+"','Subsection':'"+sub_section+"','Target':'" + Target  + "'}",    
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
       

        },
         error: function(XMLHttpRequest, textStatus, errorThrown) 
        {            
            /*var jsonError = JSON.parse(XMLHttpRequest.responseText);            
            alert('Error'+jsonError.d);*/
        }
      });
      
      if(section == "Découvrez" && sub_section == "Region")
      {     
         document.getElementById("ctl00_ContentPlaceHolder1_hdnRegionName").value = Target
         //alert(document.getElementById("ctl00_ContentPlaceHolder1_hdnRegionName").value);
         document.getElementById("ctl00_ContentPlaceHolder1_btnHomeCallPage").click();
      }
      else
      {
        //Check if the details page call is from top pick or events click 
        if(section == "Découvrez" || section == "Cette semaine")
        {  
          CallDetailsPage(Target) //This function is in master page
         // document.getElementById("ctl00_btnDetailsCallPage").click();          
         //var btnName = $get("<%=btnDetailsCallPage.ClientID%>").name;
          //__doPostBack(btnName,Target);         
        }
        else
        {
          window.location.href=TargetURL;      
        }
      }           


}


 function ClikTracking(sourceurl,TargetURL,ip,sessionID,email,page,section,sub_section,Target,RowNo,ArticleID,Mode,Area,Keyword,CatIDs)    {
        
        /* alert(sourceurl);
        alert(TargetURL);
       alert(ip);
        alert(sessionID);
        alert(email);
        alert(page);
        alert(section);
        alert(sub_section);
        alert(Target);*/
	/*alert(Mode);
    alert(Area);
    alert(ArticleID);
    //alert(CatIDs);
    //alert(RowNo);
    //alert(Keyword);
*/               
        $.ajax({
        type: "POST",
        /* For Local */
        //url: "Homev2.aspx/getData",    
        /* For Stage Uncomment the below line and comment the above line */
        url: "http://www.milletapes.com/Homev2.aspx/getData",    
    data: "{'SourceURL':'"+sourceurl+"','TargetURL':'"+TargetURL+"','IPAddress':'"+ip+"','SessionID':'"+sessionID+"','Page':'"+page+"','Section':'"+section+"','Subsection':'"+sub_section+"','PageIndex':" + ArticleID  + ", 'PageSize':'" +  Mode + "', 'Area':'"+ Area +"', SortColumn:"+RowNo+", keyword:'"+Keyword+"', CatIDs:'"+CatIDs+"'}",       
   contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
  /* For Local */   
//window.location.href=TargetURL;
/* For Stage unComment the Below Line and Comment the one above */
  if(section == "Listing")
        {  
          CallDetailsPage(Target) //This function is in master page          
        }
        else
        {
window.location.href="http://www.Milletapes.com/Article/"+Target;
}
        },
         error: function(XMLHttpRequest, textStatus, errorThrown) 
        {            
       /* alert('error');
            var jsonError = JSON.parse(XMLHttpRequest.responseText);            
            alert('Error'+jsonError.d);*/
        }
      });
     }
     
 
 function pageTracking(pageName)
{   
    
    if (pageName!='' || pageName!='undefined')
{

       $.ajax({
        type: "POST",
        /* For Local */
        //url: "WS_BGProcess.asmx/pageTracking",    
        /* For Sandbox Uncomment the below line and comment the above line */
        url: "http://www.milletapes.com/WS_BGProcess.asmx/pageTracking",    
    data: "{'PageName':'"+pageName+"'}",       
   contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
        //alert('Done');
        },
         error: function(XMLHttpRequest, textStatus, errorThrown) 
        {            
        /*alert('error');
            var jsonError = JSON.parse(XMLHttpRequest.responseText);            
            alert('Error'+jsonError.d);*/
        }
      });
     }
     }