//SCRIPTS FROM MAKEHOMEPAGE1.JSP
var homepage;
var tillContextPath;
//current page as homepage
//parentHref=location.href;
//var pHref=parentHref.replace("#","")

//building path using requestmethods
//var homepage='http//'+'<%=request.getServerName()%>'+':'+'<%=request.getServerPort()%>'+'/'+'<%=request.getContextPath()%>'+'/'+'index.jsp';

//splitting the location.href 
currentHref=location.href;
cntxPath='<%=request.getContextPath()%>';
end =currentHref.indexOf(cntxPath);

if(end!=-1)
 		tillContextPath=currentHref.substring(0,end);

homepage=tillContextPath+cntxPath+'/index.faces';


function makehomePage(thisObj){

			if (window.XMLHttpRequest) { // Mozilla, Safari, ...

chk=confirm("Due to your browser security handling, making Window2India your homepage, will show you a dialog with a warning.If you do not wish to grant this site the access to your browser settings, you can manually copy http://www.window2india.com and paste it in the location field in Edit|Preferences|Navigator.");
if(chk==true){
try{

//thisObj.style.behavior='url(#default#homepage)';thisObj.setHomePage(pHref);
thisObj.style.behavior='url(#default#homepage)';thisObj.setHomePage(homepage);

}catch(Exception){
}
//alert("hi");
}
//alert(chk);
			} 
			else if (window.ActiveXObject) { // IE
			thisObj.style.behavior='url(#default#homepage)';thisObj.setHomePage(homepage);
			
			//thisObj.style.behavior='url(#default#homepage)';thisObj.setHomePage(pHref);

		}

}

//SCRIPTS FROM ENDUSERLINKS.JSP

function ajaxFunction()
{
	var xmlHttp;
	try
	{  
		// Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	}
	catch (e)
    {
	// Internet Explorer  
	try
    {    
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
	}
    catch (e)
    { 
	  try
      {      
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
      }
      catch (e)
       {      
		   alert("Your browser does not support AJAX!");      
		   return false;      
	   }    
	}
  }

  xmlHttp.onreadystatechange=function()
  {
    if(xmlHttp.readyState==4)
    {
		var str = xmlHttp.responseText;
		
        document.getElementById("enduserdata").innerHTML=str;
    }
  }
  xmlHttp.open("POST","<%=request.getContextPath()%>/components/newEndUserLinks/endUserLinksProcess.jsp",true);
  xmlHttp.send(""); 
}

function test()
{
	new ajaxFunction();
}


//SCRIPTS FROM adBanner.jsp

function GetXMLHttpRequest() 
{
	var object = null;
	
	if (window.ActiveXObject) 
	{
		try
		{
			object = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
		}
		
		if (object == null)
		{
			try
			{
				object = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
			}
		}
	}
	else if (window.XMLHttpRequest) 
	{
		object = new XMLHttpRequest();
	} 
	
	if (object == null)
	{
		alert("Your browser does not support AJAX");
	}
	
	return object;
}
var XMLRequestObj = null;
function sendRequestforbanner(bannerID)
{  

   if (!XMLRequestObj)
		XMLRequestObj = GetXMLHttpRequest();
	else if (XMLRequestObj.readyState != 0)
		XMLRequestObj.abort(); 

	if (XMLRequestObj)
	{
		XMLRequestObj.onreadystatechange = handleRequest;
		var URL = '<%=request.getContextPath()%>' + "/BannerHitServlet";
		var params = "bannerID="+bannerID;//+'<%=request.getAttribute("bannerId")%>';
		var url = URL + "?" + params ;
		XMLRequestObj.open("GET", url, true);
		XMLRequestObj.setRequestHeader( "Content-Type" , "application/x-www-form-urlencoded; charset=UTF-8" );
		XMLRequestObj.send("");
	}
}
function handleRequest()
{
	if (XMLRequestObj.readyState == 4) {
			if (XMLRequestObj.status == 200) {
				var hitCount = XMLRequestObj.responseText;
					
			} else {
				alert("There was a problem with the request.");
			}
		}
}

function countHitsforBanner(bannerID)
{
	sendRequestforbanner(bannerID);
}


//SCRIPTS FROM shopsiteSearch.jsp


function updateCounter(keyword)
{
	var xmlHttp;
	try
	{  
		// Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	}
	catch (e)
    {
	// Internet Explorer  
	try
    {    
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
	}
    catch (e)
    { 
	  try
      {      
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
      }
      catch (e)
      {      
		  alert("Your browser does not support AJAX!");      
	      return false;      
	   }    
	}  
  }

  xmlHttp.onreadystatechange=function()
  {
    if(xmlHttp.readyState==4)
    {
		var str = xmlHttp.responseText;
    }
  }
  
  xmlHttp.open("POST","<%=request.getContextPath()%>/components/searchmenu/updateCounter.jsp?keyword="+keyword,true);
  xmlHttp.send(""); 
}


function resultsPage()
{
	var query = document.getElementById("query").value;
	new updateCounter(query);
	
	if(trim(query)!="")
	{
		/*if (document.getElementById("site").checked==true)
		{
			location.href = "<%=request.getContextPath()%>/admin/luceneResults.jsp?query=" +query + "&maxresults=20";
		}
		else  if (document.getElementById("catalogue").checked==true)
		{
			location.href = "http://shopping.window2india.com/wl/faces/tiles/search.jsp?q="+query+"&catalogueID=20375786";
		}*/
		location.href = "<%=request.getContextPath()%>/admin/luceneResults.jsp?query=" +query + "&maxresults=20";
	}
	//window.open("/cms/components/printPage/printThisPage.jsp?articleId="+artid);
}
