var sendOmnitureCode = true;

var s_LPCtoGPCArray = new Array();
s_LPCtoGPCArray["Sigorta"]="Insurance";
s_LPCtoGPCArray["Mortgage"]="Mortgages";
s_LPCtoGPCArray["KOBİ Kredileri"]="Others";
s_LPCtoGPCArray["Ticari Krediler"]="Others";
s_LPCtoGPCArray["Leasing/Factoring"]="Others";
s_LPCtoGPCArray["Emeklilik"]="Others";
s_LPCtoGPCArray["Şubesiz"]="Others";
s_LPCtoGPCArray["KOBİ Bankacılığı"]="Others";
s_LPCtoGPCArray["Garanti Masters"]="Others";
s_LPCtoGPCArray["Ticari Bankacılık"]="Others";
s_LPCtoGPCArray["Kurumsal Bankacılık"]="Others";
s_LPCtoGPCArray["Yatırım"]="Others";
s_LPCtoGPCArray["Bireysel Krediler"]="Personal Loans";
s_LPCtoGPCArray["Kredi Kartları"]="PLCC";
s_LPCtoGPCArray["Bireysel Bankacılık"]="Savings/Deposits";
s_LPCtoGPCArray["Ana Sayfa"]="HomePage";
s_LPCtoGPCArray["Tablo/Hesap Makinesi"]="Others";
s_LPCtoGPCArray["Kampanya"]="Others";
s_LPCtoGPCArray["Garanti'yi Tanıyın"]="Company Information";
s_LPCtoGPCArray["İnsan Kaynakları"]="Others";
s_LPCtoGPCArray["Arama"]="Others";
s_LPCtoGPCArray["Yatırımcı İlişkileri"]="Others";
s_LPCtoGPCArray["Site Haritası"]="SiteMap";
s_LPCtoGPCArray["Haklı Müşteri Hattı"]="Customer Support";
s_LPCtoGPCArray["Güvenlik"]="Others";

function s_trimSessionID(curURL,trimID){
       return curURL.toLowerCase().indexOf(trimID)!=-1?curURL.split(trimID)[0]:curURL;
}

function s_getGPC(s_theProductName){
	return typeof(s_LPCtoGPCArray[s_theProductName])!=UNDEFINED?s_LPCtoGPCArray[s_theProductName]:"";
}

/*** Custom Functions ***/
function s_getQueryParameter(s_param)
{
	var regexS = "[\\?&]"+s_param+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results == null )
		return undefined;
	else
		return results[1];
}

function s_addSlashes(s_addslash_params)
{
	var result="";

	for (var i in s_addslash_params)
	{
		if (s_addslash_params[i]=="") 
			break;
		result+="/"+s_addslash_params[i];
	}
	
	return result.length>0?result.substring(1):"";
}

function s_trimString(val,len)
{
	if (val.length > len)
	{
		tmp_oversize = val.length - len;
		return val.substr(0,(val.length/2)-(tmp_oversize/2)-2) + ".." + val.substr((val.length/2)+(tmp_oversize/2));
	}
	return val;
}

function s_sendErrorInfo(errorDetail)
{
	// This will send a request to Omniture, i.e. extra cost (same as a page view request)
	var s=s_gi(s_account);
	s.usePlugins=false;

	s.dynamicAccountSelection=true;
	s.dynamicAccountList=s_dynamicAccountList;
	s.linkTrackVars="prop22,prop21,eVar22";

	s.prop21=errorDetail;
	s.prop22=errorDetail;
	s.eVar22=errorDetail;
		
	s.tl(obj,'o','Validation Error');
	s.usePlugins=true;
	s.linkTrackVars="";
	s.prop21=""
	s.prop22=""
	s.eVar22=""
}
/*** End Custom Functions ***/


/*** Constants***/
var UNDEFINED = "undefined";
/*** Constants ***/


