﻿function DoCallback(url, params)
{
	// url:    URL to invoke
	// params: string object to pass to the remote URL
	//Add some parameters to the query string	
	var pageUrl = url+'?'+params+'&'+Math.random();
	var xmlHttp=null;
	try
	{
		//Mozilla Browsers		
		//xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
		xmlHttp=new XMLHttpRequest();

	}
	catch (e)
	{
		try
		{
			//IE
			//xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");

			//xmlRequest = new XMLHttpRequest();
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");			
		}
		catch (e)
		{
			//Something else that won't work with this code...
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

			//xmlRequest=false;
		}
	}
	// Post our XmlRequest and get our desired string
	xmlHttp.open("GET", pageUrl, false);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	
	xmlHttp.send(null);
	// Return the XmlHttp object
	return xmlHttp;
}
function AddItemToCombo(ComboName,ComboValue,ComboText)
{
	var objCmbOptions=document.getElementById(ComboName);
	objCmbOptions.options[objCmbOptions.options.length] = new Option(ComboText,ComboValue);
}

function ClearComboBox(ComboName)
{
    var objCmbOptions=document.getElementById(ComboName);
	objCmbOptions.options.length=0;
}

var NextRecPosition=0;
function GetNodeValue(FullText,NodeName)
{
	NextRecPosition=0;
	var LeftText="<" + NodeName + ">";
	var EndText="</" + NodeName + ">";
	var FString=new String(FullText);
	var sPos=0,EPos=0;
	sPos = FString.indexOf(LeftText);
	if(sPos==-1)
	{
		NextRecPosition=0;
		return '';
	}
	else
	{
		sPos=sPos+LeftText.length;
		ePos=FString.indexOf(EndText);
		if(ePos==-1)
		{
			return '';
			NextRecPosition=0;
		}
		else
		{
			NextRecPosition=ePos + EndText.length; 
			return FString.substring(sPos ,ePos);
		}  
	 }
}

function FilledCombo(strCountry,objCombo)
{
    
    var pcountry = strCountry.options[strCountry.selectedIndex].text;
	var xml=new DoCallback('/XMLResponse.aspx','command=country&eventArgument=' + pcountry);
	var resp=xml.responseText;
	
	ClearComboBox(objCombo);
	AddItemToCombo(objCombo,0,'...Select Any City...');
	while (1)
	{
		var intQueNo=GetNodeValue(resp,"City");
		var varQueDesc=GetNodeValue(resp,"City");
		GetNodeValue(resp,"Table");
		if(NextRecPosition==0)
			break;
		else
		{
			AddItemToCombo(objCombo,intQueNo,varQueDesc);
			resp=resp.substring(NextRecPosition,resp.length);
		}
	}
}

// ADDED By ATS ON 30-Jan-2007
// Modified on 31-Jan-2007
// For getting weather forecast
function GetWhether(strCountry,strCity)
{
    
	var xml=new DoCallback('XMLResponse.aspx','command=Temp&eventArgument='+strCountry.value+'&City='+strCity.value); 
	var resp=xml.responseText;
	var Temperature;
	var Wind;
	var Result;
	if(GetNodeValue(resp,'Location')!='')
	{
	    Result = 'Location: ' + GetNodeValue(resp,'Location')+'\n'
	    +'Time: ' + GetNodeValue(resp,'Time') +'\n'
	    +  'Wind:' + GetNodeValue(resp,'Wind')+'\n'
	    +  'Visibility: ' + GetNodeValue(resp,'Visibility')+'\n'
	    +  'Sky Conditions: ' + GetNodeValue(resp,'SkyConditions')+'\n'
	    +  'Temperature: ' + GetNodeValue(resp,'Temperature')+'\n'
	    +  'Dew Point: ' + GetNodeValue(resp,'DewPoint')+'\n'
	    +  'Relative Humidity: ' + GetNodeValue(resp,'RelativeHumidity')+'\n'
	    +  'Pressure: ' + GetNodeValue(resp,'Pressure'); //+'\n'
	}
	else
	{
	    Result="Sorry! Currently no data available for this city"
	}
	//addWeather(Result);
	//document.getElementById('lblText2').innerText=Result;
	return Result;
}

