﻿// Preload nav images to prevent flickering on :hover state
img_forum_on                = new Image();  
img_forum_on.src            = 'images/nav/Forum-on.gif';
img_forum_off               = new Image();  
img_forum_off.src           = 'images/nav/Forum.gif';

img_articles_on             = new Image();  
img_articles_on.src         = 'images/nav/Articles-on.gif';
img_articles_off            = new Image();  
img_articles_off.src        = 'images/nav/Articles.gif';

img_expert_tips_on          = new Image();
img_expert_tips_on.src      = 'images/nav/Expert-tips-on.gif';
img_expert_tips_off         = new Image();
img_expert_tips_off.src     = 'images/nav/Expert-tips.gif';

img_podcast_on              = new Image();
img_podcast_on.src          = 'images/nav/Podcast-on.gif';
img_podcast_off             = new Image();
img_podcast_off.src         = 'images/nav/Podcast.gif';

img_videos_on               = new Image();
img_videos_on.src           = 'images/nav/Videos-on.gif';
img_videos_off              = new Image();
img_videos_off.src          = 'images/nav/Videos.gif';

img_submit_own_on           = new Image();
img_submit_own_on.src       = 'images/nav/Submit-your-own-article-on.gif';
img_submit_own_off          = new Image();
img_submit_own_off.src      = 'images/nav/Submit-your-own-article.gif';

img_green_rc_on             = new Image();
img_green_rc_on.src         = 'images/nav/Green-building-resource-center-on.gif';
img_green_rc_off            = new Image();
img_green_rc_off.src        = 'images/nav/Green-building-resource-center.gif';

// Submit your own article JS
function sendToAFriendPopUp(url) {
    Modalbox.show('SendToAFriend.aspx', {title: 'Send To A Friend', method: 'post', params: {pgurl : url} });
}
function submitArticlePopUp() {
    Modalbox.show('SubmitArticle.aspx', {title: 'Submit An Article'});
}
function validateFieldNotNull(fieldID) {
    valid = true;
    if ($F(fieldID) == null || $F(fieldID) == '') {
        Element.setStyle(fieldID, {backgroundColor: '#ffcccc'});
        valid = false;
    }
    return valid;
}
function sendToFriend() {
    // Validate the fields
    valid_user_name      = validateFieldNotNull('user_name');
    valid_user_email     = validateFieldNotNull('user_email');
    valid_friend_email     = validateFieldNotNull('friend_email');
    valid_message   = validateFieldNotNull('message');
    if ( valid_user_name && valid_user_email && valid_friend_email && valid_message ) {
         Modalbox.show('SendToAFriend-ThankYou.aspx', { 
		    title: 'Sent To A Friend',
		    method: 'post',
		    params: Form.serialize('SubmitArticleForm')
	    });
    }
}
function emailArticle() {
    // Validate the fields
    valid_name      = validateFieldNotNull('name');
    valid_email     = validateFieldNotNull('email');
    valid_article   = validateFieldNotNull('article');
    if ( valid_name && valid_email && valid_article ) {
         Modalbox.show('SubmitArticle-ThankYou.aspx', { 
		    title: 'Article has been submited',
		    method: 'post',
		    params: Form.serialize('SubmitArticleForm')
	    });
    }
}