/*	SONY | SONY STYLE.COM - [MODAL OF FUNCTIONALITY NAME]
 *	Author(s): 	Jonathan Cheung 	| Sr. Flash Developer , Jonathan.Cheung at am dot sony dot com
 *	Date:		November 16, 2009
 *
 *	JS FILE PRE-CONDITIONS:
 *	-------------------------------------------------------------------------------------------------
 *
 *		- Prototype must be included before this .js (or included functions) is referenced.
 *
 *
 *
 *	FUNCTIONALITY THAT THIS JS WILL PROVIDE
 *	-------------------------------------------------------------------------------------------------
 *
 *	This file will allow us to strip the DOM level2 events that are used ON ALL FILES ON SONY STYLE
 *	Examples would include: AjaxInit()
*/

/* Omniture Tracking functions */

//Reader Hero banner
var trackImpression = function(param){
	param =param.split("/").join(":");
	FlashTracking(param);
	try{console.log("Impression:"+"PE:Reader Digital Book:"+param)}catch(_){}
}
var trackCTA = function(param){
	param =param.split("/").join(":");
	FlashTrackingCTA(param);
	try{console.log("CTA:"+"PE:Reader Digital Book:"+param)}catch(_){}
}
//Book Grid
var trackBookGridImpression = function(param){
	param =param.split("/").join(":");
	FlashTracking(param);
	try{console.log("Impression:"+"PE:eBookStore Book Grid:"+param)}catch(_){}
}
var trackBookGridCTA = function(param){
	param =param.split("/").join(":");
	FlashTrackingCTA(param);
	try{console.log("CTA:"+"PE:eBookStore Book Grid:"+param)}catch(_){}
}
var FlashTracking = function(param){	
	try{
		s.linkTrackVars="prop29,hier2";
		s.prop29 = s.pageName+":"+param;
		
		s.tl(this,'o','Reader Category tracking');
		
		if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=\"http://192.168.112.2O7.net/stats_debugger.php\"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
		
	
	} catch(_){
		try{console.log("An error occurred when trying to send metrics to Omniture")}catch(_){};
	}
}

var FlashTrackingCTA = function(param){	
	try{
		s.linkTrackVars="prop29,hier2,eVar29";
		s.prop29 = s.pageName+":"+pathArray.join(':');
		s.eVar29 = s.pageName+":"+param;

		s.tl(this,'o','Reader Category tracking');
		
		if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=\"http://192.168.112.2O7.net/stats_debugger.php\"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
		
		
	} catch(_){
		//alert("An error occurred when trying to send metrics to Omniture");
	}
}

var partnum ="";
//Dealer locator
function intializeLocatorForm(_partnum)
{ 
	try{console.log(_partnum + " and length:" +$$('#lightwindow_contents .zipCodeSubmitLink').length)}catch(_){};
	partnum=_partnum.replace(/_/g, "/");
  $$('#lightwindow_contents .zipCodeSubmitLink').each(function(e){
   Event.observe(e, 'click', function(){
   alert("ok")
    var ourZipCode = $$('#lightwindow_contents .zipCodeField')[0].value;
    
    var ourLink = '/webapp/wcs/stores/servlet/CategoryDisplay?catalogId=10551&storeId=10151&langId=-1&identifier=S_Retailers_with_Inventory';

    var ourFullSource = ourLink + '&zipCode=' + ourZipCode +'&sku='+ partnum;
    
    $(this).href= ourFullSource;    
    
   });
   
  });

}//dealer locator

