function getObj(nm) {
	if (document.getElementById) {
		return document.getElementById(nm);
	} else if (document.all) {
		return document.all[nm];
	} else {
		return eval("document." + nm);
	}
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}

function download_document(filepath) {
	var newdocpage=window.open("document_download.asp?doc=" + escape(filepath), "downloaddocument", "width=400,height=280,locationbar=0,menubar=0,personalbar=0,status=0,scrollbars=0,resizable=0");
}

function open_document(filepath) {
	var newdocpage=window.open(filepath, "downloaddocument", "width=400,height=250,locationbar=0,menubar=0,personalbar=0,status=0,scrollbars=0,resizable=0");
}

function viewmappage(pageid, pagename){
	document.location.href = pagename + '?pageid=' + pageid
}
function viewpage(pageid){
	var newwin=window.open("?pageid=" + pageid,"contact", "width=770,height=700,locationbar=0,menubar=0,personalbar=0,status=1,scrollbars=1,resizable=1")
}


/*var rand1 = 0;
var useRand = 0;
var images = new Array();
images[0] = new Image();
images[0].src = "graphics/img_header0.jpg";
images[1] = new Image();
images[1].src = "graphics/img_header1.jpg";
images[2] = new Image();
images[2].src = "graphics/img_header2.jpg";
images[3] = new Image();
images[3].src = "graphics/img_header3.jpg";
images[4] = new Image();
images[4].src = "graphics/img_header4.jpg";

function swapPic() {
	var imgnum = images.length - 1;
do {
	var randnum = Math.random();
	rand1 = Math.round((imgnum - 1) * randnum) + 1;
} while (rand1 == useRand);
	useRand = rand1;
	document.header_img.src = images[useRand].src;
}*/

function ShowAlt(altID, testrep) {
	//object = document.getElementById('ClientAltText_' + altID);
	getObj('ClientAltText_' + altID).style.visibility = "visible";
	var topmarg = (testrep*23)
	getObj('ClientAltText_' + altID).style.top=topmarg + "px";
	//document.getElementById('ClientAltBullet_' + altID).style.top=event.clientY+10;
}

function HideAlt(altID) {
	//object = getObj('ClientAltText_' + altID);
	getObj('ClientAltText_' + altID).style.visibility = "hidden";
}

function show_phone(message, location) {
	//getObj("header_phonenum").innerHTML = message;
	getObj("header_" + location).innerHTML = message;
	//getObj("header_phonenum").style.display = "block";
	//alert(message);
}

function hide_phone(message, location) {
	getObj("header_" + location).innerHTML = message;
	//alert(message);
}

function add_recip() {
	document.forms.enewssign.submit()
}
function display_iconname(txtstring) {
	getObj("template_icon_name").innerHTML = txtstring;
}

function clear_searchbox() {
	getObj("searchstring").value = ""
}

function sitemap() {
	//alert("Coming Very Soon!");
	document.location.href = "sitemap.asp";
}

function initiate_search() {
	document.forms['site_search'].submit();
}

function Print_Page() {
	window.print();
}

function Email_Page() {
	var emailpage=window.open("emailpage.asp?pageurl=" + escape(document.location.href), "emailpage", "width=400,height=390,locationbar=0,menubar=0,personalbar=0,status=0,scrollbars=0,resizable=0");
}

function enews_signup() {
	var enewssignup=window.open("byteback.asp?pageurl=" + escape(document.location.href), "byteback", "width=400,height=350,locationbar=0,menubar=0,personalbar=0,status=0,scrollbars=0,resizable=0");
}
//not in use hds changed the pop up to a floater window
function showmap(mapurl) {
	var viewmap=window.open(mapurl, "OfficeMap", "width=550,height=520,locationbar=0,menubar=0,personalbar=0,status=0,scrollbars=0,resizable=0");
} 

//	Check Email Function For Form Validation Code

function checkEmail(email)
{
	email = email.toLowerCase(); 

	if (email.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/)) {
		return true;
	} else {
		return false;
	}
}


// Download Case Study PDF
// JQuery 1.1.3 used (version matters)

