////AjaxHttpRequest.js
function autoFocus(e)
{
    if(e.keyCode==13)
    {        
        document.getElementById('btnGo').focus();        
    }      
}

//function MM_reloadPage(init) //reloads the window if Nav4 resized
//{  
//  if (init==true) with (navigator) 
//  {
//        if ((appName=="Netscape")&&(parseInt(appVersion)==4)) 
//        {
//            document.MM_pgW=innerWidth; 
//            document.MM_pgH=innerHeight; 
//            onresize=MM_reloadPage; 
//        }
//  }
//  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
//}
//MM_reloadPage(true);

//function createRequestObject()
//{
//  var objRequest;
//  var browser = navigator.appName;
//  if(browser == "Microsoft Internet Explorer") 
//  {		
//  	objRequest = new ActiveXObject("Microsoft.XMLHTTP");     	
//  } 
//  else 
//  { 	
//    objRequest = new XMLHttpRequest();
//  }
//  return objRequest;
//}

//var http = createRequestObject();

//function handleResponse()
//{
//    if(http.readyState == 4) 
//    {
//        var response = http.responseText;
//        var update = new Array();
//        if(response.indexOf('|' != -1)) 
//        {
//            update = response.split("|");
//            document.getElementById("ProductImage").innerHTML =update[0];
//            document.getElementById("ProdDescription").innerHTML =update[1];
//			document.getElementById("ProductPrice").innerHTML =update[2];
//			//document.getElementById("ProductPrice").innerHTML ="Rs. " + update[2] + " / " + CurrecyUnit[1] + " " +  (collDivs[i].title/CurrecyUnit[2]).toFixed(2);
//			document.getElementById("ProductPrice").title =update[2];
//			//SetDivIndexPrice(getElementById('ProductPrice'),getElementById('ProductPrice'),getElementById('CurrencyFlag'));
//			//SetDivIndexPrice(theDiv,theOpt,theFlag)               
//        }

//    }
//}

function sndUserCheckforcolor(theOpt)
{
  http.open("get", "Ajax.aspx?proid=" + theOpt.value + "&ajmode=color");
  http.onreadystatechange = handleResponse;
  http.send(null);
}

function sndUserCheckforsize(theOpt)
{  
  http.open("get", "Ajax.aspx?proid=" + theOpt.value + "&ajmode=size");
  http.onreadystatechange = handleResponse;
  http.send(null);
}

function SelectedItem(theOpt,theTxt) 
{
    window.location.href= "category.aspx?cat=" + theOpt.value + "&searchterm=" + theTxt.value;  
}

//function SetDivIndexPrice(theDiv,theOpt,theFlag) 
//{
//    theFlag.innerHTML="<img src='Pictures/" + theOpt.options[theOpt.selectedIndex].text +".jpg' width='29' height='15'>" ;   
//    var i;
//    var CurrecyUnit = new Array();
//    var collDivs = document.all.tags('DIV');
//    //alert(collDivs);
//    if (collDivs != null) 
//    {
//        theFlag.innerHTML="<img src='Pictures/" + theOpt.options[theOpt.selectedIndex].text +".jpg' width='29' height='15'>" ;
//        for(i=0;i<collDivs.length;i++)  
//        {          
//            if (theDiv.id == collDivs[i].id)
//            {                 
//                CurrecyUnit = theOpt.value.split(",");
//                collDivs[i].innerHTML= "Rs. " + collDivs[i].title + " / " + CurrecyUnit[1] + " " +  (collDivs[i].title/CurrecyUnit[2]).toFixed(2);
//            }          
//        }        
//        return -1;
//    }
//}


//////////////// Newly implemented by AB
function SetDivIndexPrice(theDiv, theOpt, theFlag) 
{   
    if(theDiv!=null && theOpt!=null)
    {
        //alert("div: " + theDiv + "Coming value="+theOpt.value + " Flag div: " + theFlag );
        var i;
        var CurrencyUnit = new Array();
        var collDivs = document.getElementsByTagName('DIV');
        //alert(collDivs);
        if (collDivs != null) 
        {
            theFlag.innerHTML="<img src='http://www.giftstoindia24x7.com/Pictures/" + theOpt.options[theOpt.selectedIndex].text +".jpg' width='29' height='15'>" ;
            for(i=0;i<collDivs.length;i++)  
            {          
                if (theDiv.id == collDivs[i].id)
                {                 
                    CurrencyUnit = theOpt.value.split(",");                    
                    alert(CurrencyUnit[2]);
                    //alert("Rs. " + collDivs[i].title + " / " + CurrencyUnit[1] + " " +  (collDivs[i].title/CurrencyUnit[2]).toFixed(2));
                    collDivs[i].innerHTML= "Rs. " + collDivs[i].title + " / " + CurrencyUnit[1] + " " +  (collDivs[i].title/CurrencyUnit[2]).toFixed(2);                    
                }          
            }        
            //return -1;
        }
    }
    else
    {
        alert("No price found to change.");
    }
}


function setDivPrice(theDiv, theOpt, theFlag) 
{   
    if(theDiv!=null && theOpt!=null)
    {
        //alert("div: " + theDiv + " Coming value="+theOpt.value + " Flag div: " + theFlag );
        var xmlHttpReq = false;
        var self = this;
        if (window.XMLHttpRequest) 
        {
            self.xmlHttpReq = new XMLHttpRequest();        
        }
        else if (window.ActiveXObject) 
        {
            self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");         
        }
        self.xmlHttpReq.open('POST', "ajaxCommonFunction.aspx", true);             
        self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        self.xmlHttpReq.onreadystatechange = function() 
        {
            if (self.xmlHttpReq.readyState == 4) 
            {
                var GetValue=new Array();
                //alert(self.xmlHttpReq.responseText);
                if(self.xmlHttpReq.responseText.indexOf('~' != -1))
                {
                    GetValue=self.xmlHttpReq.responseText.split("~");
                }
                if(GetValue[0].toString()!="")
                {
                    if(GetValue[0].toString()=="0")
                    {
                        alert("Error : " + GetValue[1].toString());
                    }
                    else
                    {
                        // Return brings Currency symbol in array 1 and Currency Value
                        var collDivs = document.getElementsByTagName('DIV');
                        //alert(collDivs);
                        if (collDivs != null) 
                        {
                            theFlag.innerHTML="<img src=\"http://www.giftstoindia24x7.com/Pictures/" + theOpt.options[theOpt.selectedIndex].text +".jpg\" width=\"29\" height=\"15\">" ;
                            
                            //alert("Symbol: " + GetValue[1].toString() + " Value: " + GetValue[2].toString());
                            for(i=0;i<collDivs.length;i++)  
                            {          
                                if (theDiv.id == collDivs[i].id)
                                {
                                    collDivs[i].innerHTML= "Rs. " + collDivs[i].title + " / " + GetValue[1].toString() + " " +  (collDivs[i].title/GetValue[2]).toFixed(2);                    
        
                                }          
                            }
                        }
                    }
                }
                else
                {
                    alert("Sorry! Due to some error currency cannot be changed.");
                }
            }
        }
        self.xmlHttpReq.send("mode=1&currId="+theOpt.value); 
    }
    else
    {
        alert("Sorry! No price found to change. Cannot Change currency.");
    }
}

