﻿// JScript File

var divName;
var xmlHttp;

var searchTerm;
var searchType;



//Status 0 : Suggest Admin with the available key text fetched from database.


//function calljs() // hdSitetype,hdIsDisPpcAdd,hdPpcCustomdisplay,hdDisPpcxmlSource,keylabels,keywords
function calljs(hdSitetype,hdIsDisPpcAdd,hdPpcCustomdisplay,hdDisPpcxmlSource,keylabels,keywords)
{
//alert("aa");
//alert("hdSitetype  - " + hdSitetype)
//alert("hdIsDisPpcAdd - " +  hdIsDisPpcAdd) 
//alert("hdPpcCustomdisplay - " + hdPpcCustomdisplay)
//alert("hdDisPpcxmlSource - " + hdDisPpcxmlSource)
//alert("keylabels - " + keylabels)
//alert("keywords - " + keywords )

var url="";
var setRadio = "0";
xmlHttp=GetXmlHttpObject()
    if(xmlHttp==null)
    {
      alert ("Browser does not support HTTP Request")
      return false;
    }
    //Status : 0 suggest Admin with serch terms
    
    // Checking has been done for value whether the send parameters are true or false.....
    
    if(hdSitetype == "0")
    {     
      return false;
    }
    if(hdIsDisPpcAdd == "0")
    {     
      return false;
    }
    if(hdPpcCustomdisplay == "0")
    {      
      return false;
    }
    if(hdDisPpcxmlSource != "myxmlsource")
    {      
      return false;
    }
    if((keylabels == "0") || (keylabels == ""))
    {      
      return false;
    }
    if((keywords == "0") || (keywords == ""))
    {      
      return false;
    }     

    url="testxml.aspx?keylabels="+keylabels +"&keywords="+keywords;  
    
    //alert(url);
    xmlHttp.onreadystatechange=stateChanged
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    return false;
}
function stateChanged()
{
        if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
        {
//        alert(xmlHttp.responseText);
        oldDiv = document.getElementById("ppcdiv");
        newDiv = document.createElement(oldDiv.tagName);
        newDiv.id = oldDiv.id;
        newDiv.className = oldDiv.className;
        newDiv.innerHTML = xmlHttp.responseText;
      //  alert(newDiv.innerHTML);
        oldDiv.parentNode.replaceChild(newDiv, oldDiv);

        //document.getElementById("serchresult").innerHTML="";
        }
}

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;
}






