function hidediv(id)
{
    //safe function to hide an element with a specified id
    if (document.getElementById)
    {
        // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';
    }
    else
    {
        if (document.layers)
        {
           // Netscape 4
            document.id.display = 'none';
        }
        else
        {
           // IE 4
           document.all.id.style.display = 'none';
        }
    }
}
 function send_input_elements(doc)
 {

     //loop through all the form elements and display them by the input type then identify them by input name.
     var input_data = '';

     for (i = 0; i < doc . elements . length; i++)
     {
         var key = doc . elements[i] . name;
         if (doc.elements[i] . getAttribute('type') == 'radio')
         {
             	var id = doc. elements[i].id;
             	if (doc.elements[i].checked) { 

	                var value = doc . elements[i] .value;
	                input_data = input_data + doc . elements[i] . name + '=' +  value + '&';
				}
         } else {
         var value = doc . elements[i] . value ;
         input_data = input_data + doc . elements[i] . name + '=' +  value + '&';

         }

     }
     return input_data;
 }
 
 function $()
{
    var elements = new Array();
    for (var i = 0; i < arguments.length; i++)
        {
        var element = arguments[i];
        if (typeof element == 'string')
            element = document.getElementById(element);
        if (arguments.length == 1)
            return element;
        elements.push(element);
        }
    return elements;
}

 function getData(dataSource, divID, doc)
 {

	 if (XMLHttpRequestObject)
     {
     	
			
         eval("var obj = document.getElementById(divID);");

         XMLHttpRequestObject . open("POST", dataSource);
         XMLHttpRequestObject . setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');


         XMLHttpRequestObject . onreadystatechange = function ()
         {
             if (XMLHttpRequestObject . readyState == 4 && XMLHttpRequestObject . status == 200)
             {
                 obj . innerHTML = XMLHttpRequestObject . responseText;

					// Login Clause - refresh page if valid login.
                	if (divID == 'login_box' ) {
                 	window.location.reload(true);
                	}
                	///////
                	
             }
         }


         if ($(doc))
         {
             var input_data = send_input_elements($(doc));
         } else
         {
             input_data = null;
         }
         XMLHttpRequestObject . send(input_data);
     }
 }

