﻿    var xmlHttp;
	/*SCRIPTS FLASH ADAPTER WILL USE TO INVOKE SHOP-NOW FUNCTIONALITY*/
	function createPopUpWindow(url,name,features){
	  alert(url+","+name+","+features);
   	  window.open(url, name, features);
	}
	// Buy Now Overlay
	function showBuyOverlay(guID) {
	    /*trace("GUID Called");
       ExternalInterface.call("showBuyOverlay",guid);
*/
		//alert('Buy Now Product guID: ' + guID);
		GetProduct(guID);			
	}
	function GetURL(guID, tabID)
	{
        xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		} 
        var url="/hybrid/GetURL.aspx";
		var params="prodguid="+guID
		params=params+"&localeid="+lregion
		params=params+"&tabid="+tabID;
		
        
        //alert(url);
		//xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlHttp.setRequestHeader("Content-length", params.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function() 
        {//Call a function when the state changes.
	        if(xmlHttp.readyState == 4 && xmlHttp.status == 200) 
	        {
	            var sStr = xmlHttp.responseText;
		        
			if((sStr=='')||sStr==null)
			{
				sStr = '/en/us/products/all-products.aspx';
			}
			//alert('Shyam :' + sStr + ':');
		        window.location=sStr;
	        }
	    }
		xmlHttp.send(params);
	}
	
	function GetProduct(guID)
	{
	    lregion = 'en-US';
        xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		} 
        var url="/hybrid/GetURL.aspx";
		var params="prodguid="+guID
		params=params+"&FunctionID='GetProdID'"
		params=params+"&localeid="+lregion;
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlHttp.setRequestHeader("Content-length", params.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function() 
        {//Call a function when the state changes.
	        if(xmlHttp.readyState == 4 && xmlHttp.status == 200) 
	        {
	            var sStr = xmlHttp.responseText;
                ID =  sStr; 	
		        if(ID!='' || ID != undefined)
		        {	
		            $('#buyNowContent').modal('',0);
		            var lft = $('#simplemodal-container').css('left');
		            var ft = lft.substr(0,lft.length-2);
		            if(BrowserDetect.browser == "Opera")
		            {
			            $('#simplemodal-container').css({width:550+"px",left:ft-30+"px"});
		            }
		            else
		            {
			            $('#simplemodal-container').css({width:550+"px",left:ft-75+"px"});
		            }
            		
		            activeTab = 6;
		            $('#tab6').click();	
		            loadRetailers();
		            $('#ctl00_ctl10_searchStores_zipcode').attr('value','search stores...');	
		        }
		        else
		        {
		            window.location = '/en/us/products/all-products.aspx';
		        }
                //return sStr;
	        }
	    }
		xmlHttp.send(params);
	}
	
	function fireEvent(element,event) { 
   if (document.createEvent) { 
       // dispatch for firefox + others 
       var evt = document.createEvent("HTMLEvents"); 
       evt.initEvent(event, true, true ); // event type,bubbling,cancelable 
       return !element.dispatchEvent(evt); 
   } else { 
       // dispatch for IE 
       var evt = document.createEventObject(); 
       return element.fireEvent('on'+event,evt) 
   } 
} 

	// Product Details Overlay
	function showProdDetailsOverlay(guID) {
	    //alert(guID);
        GetURL(guID,0);
	}

	// Ratings & Reviews Overlay
	function showRROverlay(guID) {
	    GetURL(guID,1);
	}
	// Questions & Answers Overlay
	function showQAOverlay(guID) {
        GetURL(guID,2);
	}
	
	function requestAdjacency(path){
        if(path == 'index/footer/nav/products/haircare'){
           window.location = "/en/us/products/all-products.aspx";
          }else if(path == 'index/footer/nav/entertainment/easports2010'){
            window.location = "/en/us/entertainment/gaming-tournament.aspx";
          }else if(path == 'index/footer/nav/products/FusionMVP'){
            window.location = "/en/us/products/razors/fusion-mvp.aspx#";
          }else if(path == 'index/footer/nav/products/ProductSelector'){
            window.location = "/en/us/products/product-coach.aspx";
          }else if(path == 'index/footer/nav/grooming/solutions'){
            window.location = "/en/us/mens-style/shaving-problems-solutions.aspx";
          }else if(path == 'index/footer/nav/grooming/science'){
            window.location ="/en/us/mens-style/gillette-science.aspx";
          }else if(path == "index/footer/nav/products/shop-now"){
           window.location  = '/en/us/shop-now.aspx'
          }else if(path == 'index/footer/nav/promotions/whatsnext/index.shtml' || path == 'index/footer/nav/promotions/whatsnext'){ 
            window.location  = '/en/us/products/razors/proglide.aspx';
          }
}
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.status==200)
	{ 
		var sStr = xmlHttp.responseText;
		alert(sStr);
		//window.location=sStr;
	} 
} 