// ADDED By ATS ON 01-FEB-2007
// Modified on 02-feb-2007
function GetLatestWeather(strCountry,strCity,tabHeader,tabPosition)
{
    tabPosition = tabPosition - 1;
    var xml=new DoCallback('/XMLResponse.aspx','command=GetLatest&eventArgument='+strCountry.value+'&City='+strCity.value+'&TabHeader='+tabHeader+'&TabPosition='+tabPosition);
	var resp=xml.responseText;
	return resp;
}
// ADDED By SK ON 15-OCT-2007
function GetChat(strNewsType,tabHeader,tabPosition,NumRow)
{
    tabPosition = tabPosition - 1;
    if(NumRow=="")
    {
        var xml=new DoCallback('/XMLResponse.aspx','command=Chat&command1=insert&TabHeader='+tabHeader+'&TabPosition='+tabPosition+'&NumRow=10');
    }
    else
    {        
        var xml=new DoCallback('/XMLResponse.aspx','command=Chat&command1=insert&TabHeader='+tabHeader+'&TabPosition='+tabPosition+'&NumRow='+NumRow);
    }
   var resp=xml.responseText;
    return resp;
}
function GetClassifieds(strClassified,tabHeader,tabPosition,NumRow)
{
    tabPosition = tabPosition - 1;
    if(NumRow=="")
    {
        var xml=new DoCallback('/XMLResponse.aspx','command=Classifieds&command1=insert&TabHeader='+tabHeader+'&TabPosition='+tabPosition+'&NumRow=10');
    }
    else
    {
        var xml=new DoCallback('/XMLResponse.aspx','command=Classifieds&command1=insert&TabHeader='+tabHeader+'&TabPosition='+tabPosition+'&NumRow='+NumRow);
    }
    var resp=xml.responseText;
    return resp;
}
// ADDED By ATS ON 05-FEB-2007
// Modified on 
// For Getting News from the news site
/*function GetNews(strNewsType,tabHeader,tabPosition,NumRow)
{
    tabPosition = tabPosition - 1;
    if(NumRow=="")
    {
        var xml=new DoCallback('/XMLResponse.aspx','command=News&NewsType='+strNewsType+'&command1=insert&TabHeader='+tabHeader+'&TabPosition='+tabPosition+'&NumRow=10');
    }
    else
    {
        var xml=new DoCallback('/XMLResponse.aspx','command=News&NewsType='+strNewsType+'&command1=insert&TabHeader='+tabHeader+'&TabPosition='+tabPosition+'&NumRow='+NumRow);
    }
	var resp=xml.responseText;
	return resp;
}*/

function GetModules(strModuleType,tabPosition,NumRow)
{
    tabPosition = tabPosition - 1;
    if(NumRow=="")
    {
        var xml=new DoCallback('/XMLResponse.aspx','command=Module&command1=insert&TabHeader='+strModuleType+'&TabPosition='+tabPosition+'&NumRow=10');
    }
    else
    {
        var xml=new DoCallback('/XMLResponse.aspx','command=Module&command1=insert&TabHeader='+strModuleType+'&TabPosition='+tabPosition+'&NumRow='+NumRow);
    }
	var resp=xml.responseText;
	return resp;
}

/*added by vl06 24 dec to get data from agcareers*/
function GetAgCareers(strModuleType,tabPosition,NumRow)
{
    tabPosition = tabPosition - 1;
    
    if(NumRow=="")
    {
        var xml=new DoCallback('/XMLResponse.aspx','command=GetAgCareers&command1=insert&TabHeader='+strModuleType+'&TabPosition='+tabPosition+'&NumOfRows=10');
    }
    else
    {
        var xml=new DoCallback('/XMLResponse.aspx','command=GetAgCareers&command1=insert&TabHeader='+strModuleType+'&TabPosition='+tabPosition+'&NumOfRows='+NumRow);
    }
	var resp=xml.responseText;
	return resp;
}
/*end of agcareers*/
/*added by vl06 24 dec to get data from realestate*/
function GetRealEstate(strModuleType,tabPosition,NumRow)
{
    tabPosition = tabPosition - 1;
    
    if(NumRow=="")
    {
        var xml=new DoCallback('/XMLResponse.aspx','command=GetRealEstate&command1=insert&TabHeader='+strModuleType+'&TabPosition='+tabPosition+'&NumOfRows=10');
    }
    else
    {
        var xml=new DoCallback('/XMLResponse.aspx','command=GetRealEstate&command1=insert&TabHeader='+strModuleType+'&TabPosition='+tabPosition+'&NumOfRows='+NumRow);
    }
	var resp=xml.responseText;
	return resp;
}
/*end of RealEstate*/
function insertUserProfile(tabHeader,tabData,tabPosition)
{
    //var xml=new DoCallback('saveUserProfile.aspx','command=insert&TabHeader'+tabHeader+'&TabData='+tabData+'&TabPosition='+tabPosition);
    tabPosition = tabPosition - 1;
    var xml=new DoCallback('saveUserProfile.aspx','command=insert&TabPosition='+tabPosition); 
	var resp=xml.responseText;
	return resp;
}

function swapUserProfile(tabPosition,tabPosition1)
{
    tabPosition=tabPosition-1;
    tabPosition1=tabPosition1-1;
    //var xml=new DoCallback('saveUserProfile.aspx','command=swap&TabPosition='+tabPosition+'&TabPosition1='+tabPosition1);
    var xml=new DoCallback('/XMLResponse.aspx','command=swap&TabPosition='+tabPosition+'&TabPosition1='+tabPosition1);
	var resp=xml.responseText;
	return resp;
}
function insertEmptyUserProfile(tabPosition)
{
    //var xml=new DoCallback('saveUserProfile.aspx','command=insert&TabHeader'+tabHeader+'&TabData='+tabData+'&TabPosition='+tabPosition);
    tabPosition = tabPosition - 1;
    var xml=new DoCallback('/XMLResponse.aspx','command=insertEmptyTab&TabPosition='+tabPosition); 
	var resp=xml.responseText;
	return resp;
}
function retrieveTabDataFromProfile(tabPosition)
{
    tabPosition = tabPosition - 1;    
    var xml=new DoCallback('/XMLResponse.aspx','command=retrieve&TabPosition='+tabPosition);
    var resp=xml.responseText;
    
	return resp;
}

