
function ShowEmail(user, domain, anchor) {
	var OutText = '';
	OutText += '<a href="mailto:' + user + '@' + domain + '">';
	if (anchor != '') OutText += anchor;
	else OutText += user + '@' + domain;
	OutText  += '</a>';
	document.write(OutText);
}

function ShowEmailBySubject(user, domain, anchor, subject) {
	var OutText = '';
	OutText += '<a href="mailto:' + user + '@' + domain + '?subject=' + subject + '">'
	if (anchor != '') OutText += anchor;
	OutText  += '</a>';
	document.write(OutText);
}

function externalLinks() { 
	if (!document.getElementsByTagName) return; 
 	var anchors = document.getElementsByTagName("a"); 
 	for (var i=0; i<anchors.length; i++) { 
   		var anchor = anchors[i]; 
   		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") 
     			anchor.target = "_blank"; 
	 } 
} 
window.onload = externalLinks;


var EP_images = new Array(
        "carmichael_1.jpg", 
        "carmichael_2.jpg",
        "carmichael_3.jpg",
        "carmichael_4.jpg",
        "carmichael_5.jpg",
        "carmichael_7.jpg",
        "carmichael_8.jpg"
);

var OS_images = new Array(
        "carmichael_9.jpg", 
        "carmichael_10.jpg",
        "carmichael_11.jpg",
        "carmichael_12.jpg"
);

var TL_images = new Array(
        "carmichael_13.jpg", 
        "carmichael_14.jpg",
        "carmichael_15.jpg",
        "carmichael_16.jpg"
);

function RandomImage(img_name) {
    var l = img_name.length;
    var rnd_no = Math.round((l-1)*Math.random());
    return(img_name[rnd_no])
}

// Check the page and call the main image.
function MainImage()
{
    var addr_str;
    var current_location = window.parent.location.href;
    if ((current_location.indexOf('OS_')!= -1) || (current_location.indexOf('os_')!= -1)) 
        addr_str="OS"
    else if ((current_location.indexOf('TL_')!= -1) || (current_location.indexOf('tl_')!= -1)) 
        addr_str="TL"    
    else if (current_location.indexOf('?division=')!= -1) 
        addr_str=current_location.substring(current_location.indexOf('?division=')+10, current_location.length); 
    else if (current_location.indexOf('&division=')!= -1) 
        addr_str=current_location.substring(current_location.indexOf('&division=')+10, current_location.length); 
    else
        addr_str = "";

    if ((addr_str == "OS") || (addr_str == "os"))
        document.write("<img src='i/pics/" + RandomImage(OS_images)+ "'  alt='' />");  
    else if ((addr_str == "TL") || (addr_str == "tl"))
        document.write("<img src='i/pics/" + RandomImage(TL_images)+ "'  alt='' />");  
    else
        document.write("<img src='i/pics/" + RandomImage(EP_images)+ "'  alt='' />");
}

function VirtualnetChat() 
{
    if(window.location.hostname != 'apollo')
        //Online
        document.write('<iframe src="http://' + window.location.hostname + '/chat.aspx" id="chatframe" height="280" width="240" frameborder="0" scrolling="no"></iframe>');
    else
        //for Testing
        document.write('<iframe src="http://' + window.location.hostname + '/CarmichaelUK/chat.aspx" id="chatframe" height="280" width="240" frameborder="0" scrolling="no"></iframe>');
}

function doHidePopUp() {
	popdiv=document.getElementById("divpopup")
	popdiv.style.visibility="hidden"
	}
	
function doShowPopUp(){
	popdiv=document.getElementById("divpopup")
	popdiv.style.left="50%"
	popdiv.style.marginLeft="-223px"
	if ((is_ie5up) && (is_mac)){ //fix for ie-mac does not accept popdiv.style.top="50%"
		popdiv.style.top="0px"
		popdiv.style.marginTop="0px"
	}else{
		popdiv.style.top="50%"
		popdiv.style.marginTop="-132px"
	}
	popdiv.style.visibility="visible"
}

function show_hide(strElem,selectedValue) {
    theElem = document.getElementById(strElem);
    if(!theElem) { return false }

    if(selectedValue == "0")
	    theElem.style.display = "";
    else 
	    theElem.style.display = "none";
}

function show_hide2(strElem,selectedValue) {
    theElem = document.getElementById(strElem);
    if(!theElem) { return false }
    // 12 - Referral, 19 - Web Search Engine
    if(selectedValue == "12" || selectedValue == "19")
    {
        //document.getElementById("ctl00_ContentPlaceHolder1_ValidatorReferrer").style.display = "";
        theElem.style.visibility = "visible";
	    //theElem.style.display = "";
	}
    else 
    {
        //document.getElementById("ctl00_ContentPlaceHolder1_ValidatorReferrer").style.display = "none";
        theElem.style.visibility = "hidden";
	    //theElem.style.display = "none";
    }
}