function show_inline_div(id)
{
    //safe function to show an element with a specified id
    if (document.getElementById)
    {
        // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'inline';
    }
    else
    {
        if (document.layers)
        {
           // Netscape 4
            document.id.display = 'inline';
        }
        else
        {
            // IE 4
            document.all.id.style.display = 'inline';
        }
    }
}
function showdiv(id)
{
    //safe function to show an element with a specified id
    if (document.getElementById)
    {
        // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }
    else
    {
        if (document.layers)
        {
           // Netscape 4
            document.id.display = 'block';
        }
        else
        {
            // IE 4
            document.all.id.style.display = 'block';
        }
    }
}

function togglediv(id)
{
    //safe function to hide an element with a specified id
    if (document.getElementById)
    {
        // DOM3 = IE5, NS6
        if (document.getElementById(id).style.display == 'block') {
        document.getElementById(id).style.display = 'none';
        }
        if (document.getElementById(id).style.display == 'none') {
        document.getElementById(id).style.display = 'block';
        }
    }
    else
    {
        if (document.layers)
        {
           // Netscape 4
           if (document.id.display == 'none') {
            document.id.display = 'block';
            }
           if (document.id.display == 'block') {
            document.id.display = 'none';
            }
        }
        else
        {
           // IE 4
           if (document.all.id.style.display == 'none') {
           document.all.id.style.display = 'block';
           }
           if (document.all.id.style.display == 'block') {
           document.all.id.style.display = 'none';
           }
        }
    }
}

function validate_checkout_form()
{
		
		if(document.purchaseform.valid_user.value=='') {
		window.alert ('Please LOG IN or Create an Account.');
		return false;
		}
		if(document.purchaseform.card_number.value=='') {
		window.alert ('Please enter Credit Card #.');
		return false;
		}
		if(document.purchaseform.expire_month.value=='') {
		window.alert ('Please enter expiration month.');
		return false;
		}
		if(document.purchaseform.expire_year.value=='') {
		window.alert ('Please enter expiration year.');
		return false;
		}
}

function validate_register_form()
{
  
	if(document.registerform.user_name.value=='') {
	window.alert ("You must enter a username!");
	return false;
	}
	
	if(document.registerform.user_email.value=='') {
	window.alert ("You must enter your email address!");
	return false;
	}
	if(document.registerform.firstname.value=='') {
	window.alert ("Please enter your first name!");
	return false;
	}
	if(document.registerform.lastname.value=='') {
	window.alert ("Please enter your last name!");
	return false;
	}
	if(document.registerform.address1.value=='') {
	window.alert ("Please enter your street address!");
	return false;
	}
	
	if(document.registerform.city.value=='') {
	window.alert ("Please enter your city!");
	return false;
	}
	
	if(document.registerform.state.value=='') {
	window.alert ("Please enter your state!");
	return false;
	}
	
	if(document.registerform.zipcode.value=='') {
	window.alert ("Please enter your zip code!");
	return false;
	}

	if(document.registerform.homephone.value=='') {
	window.alert ("Please enter your home phone!");
	return false;
	}

}

function register_password_verification () {

	if(document.registerform.password.value=='') {
		window.alert ('Please enter a password.');
		return false;
		}
	
	if(document.registerform.password_verify.value=='') {
		window.alert ('Please Re-Enter your password.');
		return false;
		}
	
	if(document.registerform.password.value!=document.registerform.password_verify.value) {
		window.alert ('Passwords Dont Match!');
		return false;
		}	
	
}

function ChangeBGColor(field, color){
	document.getElementById(field).style.backgroundColor=color;
}

function viewpreview(theURL) { //v2.0
try {
msgWindow = open(theURL, 'FlashPlayer', 'width=730,height=610,left=0,top=0, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no');
if (msgWindow.opener == null) msgWindow.opener = self;
if (window.focus) msgWindow.focus();
	}
catch (e) {
		alert ("Popups are blocked");
	
}
}



// ==== LAMPCODER2005: RIGHT MENU FUNCTIONS ==== //
// define here list of used class names
var rm_class_names = {
  ch_over: 'over',
  ch_out: 'out'
};
// define here right menu table id
var rm_parent_id = 'right-menu';
var rm_childs_tagname = 'li';

// right menu style & event actions initialisation function
function RightMenu_Init()
{

  // get parent object
  var parent = document.getElementById(rm_parent_id);
  // if parent not found - exit
  if (!parent) return;

  // get all childs of this parents
  var childs = parent.getElementsByTagName(rm_childs_tagname);
  // run through all childs and :
  // 1) set class name to them
  // 2) set onMouseOver event action
  // 3) set onMouseOut event action
  for (var i = 0; i < childs.length; i++)
  {
    childs[i].className   = rm_class_names.ch_out;
    childs[i].onmouseover = RightMenu_OnMouseOver;
    childs[i].onmouseout  = RightMenu_OnMouseOut;
  }

  return;
}

function RightMenu_OnMouseOver(e)
{
  RightMenu_ChangeCellStyle(e,'over');
  return;
}

function RightMenu_OnMouseOut(e)
{
  RightMenu_ChangeCellStyle(e,'out');
  return;
}

function RightMenu_ChangeCellStyle(e, e_type)
{
  var e = e || window.event;
  if(!e) return;

  var td = e.target ? e.target : (e.srcElement ? e.srcElement : null);
  if (td == null) return;

  td.className = rm_class_names['ch_'+e_type];

  return;
}
function viewpreview(theURL) { //v2.0
try {
msgWindow = open(theURL, 'FlashPlayer', 'width=470,height=400,left=200,top=200, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no');
if (msgWindow.opener == null) msgWindow.opener = self;
if (window.focus) msgWindow.focus();
	}
catch (e) {
		alert ("Popups are blocked");
	
}
}
function UploaderPopUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=350,left = 440,top = 312');");
}

function check_session(field) {
if (arr.in_array(document.sessionform.sessiond_id)) {
alert('session exists!');
}
}
	
function switchid(id){	
hideallids();
showdiv(id);
}
	
function hideallids(){
//loop through the array and hide each element by id
for (var i=0;i<ids.length;i++){
hidediv(ids[i]);
}		  
}

function disableform(){  
var header_logo = document.getElementById('header_logo'); 
var upper_right = document.getElementById('upper_right');
var upper_left = document.getElementById('upper_left');
var catheaderbg = document.getElementById('catheaderbg'); 
var main_color = document.getElementById('main_color'); 
var light_shade = document.getElementById('light_shade'); 
var dark_shade = document.getElementById('dark_shade');
header_logo.disabled=true;
upper_right.disabled=true;
upper_left.disabled=true;
catheaderbg.disabled=true;
main_color.disabled=true;
light_shade.disabled=true;
dark_shade.disabled=true;
} 

function enableform(){  
var header_logo = document.getElementById('header_logo'); 
var upper_right = document.getElementById('upper_right');
var upper_left = document.getElementById('upper_left');
var catheaderbg = document.getElementById('catheaderbg'); 
var main_color = document.getElementById('main_color'); 
var light_shade = document.getElementById('light_shade'); 
var dark_shade = document.getElementById('dark_shade');
header_logo.disabled=false;
upper_right.disabled=false;
upper_left.disabled=false;
catheaderbg.disabled=false;
main_color.disabled=false;
light_shade.disabled=false;
dark_shade.disabled=false;
} 
function grayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';				 
  } else {
     dark.style.display='none';
  }
  }