// Function to 'activate' images.
 
function swap(img,imgsrc){
	document[img].src=[imgsrc];
}

//Preload Images
//These are all the rollovers 
if (document.images) {            // Active Images
           	tile_on = new Image(); 
            tile_on.src = "unm_impressions/impressions_imgs/sekure_tileon.gif";
			about_on = new Image(); 
            about_on.src = "unm_nav/unm_about_on.gif";
			client_on = new Image(); 
            client_on.src = "unm_nav/unm_client_on.gif";
			contact_on = new Image(); 
            contact_on.src = "unm_nav/unm_contact_on.gif";
			impression_on = new Image(); 
            impression_on.src = "unm_nav/unm_impressions_on.gif";
			services_on = new Image(); 
            services_on.src = "unm_services/unm_services_on.gif";
			branding_on = new Image(); 
            branding_on.src = "unm_services/branding_on.gif";
			dvdprod_on = new Image(); 
            dvdprod_on.src = "unm_services/dvdproduction_on.gif";
			flashpres_on = new Image(); 
            flashpres_on.src = "unm_services/flashpresentation_on.gif";
			print_on = new Image(); 
            print_on.src = "unm_services/printdesign_on.gif";
			procopy_on = new Image(); 
            procopy_on.src = "unm_services/procopywriting_on.gif";
			webdes_on = new Image(); 
            webdes_on.src = "unm_services/webdesign_on.gif";
			methover_on = new Image(); 
            methover_on.src = "unm_methodology/overview_on.gif";
			methscope_on = new Image(); 
            methscope_on.src = "unm_methodology/scope_on.gif";
			methdesign_on = new Image(); 
            methdesign_on.src = "unm_methodology/design_on.gif";
			methbuild_on = new Image(); 
            methbuild_on.src = "unm_impresssions/build_on.gif";
			impblack_on = new Image(); 
            impblack_on.src = "unm_impresssions/ultimateathlete_on.gif";
			impsekure_on = new Image(); 
            impsekure_on.src = "unm_impresssions/sekure_on.gif";
			impcasa_on = new Image(); 
            impcasa_on.src = "unm_impresssions/casadelcabo_on.gif";
			coninfo_on = new Image(); 
            coninfo_on.src = "unm_contact/contactinfo_on.gif";
			conrfp_on = new Image(); 
            conrfp_on.src = "unm_contact/rfp_on.gif";
			clilogin_on = new Image(); 
            clilogin_on.src = "unm_clients/extranet_access.gif";
}

// ===============================
// Funtion for Dynamic Hilite

var prevSelected = 1;
var imgPrefix = "sekure_tile";
var imgPostfix = ".gif";
var imgPath = "unm_impressions/impressions_imgs/";
var isChanging = false;
var totalImages = 6;

function setVar (path, prefix, imgNum) {
    imgPath = path;
	imgPrefix = prefix;
	totalImages = imgNum
}

function myClear() {
	
	var img = "";
	var imgsrc = "";
	var i;
	for (i=1; i<=totalImages; i++) {
		img = imgPrefix + i;
		imgsrc = imgPath + imgPrefix + "off" + imgPostfix;
		swap(img, imgsrc);
	}
}

function sleep() {
	if (!isChanging) {
		swap((imgPrefix + prevSelected), (imgPath + imgPrefix + "on" + imgPostfix));
	}
}

function myRollOver(id, flag) {
	myClear();
	if (flag) {
		isChanging = true;
		swap((imgPrefix + id), (imgPath + imgPrefix + "on" + imgPostfix));
	}
	else {
		isChanging = false;
		setTimeout('sleep()', 100);
	}
}

function myClick(id) {
	myClear();
	prevSelected = id;
	swap((imgPrefix + prevSelected), (imgPath + imgPrefix + "on" + imgPostfix));
}

// end Dynamic Hilite
// ===============================

// New Window w/location

function winpop(w,h,url,winnm){
    var xpos=(screen.width)/2-(w/2);
    var ypos=(screen.height)/2-(h/2);
	var features="toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+xpos+",top="+ypos+"";
	var x=window.open(url,winnm,features);
	x.focus();
}

function scrollpop(w,h,url,winnm){
    var xpos=(screen.width)/2-(w/2);
    var ypos=(screen.height)/2-(h/2);
	var features="toolbar=no,status=yes,menubar=no,location=no,scrollbars=yes,resizable=no,width="+w+",height="+h+",left="+xpos+",top="+ypos+"";
	var x=window.open(url,winnm,features);
	x.focus();
	
}

// Functions to check form validity
function isEmail(elm) {
	if (elm.value.indexOf("@") != "-1" &&
		elm.value.indexOf(".") != "-1" &&
		elm.value != "")
		return true;
		else return false;
}

function isFilled(elm) {
	if (elm.value == "" ||
		elm.value == null)
	return false;
	else return true;
}

function formFilled(form) {
var errorMessage, valid_func;
errorMessage = "Please fill in a valid \n \n";
valid_func = 1;
	if (isEmail(form.email) == false) {
	errorMessage += "Email Address\n";
	valid_func = 0;
	form.email.focus();
	}
	if (isFilled(form.FirstName) == false) {
	errorMessage += "First Name\n";
	valid_func = 0;
	form.FirstName.focus();
	}
	if (isFilled(form.LastName) == false) {
	errorMessage += "Last Name\n";
	valid_func = 0;
	form.LastName.focus();
	}
	if (isFilled(form.Position) == false) {
	errorMessage += "Position\n";
	valid_func = 0;
	form.Position.focus();
	}
	if (isFilled(form.Company_Name) == false) {
	errorMessage += "Company Name\n";
	valid_func = 0;
	form.Company_Name.focus();
	}
	if (isFilled(form.Contact_Telephone) == false) {
	errorMessage += "Contact Telephone\n";
	valid_func = 0;
	form.Contact_Telephone.focus();
	}
	errorMessage += "\n so we can reply to your request.";
	if (valid_func == 0) {
		alert(errorMessage);
		return false;
	}
 	else 
 		return true;
}