/*** Custom Insights configuration ***/
var tmpTitle=document.title;
if (typeof(s_pName) == UNDEFINED){
	if (tmpTitle.indexOf("Garanti Bankası >> Garanti'yi Tanıyın >> Garanti'den Haberler >> ŞubeSiz'den Yenilikler >>") == 0)
		tmpTitle = "Garanti Bankası >> Haberler >> ŞubeSiz " + tmpTitle.substring(88);
	else 	if (tmpTitle.indexOf("Garanti Bankası >> Garanti'yi Tanıyın >> Garanti'den Haberler >> Başarılar ve Ödüller >>") == 0)
		tmpTitle = "Garanti Bankası >> Haberler >> Ödüller " + tmpTitle.substring(86);
	else 	if (tmpTitle.indexOf("Garanti Bankası >> Garanti'yi Tanıyın >> Garanti'den Haberler >> Garanti Sanat >>") == 0)
		tmpTitle = "Garanti Bankası >> Haberler >> Sanat " + tmpTitle.substring(79);
	else 	if (tmpTitle.indexOf("Garanti Bankası >> Garanti'yi Tanıyın >> Garanti'den Haberler >> Kampanyalar >>") == 0)
		tmpTitle = "Garanti Bankası >> Haberler >> Kampanyalar " + tmpTitle.substring(77);
	else 	if (tmpTitle.indexOf("Garanti Bankası >> Garanti'yi Tanıyın >> Garanti'den Haberler >> Önemli Gelişmeler >>") == 0)
		tmpTitle = "Garanti Bankası >> Haberler >> Önemli " + tmpTitle.substring(83);
	else 	if (tmpTitle.indexOf("Garanti Bankası >> Garanti'yi Tanıyın >> Toplumsal Sorumluluk >> Kültür - Sanata Destek >>") == 0)
		tmpTitle = "Garanti Bankası >> Toplumsal Sorumluluk >> Sanat " + tmpTitle.substring(88);
	else 	if (tmpTitle.indexOf("Garanti Bankası >> Haklı Müşteri Hattı >> Sıkça Sorulan Sorular >>") == 0)
		tmpTitle = "Garanti Bankası >> HMH >> SSS " + tmpTitle.substring(64);

	s_pName = tmpTitle.indexOf(">>")!=-1?tmpTitle.substring(tmpTitle.indexOf(">>")+2).replace(/>>/gi,": "):" Ana Sayfa";
}
if (typeof(s_productType) == UNDEFINED){
	s_productType="";
	if (tmpTitle.indexOf(" : ") != -1){
		var tmpIndex = tmpTitle.substring(0,tmpTitle.lastIndexOf(" : ")).lastIndexOf(" : ");
		if (tmpIndex != -1)
			s_productType = tmpTitle.substring(tmpIndex+3);
	}
}
if (typeof(s_productCat) == UNDEFINED)
	s_productCat="";
if (typeof(s_featureName) == UNDEFINED)
	s_featureName="N.A.";
if (typeof(s_UID) == UNDEFINED)
	s_UID="";


s_prop1="CEE";															// Region
s_prop2="Turkey";														// Country	
s_prop3="Garanti";												// website name
s_prop4=typeof(s_prop4)==UNDEFINED?"Products":s_prop4;					// site section
// s_prop5=s_productCat;		// global product category
// s_prop6=s_productCat;		// local product category
s_prop5=typeof(s_prop5)==UNDEFINED?s_getGPC(s_productCat):s_prop5;  // global product category
s_prop6=typeof(s_prop6)==UNDEFINED?s_productCat:s_prop6; 		 // local product category
if (typeof(s_prop7) == UNDEFINED){
   s_prop7=s_productType;
}
s_prop8="TR";
var documentLocation = document.location.href;
if (documentLocation.indexOf(";jsessionid") > -1)
	documentLocation = documentLocation.substr(0,documentLocation.indexOf(";jsessionid"));
s_prop10=s_trimString(documentLocation,100);
s_prop30=s_UID;

s_eVar2=s_prop2;
s_eVar3=s_prop3;
s_eVar4=s_prop8;
s_eVar5=s_prop5;
s_eVar6=s_prop6;
s_eVar7=s_prop7;
s_eVar30=s_prop30;
if (typeof(s_prop39) != UNDEFINED){
  s_eVar39=s_prop39;
}
if (typeof(s_prop40) != UNDEFINED){
  s_eVar40=s_prop40;
}

if(s_productType!=""&&s_productCat!="")
	s_products=s_productCat+";"+s_productType;

s_prop22=typeof(s_prop21)!=UNDEFINED?s_prop21:"";
s_eVar21=typeof(s_prop21)!=UNDEFINED?s_prop21:"";

if (typeof(s_pageState)!=UNDEFINED)
{
	switch(s_pageState)
	{
		case "page not found":
			s_pageType="errorPage";
			s_pageName="";
		break;
		
		case "server error":
			s_pName=s_pName+"[error "+s_errorId+"]";
			if (s_errorId == "404")
			{
				s_pageType="errorPage";
				s_pageName="";
			}
		break;
			
		default:
	}
}
/*** End Custom Insights configuration ***/


/*** Other Omniture variables ***/
s_account="gemoneydtr";
s_prodAccount="gemoneystrparagaranti";
s_prodUrls="www.paragaranti.com";
s_testUrls="localhost";

s_currencyCode="TRY";
s_linkInternalFilters="javascript:,"+s_testUrls+","+s_prodUrls;
s_dynamicAccountSelection=true;
s_dynamicAccountList=s_prodAccount+"="+s_prodUrls;

s_server=location.host.toLowerCase();

/* Site Section */
s_channel= s_prop2 + ":" + s_prop3;

// PageName Specific code
//s_pageName=s_prop3+" : ";
s_pageName=s_pName;

s_pageName=s_trimString(s_pageName, 100);

s_prop9=typeof(s_pageType)!=UNDEFINED?"":s_pageName+"("+s_prop8+")";

/* Hierarchy Variables */

