function UpdateImageOnMouseEvent(Target)
{       
    if(Target.childNodes[0].src.slice(Target.childNodes[0].src.lastIndexOf('.')-4, Target.childNodes[0].src.lastIndexOf('.')) == 'Over'){
        Target.childNodes[0].src = Target.childNodes[0].src.slice(0,Target.childNodes[0].src.lastIndexOf('.')-4) + Target.childNodes[0].src.slice(Target.childNodes[0].src.lastIndexOf('.'));
    } else {
        Target.childNodes[0].src = Target.childNodes[0].src.slice(0,Target.childNodes[0].src.lastIndexOf('.')) + 'Over' + Target.childNodes[0].src.slice(Target.childNodes[0].src.lastIndexOf('.'));
    }  
}

function ExpandLanguageSelector (Height){	
	TargetDIV = document.getElementById('TIGILanguageSelectorDIV');
  	TargetTD = document.getElementById('TIGILanguageSelectorTD');	
	CurrentTop = TargetDIV.offsetTop	
  	TargetTD.style.height = Height+"px";
	NewTop = (Height*-1) - 48;
	TargetDIV.style.top = NewTop+"px"; 
}

function ContractLanguageSelector(){
	TargetHeight = 30;
   	TargetDIV = document.getElementById('TIGILanguageSelectorDIV');
  	TargetTD = document.getElementById('TIGILanguageSelectorTD');		
  	TargetTD.style.height = TargetHeight; 
	TargetDIV.style.top = -77 +"px";     
}


function UpdateSkin(TargetSite, CustomerLocale){ 
	
	var CurrentDomain = window.location.host;
	var CurrentURL = window.location.pathname;
	var SegmentedURL = window.location.pathname.split( '/' ); 
	var TargetSkinID;
	CorrectURL = false;
	var TargetURL = "/"+TargetSite+"/"+CustomerLocale+"/"+SegmentedURL[SegmentedURL.length-1];


	if(TargetSite.toLowerCase() == "CONSUMER"){
		TargetSkinID = "2";
	} else if(TargetSite.toLowerCase() == "PROFESSIONAL"){
		TargetSkinID = "3";
	} else {
		TargetSkinID = "2";
	}

	
	if (CurrentURL.toLowerCase() != TargetURL.toLowerCase()  ){
		CorrectURL = true;
	}

	var SkinCookieReturn = ReadSkinCookie('SkinID'); 
	if (SkinCookieReturn != TargetSkinID || SkinCookieReturn == null || CorrectURL == true ){
		CorrectURL = false;
		document.cookie = "SkinID"+"="+TargetSkinID;
		window.location = TargetURL;  
	}
	
		
	function ReadSkinCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
        	window.onload = func;	
	} else {
        	window.onload = function() {
			if (oldonload) {
			oldonload();
		}
	func;    
	}
    }
}


var CurrentSection = "Video";
function HTGTLStep(TotalSteps, TargetStep){		
	if (CurrentSection  == "Video"){        	
	HTGTLPlayer.DoStop(); 
	CurrentSection = "Steps";
	} 
	document.getElementById('StepsDiv').style.display = 'block';
	document.getElementById('VideoDiv').style.display = 'none';
	 for (var i=1;i<=TotalSteps;i++){
   		if (TargetStep == i){			
			var DisplayType = "block";			
		} else {			
		 	var DisplayType = "none";
		} 
		document.getElementById('StepText' + i).style.display = DisplayType;
		document.getElementById('StepPhoto' + i).style.display = DisplayType;
   	}
} 

function HTGTLVideo(TotalSteps, TargetStep){	
	if (CurrentSection  == "Steps"){	
	document.getElementById('StepsDiv').style.display = 'none';
	document.getElementById('VideoDiv').style.display = 'block';
	for (var i=1;i<=TotalSteps;i++){
   		if (TargetStep == i){			
			var DisplayType = "block";			
		} else {			
		 	var DisplayType = "none";
		} 
		document.getElementById('StepText' + i).style.display = DisplayType;
		document.getElementById('StepPhoto' + i).style.display = DisplayType;
   	}}
	HTGTLPlayer.DoPlay()
	CurrentSection = "Video";
}


/*image ratio = 445 by 281.*/
var api
function FlashVideoPlayer(VideoURL, W, H, DIVID) {
api =  flashembed(DIVID,{	
	src:'SWF/FlowPlayer/FlowPlayerDark.swf',
	id:'VideoPlayer',
	width: W,
	height: H
	},       
	{config: {
	videoFile: VideoURL,
	loop: false,
	autoRewind: true,
	initialScale: 'scale',
	controlBarGloss: 'high',
	menuItems: [ true, true, true, true, false, false ],
	useNativeFullScreen: true
	}}
	);
}               


function SetLocale(TargetLocale){	
	var CurrentURL = window.location.pathname;
	var SegmentedURL = window.location.pathname.split( '/' ); 	
	var TargetLocalURL = "http://www.tigistore.com/Consumer/setlocale.aspx?returnURL=" + SegmentedURL[SegmentedURL.length-1] + "&localesetting=" + TargetLocale;
	window.location = TargetLocalURL;
}


function ChangeTxt(divname, txt) {
	if(document.getElementById){
		document.getElementById(divname).innerHTML = txt;
	}
}

function ActivateLocaleFlag(TargetFlagLocale){	
	if (TargetFlagLocale == 'en-US'){		
		document.getElementById("IMGUSFlag").setAttribute("src", "skins/Skin_2/TIGIImages/buttons/flag_us_active.png");		
	}else if (TargetFlagLocale == 'en-GB'){
		document.getElementById("IMGGBFlag").setAttribute("src", "skins/Skin_2/TIGIImages/buttons/flag_uk_active.png"); 
	}else if (TargetFlagLocale == 'en-AU'){
		document.getElementById("IMGAUFlag").setAttribute("src", "skins/Skin_2/TIGIImages/buttons/flag_AU_active.png"); 
	} 

}

function GetQueryParams() { 
	var QueryParams = new Object(); 	
	var QueryString = location.search.substring(1);	
	var Pairs = QueryString.split("&"); 
	
	for(var i = 0; i < Pairs.length; i++) { 
		var pos = Pairs[i].indexOf('='); 
		if (pos == -1) continue; 
		var argname = Pairs[i].substring(0,pos); 
		var value = Pairs[i].substring(pos+1); 
		QueryParams[argname] = unescape(value); 
	} 	
	
	return QueryParams; 
} 