//Settings for View Page only
function retrieveViewTabDataFromProfile(tabPosition)
{
    tabPosition = tabPosition - 1;
    var xml=new DoCallback('/XMLResponse.aspx','command=retrieveview&TabPosition='+tabPosition);    
   //debugger; 
    var resp=xml.responseText;     
	return resp;
}
function setDefaultControlProp()
{    
    var xml=new DoCallback('/XMLResponse.aspx','command=setDefault');
	var respo=xml.responseText;
	return respo;
}

function retrieveDefaultTabProp(tabPosition)
{
    tabPosition = tabPosition - 1;   

    var xml=new DoCallback('/XMLResponse.aspx','command=retrieveDefaultTabProperties&TabPosition='+tabPosition);
	var resp=xml.responseText;
	return resp;
}
function retrieveDefaultViewTabProp(tabPosition)
{   
    tabPosition = tabPosition - 1;       
    var xml=new DoCallback('/XMLResponse.aspx','command=retrieveDefaultViewTabProperties&TabPosition='+tabPosition);        
	var resp=xml.responseText;	
	return resp;
}

function retrieveDefaultTabItemProp(tabPosition)
{
    tabPosition = tabPosition - 1;
    var xml=new DoCallback('/XMLResponse.aspx','command=retrieveDefaultTabItemProperties&TabPosition='+tabPosition);
	var resp=xml.responseText;
	return resp;
}
function updateCheckStatusFromCodeBehind(checkValu,categoryType)
{

    var xml=new DoCallback('/XMLResponse.aspx','command=Status&checkId='+checkValu+'&categoryType='+categoryType);
    var resp=xml.responseText;
    return resp;
}
//******************               VL RJ 2007-10-25                 **********************
//******************* Get RSS Feeds from the Link by calling XMLResponse.vb *********************
function GetRSSFeeds(tabPosition,strLink,numOfRows,save)
{
    tabPosition = tabPosition - 1;
    var xml=new DoCallback('/XMLResponse.aspx','command=RSSFeed&LinkType='+strLink+'&command1=insert&TabPosition='+tabPosition+'&NumOfRows='+numOfRows+'&EditAndSave='+save);
	var resp=xml.responseText;
	return resp;
}
//******************* RSS Feeds Code Ends Here *****************************
function getRSSSearchFeeds(strSearch,strCategory,strLocation,strRows)
{
    exp="\\.";
    emailregexp = new RegExp(exp);
    result = strSearch.match(emailregexp);
    while(result != null)
    {
        strSearch = strSearch.replace(".","dddottt");
        result = strSearch.match(emailregexp);
    }
    var xml=new DoCallback('/XMLResponse.aspx','command=getRSSSearchFeeds&searchkey='+strSearch+'&category='+strCategory+'&location='+strLocation+'&Rows='+strRows);
	var resp=xml.responseText;
	return resp;
}
function getPreviousRSSSearchFeeds(strSearch,strCategory,strLocation,strRows,setRowCount)
{
    var xml=new DoCallback('/XMLResponse.aspx','command=getPreviousRSSSearchFeeds&searchkey='+strSearch+'&category='+strCategory+'&location='+strLocation+'&Rows='+setRowCount);    
	var resp=xml.responseText;
	return resp;
}
function getNextRSSSearchFeeds(strSearch,strCategory,strLocation,strRows,setRowCount)
{
    var xml=new DoCallback('/XMLResponse.aspx','command=getNextRSSSearchFeeds&searchkey='+strSearch+'&category='+strCategory+'&location='+strLocation+'&Rows='+setRowCount);
	var resp=xml.responseText;
	return resp;
}
function retrieveSubPageTabItemProp(tabHeader,groupID,categoryTypeParam)
{
  //debugger;
    exp="\\&";
    emailregexp = new RegExp(exp);
    result = tabHeader.match(emailregexp);
    while(result != null)
    {
        tabHeader = tabHeader.replace("&","$amph$");
        result = tabHeader.match(emailregexp);
    }
    var xml=new DoCallback('/XMLResponse.aspx','command=retrieveSubPageTabItemProp&TabHeader='+tabHeader+'&GroupId='+groupID+'&categoryTypeParam='+categoryTypeParam);
	var resp=xml.responseText;
	return resp;
}
function funCheckExistDisplayName(strDisplayName)
{
//debugger;
    var xml=new DoCallback('/XMLResponse.aspx','command=funCheckExistDisplayName&Name='+strDisplayName);    
	var resp=xml.responseText;
	alert(resp);
	return resp;
}