s_hier1=s_addSlashes(new Array(s_prop1,s_prop2,s_prop3,s_prop4,s_prop5,s_prop7,s_pageName));
s_hier2=s_addSlashes(new Array(s_prop1,s_prop2,s_prop3,s_prop5,s_pageName));
s_hier3=s_addSlashes(new Array(s_prop2,s_prop3,s_prop4,s_prop6,s_prop7,s_pageName));
s_hier4=s_pageName; // local hierarchy

s_cookieDomainPeriods=location.host.match(/\.(co(m?)|net)\.(in|sg|ph|tr)/)?3:2;

//s_visitorNamespace="garanti"
s_dc=112

s_trackingServer="webstat.garanti.com.tr"
s_trackingServerSecure="webstats.garanti.com.tr"
s_vmk="483ED314"


/*** End Other Omniture variables ***/

/*** Custom functions ***/
/* Custom Function - Run plugin functions 10.04.2008'de Nicolas'tan gelen kod ile degistirildi*/
function runLocalOmniturePluginFunctions()

{

       s.campaignStackingExpires = 60; //in days
       s.campaignStackingCount = 5; //number of campaign codes to keep in cache
       s.campaignStackingCookieName = 's_cs'; //name of cookie that is used
       s.campaignStackingDelimiter = '>';
       s.campaignStackingSuccessEvent = 'event2';

       s.campaign=s.getQueryParam('gbid1');

       if(typeof(s_eVar1)=="undefined")
              s.eVar1=s.getQueryParam('gbid2');
       s.eVar9 = s.eVar1
       s.eVar10=s.campaignStacking();       

       /* Form Analysis Config */
       // s.formList="";
       // s.trackFormList=false;
       // s.trackPageName=true;
       // s.useCommerce=true;
       // s.varUsed="eVar20,prop20";
       // s.linkTrackVars="prop3,prop9,prop20,prop22,eVar20";
       // s.eventList="event10"; Abandon,Success,Error
       // s.setupFormAnalysis();

       s.prop31=(typeof(s.prop19)!="undefined"&&s.prop19!=""?s.prop19+" - ":"")+ s.pageName;
       s.prop32=(typeof(s.campaign)!="undefined"&&s.campaign!=""?s.campaign+" - ":"")+ s.pageName;
       s.prop34=(typeof(s.eVar34)!="undefined"&&s.eVar34!=""?s.eVar34+" - ":"")+ s.pageName;
       s.prop35=(typeof(s.eVar1)!="undefined"&&s.eVar1!=""?s.eVar1+" - ":"")+ s.pageName;
  	 
	 var trimID=";jsessionid";
	 s.referrer = s_trimSessionID(document.referrer,trimID);
	 s.pageURL= s_trimSessionID(document.location.href,trimID);
}


/* Custom Function - Instanciate oo Omniture code based on non-oo code or a default value*/
function setOV(name,defaultVal)
{
	if(typeof(window['s_'+name])!=UNDEFINED)
	{
		if(typeof(window['s_'+name])=="string")
		{
			eval("s."+name+"='"+eval('s_'+name+'.replace(/[\'\"]/g,\"\")')+"'");
		}
		else
		{
			eval("s."+name+"=s_"+name);
		}
	}
	else
	{
		if(typeof(defaultVal)=="string")
		{
			if(defaultVal!="")
			{
				eval("s."+name+"='"+defaultVal.replace(/[\'\"]/g,'')+"'");
			}
			else
			{
				eval("s."+name+"=''");
			}
		}
		else if(typeof(defaultVal)!=UNDEFINED)
		{
			eval("s."+name+"="+defaultVal);
		}
	}
}

/* Custom Function - triggers the instanciation of all oo omniture variables */
function setPrevDefinedOmniVars(){
	var k;
	for(k=1;k<=50;k++){
		setOV('prop'+k,"");
		setOV('eVar'+k,"");
	}
	for(k=1;k<=5;k++){
		setOV('hier'+k,"");
	}
	setOV('pageName',"");
	setOV('channel',"");
	setOV('products',"");
	setOV('zip',"");
	setOV('state',"");
	setOV('events',"");
	setOV('currencyCode',"USD");
	setOV('trackDownloadLinks',true);
	setOV('trackExternalLinks',true);
	setOV('trackInlineStats',true);
	setOV('linkDownloadFileTypes',"exe,zip,wav,mp3,mov,mpg,avi,wmv,doc,pdf,xls,flv");
	setOV('linkLeaveQueryString',true);
	setOV('linkTrackVars',"None");
	setOV('linkTrackEvents',"None");
	setOV('purchaseID');
	setOV('pageType');
	setOV('linkInternalFilters',"javascript:");
	setOV('dynamicAccountSelection', true);
	setOV('dynamicAccountList');
	setOV('dynamicAccountMatch');
	setOV('visitorNamespace');
	setOV('dc');
	setOV('trackingServer');
	setOV('trackingServerSecure');
	setOV('vmk');
	setOV('server');
	setOV('cookieDomainPeriods');
	setOV('charSet','UTF-8');
}
