/**
 * FIX DOMAIN ISSUE OF LINCOLN SITE
 * Author - Srinivas Rao
 */
try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}


$(document).ready(Init);

function Init()
{
	// Replace domain
	if(location.host.indexOf('sunnet.sunlife.com') != -1){
		
		//z189 : 24/08/2010 - Removing the replace call , as permanent fix given to the issue.
		//replaceDomain();
		openOverLay();
	}
	
}




/*
Quick fix for Lincoln site for replacing few urls.
*/
function replaceDomain(){
	if(document.getElementById("toolbar")!=null){
		//stage
		$('#toolbar li a').attr('href', function() {
    			//return this.href.replace(/http:\/\/stage-www\.sunlife\.ca\/slfglobal/,'https://stage-www-uk.ca.sunlife/slfglobal');
			return this.href.replace(/http:\/\/stage-www\.sunlife\.ca\/slfglobal/,'https://stage.sunnet.sunlife.com/slfglobal');	
		}); 
		//production 
		$('#toolbar li a').attr('href', function() {
    			return this.href.replace(/http:\/\/www\.sunlife\.ca\/slfglobal/,'https://www.sunnet.sunlife.com/slfglobal');
				
		});
	}
	if(document.getElementById("primary")!=null){
		//stage
		$('#primary li a').attr('href', function() {
    			return this.href.replace(/http:\/\/stage-www\.sunlife\.ca\/canada/,'https://stage.sunnet.sunlife.com/slfglobal');
		}); 	
		$('#primary li a').attr('href', function() {
    			return this.href.replace(/https:\/\/stage\.sunnet\.sunlife\.com\/slfuk/,'https://stage.sunnet.sunlife.com/slfglobal');
		}); 
		$('#breadcrumb li a').attr('href', function() {
    			return this.href.replace(/slfuk/,'slfglobal');
		});

		//production
		$('#primary li a').attr('href', function() {
    			return this.href.replace(/http:\/\/www\.sunlife\.ca\/canada/,'https://www.sunnet.sunlife.com/slfglobal');
		}); 	
		$('#primary li a').attr('href', function() {
    			return this.href.replace(/https:\/\/www\.sunnet\.sunlife\.com\/slfuk/,'https://www.sunnet.sunlife.com/slfglobal');
		}); 
		$('#breadcrumb li a').attr('href', function() {
    			return this.href.replace(/slfuk/,'slfglobal');
		});

	}



	if(document.getElementById("content-navigation")!=null){
		
		$('#content-navigation #secondary li a').attr('href', function() {
    			return this.href.replace(/slfuk/,'slfglobal');
		}); 
	}


	if(document.getElementById("primary")!=null){
		
		if(document.getElementById("firstname")!= null){
			if(document.getElementById("firstname").value == "null"){
				$('#primary li a').attr('href', function() {
					return this.href.replace(/slfuk/,"slfglobal");
				}); 
			}
		}		
	}

	if(document.getElementById("sitemap")!=null){
		//alert(document.getElementById("firstname"));
		if(document.getElementById("firstname").value== null||document.getElementById("firstname").value== undefined
			||document.getElementById("firstname").value== 'null'||document.getElementById("firstname")== ""){			
				$('#sitemap li a').attr('href', function() {
					return this.href.replace(/slfuk/,"slfglobal");
				}); 
		}		
	}

	
if(document.getElementById("footer") !=null){

		//stage
		$('#footer a').attr('href', function() {
    			return this.href.replace(/http:\/\/stage-www\.sunlife\.ca\/canada/,'https://stage.sunnet.sunlife.com/slfglobal');
				
		});
		$('#footer a').attr('href', function() {
    			return this.href.replace(/https:\/\/stage\.sunnet\.sunlife\.com\/slfuk/,'https://stage.sunnet.sunlife.com/slfglobal');
				
		});
		//production 
		$('#footer a').attr('href', function() {
    			return this.href.replace(/http:\/\/www\.sunlife\.ca\/slfglobal/,'https://www.sunnet.sunlife.com/slfglobal');
				
		});
	}

if(document.getElementById("content-wrapper-right") !=null){

//production 
		$('#content-wrapper-right a').attr('href', function() {
    			return this.href.replace(/http:\/\/www\.sunlife\.ca\/slfglobal/,'https://www.sunnet.sunlife.com/slfglobal');
				
		});
	}

	if(document.getElementById("content-wrapper-right") !=null){

//production 
		$('#content-wrapper-right a').attr('href', function() {
    			return this.href.replace(/http:\/\/www\.sunlife\.ca\/canada/,'https://www.sunnet.sunlife.com/slfglobal');
				
		});
	}
	
	if(document.getElementById("firstname")!= null){
			
		if(document.getElementById("firstname").value != "null"){
			//stage
			$('#ftr-searchresults a').attr('href', function() {
    			return this.href.replace(/http:\/\/stage-www\.sunlifefinancialofcanada\.co\.uk/,'https://stage.sunnet.sunlife.com');
			});

			//production
			$('#ftr-searchresults a').attr('href', function() {
    			return this.href.replace(/http:\/\/www\.sunlifefinancialofcanada\.co\.uk/,'https://www.sunnet.sunlife.com');
			});
		}
	}
   

}