function DownloadCaseStudy(filename, divID)
{
    hasSignUp = getCookie("CaseStudySignUp")
    if(hasSignUp == "") {
        var htmlc = '<fieldset class="clearer">';
        htmlc += '<div id="ClientValidationSummary"></div>'
        htmlc += '<p>Please complete the fields below before proceeding. Once complete, the document will be emailed to the address which you provide.</p>';
        htmlc += '<form action="http://www.byteart.com/downloadDocs.aspx" method="post" id="fm' + divID + '" >';
        htmlc += '<ul class="form">';
        htmlc += '<li><input name="requiredfile" value="' + filename + '" type="hidden" /><li>'
        htmlc += '<li><label for="name">your name*:</label><input class="fields validator-required" title="Name - your name" type="text" name="name" id="name" /></li>';
        htmlc += '<li><label for="company">your company name:</label><input class="fields" type="text" name="company" /></li>';
        htmlc += '<li><label for="email">your email address*:</label><input class="fields validator-required validator-email" type="text" id="email" title="Email - please provide a valid email address" name="email" /></li>';
        htmlc += '<li><label for="phone">your phone number:</label><input class="fields" type="text" name="phone" /></li>';
        htmlc += '<li class="marginbottom"><input class="checkbox" type="checkbox" checked="checked" name="contactme" value="yes" />Would you like a Byte Art representative to contact you?</li>';
        
        htmlc += '<li><input class="button caseStudySignUpHiddenBtn" type="submit" value="Submit" /></li>';
        htmlc += '</ul></form></fieldset>';
        
        $("#" + divID).html(htmlc);
        //alert($("#" + divID));
        if($("#" + divID).is(":hidden")) {
            if($(".exclusive").is(":visible")) { $(".exclusive:visible").empty(); $(".exclusive:visible").fadeOut('fast'); }
            $("#" + divID).slideDown('fast'); 
            if($("#fm" + divID).length != 0) { $("#fm" + divID).validationAideEnable(); }
        }
        else { $("#" + divID).fadeOut('fast'); }
    }else {
        var htmlc = '<fieldset class="clearer">';
        htmlc += '<form action="downloadDocs.aspx" method="post" id="fm' + divID + '" >';
        htmlc += '<input name="requiredfile" value="' + filename + '" type="hidden" />';
        htmlc += '<input name="name" value="' + getCookie("CaseStudyVisitorName") + '" type="hidden"/>';
        htmlc += '<input name="email" value="' + getCookie("CaseStudyVisitorEmail") + '" type="hidden"/>';
        htmlc += '</fieldset>';
        
        $("#" + divID).html(htmlc);
        if($(".exclusive").is(":hidden")) { $("#" + divID).fadeOut('fast'); }
        $("#fm" + divID).submit();
    }
}

function showSignUpFm()
{
    htmlf = '<ul class="form">';
    htmlf += '<li class="NoScript JsShowUp"><label for="name">first name:</label>';
    htmlf += '<input class="fields validator-required" title="Name - your first name" id="name" type="text" name="name" />';
    htmlf += '<input type="hidden" name="status" value="add" />';
    htmlf += '<input type="hidden" name="newsletter_code" value="MAIN01" /></li>';
    htmlf += '<li class="NoScript JsShowUp"><label for="lastname">last name:</label>';
    htmlf += '<input class="fields validator-required" title="Email - your last name" id="lastname" type="text" name="lastname" />';
    htmlf += '<li class="NoScript JsShowUp"><label for="email">email address:</label>';
    htmlf += '<input class="fields validator-required validator-email" title="Email - please enter a valid email address" id="email" type="text" name="email" />';
    htmlf += '<input type="hidden" name="confirmCode" value="noneed" /></li>';
    htmlf += '<li id="BtnSignUp" ><input class="button" type="submit" value="send" /></li>';
    htmlf += '</ul>';
    
    $("#FmSignUp").empty();
    $("#FmSignUp").html(htmlf);
}

function showMap()
{
    if($("#mapContainer").is(":visible")) { 
        $("#mapContainer").slideUp(50);
        $("#MapBtnTxt").empty();
        $("#MapBtnTxt").html('view map'); 
    }
    if($("#mapContainer").is(":hidden")) {
        $("#mapContainer").slideDown(50);
        $("#MapBtnTxt").empty();
        $("#MapBtnTxt").html('hide map');
    }
}