var ltkalmaremailwindow;
var ltkalmarprintwindow;

function EnableScriptLinks() {
	var tiplink = document.getElementById("utiltiplink");
	if(tiplink){
		tiplink.style.display = "inline";
	}	
}
function OpenEmailDialogue(rootDir, pageId, userid){
	var height = 320;
	var width = 230;
	var left = (window.screen.width - width) / 2;
	var top = (window.screen.height - height) / 2;
	var features = "height=" + height + ",width=" + width + ",left=" + left + ",top=" + top;
	if(ltkalmaremailwindow && !ltkalmaremailwindow.closed){
		ltkalmaremailwindow.close();
	}
	ltkalmaremailwindow = window.open(rootDir + 'lttemplates/emailpage.aspx?id=' + pageId + "&userid=" + userid,null,features);
}
function ClickFont(caller){
	var currentStyle = caller.options[caller.selectedIndex].value;
	var preview = document.getElementById("previewdiv");
	
	if(preview != null && currentStyle == "Ltkalmar_HighFont"){
		preview.style.fontFamily = "'Times New Roman', Courier, 'Courier New', serif";
	}else if(preview != null){
		preview.style.fontFamily = "Arial, Verdana, Helvetica, Tahoma";
	}
}
function ClickContrast(caller){
	var currentStyle = caller.options[caller.selectedIndex].value;
	var preview = document.getElementById("previewdiv");
	
	if(preview != null && currentStyle == "Ltkalmar_HighContrast"){
		preview.style.backgroundColor = "#006981";
		preview.style.color = "#F1AF00";
	}else if(preview != null && currentStyle == "Ltkalmar_LowContrast"){
		preview.style.backgroundColor = "#C0C0C0";
		preview.style.color = "#FFFFFF";
	}else if(preview != null){
		preview.style.backgroundColor = "#FFFFFF";
		preview.style.color = "#333";
	}
}
function OpenPrintPage(pageurl) {
	var height = 600;
	var width = 800;
	var left = (window.screen.width - width) / 2;
	var top = (window.screen.height - height) / 2;
	var features = "scrollbars=1,height=" + height + ",width=" + width + ",left=" + left + ",top=" + top;
	if(ltkalmarprintwindow && !ltkalmarprintwindow.closed){
		ltkalmarprintwindow.close();
	}
	ltkalmarprintwindow = window.open(pageurl,null,features);
}
function FocusThis(caller){
	caller.className = caller.className + " focus";
}
function UnFocusThis(caller){
	var strclass = caller.className;
	caller.className = strclass.substring(0,strclass.indexOf("focus"));
}
function ToggleVisiblity(callerid){ 	
	var caller = document.getElementById(callerid);
	var strclass = caller.className;
	if(strclass.indexOf("hidden")== -1)
		caller.className = caller.className + " hidden"; 
	else
		caller.className = strclass.substring(0,strclass.indexOf("hidden"));
}
function ClickFont(caller){
	var currentStyle = caller.options[caller.selectedIndex].value;
	var preview = document.getElementById("customizepreview");
	
	if(preview != null && currentStyle == "ltkalmar_HighFont"){
		preview.style.fontFamily = "'Times New Roman', Courier, 'Courier New', serif";
	}else if(preview != null){
		preview.style.fontFamily = "Arial, Verdana, Helvetica, Tahoma";
	}
}
function ClickContrast(caller){
	var currentStyle = caller.options[caller.selectedIndex].value;
	var preview = document.getElementById("customizepreview");
	
	if(preview != null && currentStyle == "ltkalmar_HighContrast"){
		preview.style.backgroundColor = "#181D3F";
		preview.style.color = "#fff";
	}else if(preview != null && currentStyle == "ltkalmar_LowContrast"){
		preview.style.backgroundColor = "#CFCFCF";
		preview.style.color = "#FFFFFF";
	}else if(preview != null){
		preview.style.backgroundColor = "#FFFFFF";
		preview.style.color = "#000";
	}
}
function doClick(buttonName,e) {
    var key;
    if(window.event)
        key = window.event.keyCode;
    else
        key = e.which;
    if (key == 13) {
        var btn = document.getElementById(buttonName);
        if (btn != null) {
            btn.click();
            event.keyCode = 0
        }
    }
}