
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

window.onload = function()
{
var x = getCookie('ImeshVisitor');
//alert(x);
//alert(typeof x);
if (x!=null) {
//alert(x);
//alert("null->");
var y=decodeURIComponent(x);
//alert(y);
//alert(y.value);
var z=y.split('|');
for (i = 0; i < z.length; i++) {
 //console.log(z[i]);
var det=z[i].split('=');
if(det[0] == "glid")
{
glid=det[1];
//alert(det[0]);
}
if(det[0]=="fn")
{
name=det[1];
//alert(name);
}
if(det[0]=="em")
{
email=det[1];
//alert(email); 
}
if(det[0]=="mb1")
{
mobile=det[1];
//alert(mobile);  
}
if(det[0]=="co")
{
company=det[1];	
}
}
var yname1=document.getElementById("yname");
var email1=document.getElementById("email");
var phone1=document.getElementById("phone");
var cname1=document.getElementById("cname");

var yname2=document.getElementById("yname1");
var email2=document.getElementById("email1");
var phone2=document.getElementById("phone1");
var cname2=document.getElementById("cname1");


if(yname2 != null)
{
document.getElementById("yname1").value=name;
}
if(email2 != null)
{
document.getElementById("email1").value=email;
}
if(phone2 !=null)
{
document.getElementById("phone1").value=mobile;
}
if(cname2!=null)
{
document.getElementById("cname1").value=company;
}


if(yname1 != null)
{
document.getElementById("yname").value=name;
}
if(email1 != null)
{
document.getElementById("email").value=email;
}
if(phone1 !=null)
{
document.getElementById("phone").value=mobile;
}
if(cname1!=null)
{
document.getElementById("cname").value=company;
}

!function(f,b,e,v,n,t,s){
if(f.fbq)return;
n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;
n.version='2.0';n.queue=[];
t=b.createElement(e);t.async=!0;
t.src=v;
s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}

(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '1000024446685311', {
//alert(email);
em:email
});
fbq('track', 'PageView');

//test(glid,email,mobile);
}
//alert(a);
if(x==null)
{
document.getElementById("cook").innerHTML="Welcome,"+" "+"Guest";		
}
else
{
document.getElementById("cook").innerHTML="Welcome,"+" "+name;
}

var message=document.getElementById("combox");
if (message != null) {
//alert("not nulll");
document.getElementById("combox").value="Your feedback is Important to us";
//res = message.value;
//alert(res);
}


function test(glid,email,mobile) {
    var d=0;
   // alert("hello-0");
       myFunction(function(d) {
           //processing the data
         console.log(d);
       },glid,email,mobile);
  // alert("hello3");
   }
//{ A1984 : 1, A9873 : 5, A1674 : 2, A8724 : 1, A3574 : 3, A1165 : 5 }
function myFunction(callback,glid,email,mobile) {
 // alert("hello 1.1");
 // alert(glid);
    var myKeyVals = { glid : glid,email : email,mobile :mobile}
     //alert("hello 1.2");
    $.ajax({
        url: 'https://www.indiamart.com/bigbrands/db_bigbrands.php',
        data: myKeyVals,
        success: function (resp) {
            data = resp;
            callback(data);
        },
        error: function () {}
    }); // ajax asynchronus request 
    // return data from the ajax request
//alert("hello2");

}

}








