// JavaScript Document
function the_find()
{
  document.the_find.submit();
}

function the_signup()
{
  document.the_signup.submit();
}

function the_comment()
{
  document.the_comment.submit();
}

function portfolio(id,w,h,image,title,caption,p_id){
var photo_title = id+'_title';
var photo_id = p_id;
var photo_caption = id+'_caption';
	document.getElementById("the_client_photo_matte").style.display = "block";
	document.getElementById(id).innerHTML = '<a href="javascript:voidoid(0);" onClick="javascript:matte_close();" title="click to hide this photo"><img src="'+image+'" width="'+w+'" height="'+h+'" title="'+title+'" border="0" /></a>';
	document.getElementById(photo_title).innerHTML = '<h2>'+title+'</h2>';
	document.getElementById(photo_caption).innerHTML = '<p>'+caption+'</p>';
}

function portfolio_client(id,w,h,image,title,caption,p_id,count){
var photo_title = id+'_title';
var photo_add = id+'_add';
var photo_id = p_id;
var input_id = 'input'+p_id;
var the_input_id = document.getElementById(input_id);
var label_id = 'label'+p_id;
var photo_caption = id+'_caption';
	document.getElementById("the_client_photo_matte").style.display = "block";
	// document.getElementById(id).innerHTML = '<img src="'+image+'" width="'+w+'" height="'+h+'" title="'+title+'" border="0" />';
	document.getElementById('photo_new_img').innerHTML = '<img src="'+image+'" width="'+w+'" height="'+h+'" title="'+title+'" border="0" />';
	document.getElementById(photo_title).innerHTML = '<h2 class="primary_h2">'+title+'</h2>';
	document.getElementById(photo_caption).innerHTML = '<p>'+caption+'</p>';
	// document.getElementById(photo_add).innerHTML = '<a href="javascript:c_label('+input_id+');">Add to Lightbox</a>';
new_lightbox(count);
if (the_input_id.checked != true) {
	// document.getElementById(photo_add).innerHTML = '<label for="'+input_id+'" onClick="c_label('+p_id+')" id="'+label_id+'">Add Photo to Lightbox</label>';
	document.getElementById(photo_add).innerHTML = '<a href="javascript:voidoid(0);" onClick="javascript:c_label('+p_id+')" id="'+label_id+'">Add Photo to Lightbox</a>';
	the_input_id.checked == true;
} else {
	// document.getElementById(photo_add).innerHTML = '<label for="'+input_id+'" onClick="c_label('+p_id+')" id="'+label_id+'">Remove Photo from Lightbox</label>';
	document.getElementById(photo_add).innerHTML = '<a href="javascript:voidoid(0);" onClick="javascript:c_label('+p_id+')" id="'+label_id+'">Remove Photo from Lightbox</a>';
}
}

function c_label(p_id) {
var input_id = 'input'+p_id;
var a_id = 'a'+p_id;
var l_id = 'list'+p_id;
var input_id = 'input'+p_id;
var the_input_id = document.getElementById(input_id);
the_input_id.click(); 
var input_null_id = 'input_null'+p_id;
var the_input_null_id = document.getElementById(input_null_id);
var li_id = document.getElementById(l_id);
if(li_id.className == 'p_hide') {
li_id.className = "p_show";
} else {
li_id.className = "p_hide";
}
bg_swap_moz(a_id);
label_swap(p_id);
the_input_null_id.click(); // Keep this last. MSIE freaks otherwise?
}

function label_swap(p_id) {
var label_id = 'label'+p_id;
var label_add = document.getElementById(label_id).innerHTML;
if(label_add == 'Add Photo to Lightbox') {
document.getElementById(label_id).innerHTML = 'Remove Photo from Lightbox';
} else {
document.getElementById(label_id).innerHTML = 'Add Photo to Lightbox';
}
}

function bg_swap_moz(a_id) {
var the_a_id = document.getElementById(a_id);
if(the_a_id.className != 'p_show')
the_a_id.className = 'p_show';
else
the_a_id.className = 'p_hide';
}

function check_two() { // This keeps the Selected Portfolio Images highlighted, even after submitting page and going back in History
frm = d.getElementById("the_form");
	for(i=0;i<frm.length;i++) {
		// reference to the elements of the form
		c = frm.elements;
		// loop over the length of those elements
		for(j=0;j<c.length;j++) {
			// if this element is a checkbox, do our thing

			if(c[j].getAttribute("type") == "checkbox") {
				// hide the original checkbox

				// set the <td> background class
				if(c[j].checked == false) {
					c[j].parentNode.className = "p_hide";
				} else {
					c[j].parentNode.className = "p_show";
				}
			}
		}
	}
}

function portfolio_promo(id,w,h,image,title,caption,p_id){
var photo_title = id+'_title';
var photo_id = p_id;
var photo_caption = id+'_caption';
	document.getElementById(id).innerHTML = '<img src="'+image+'" onclick="javascript:window.print();" width="'+w+'" height="'+h+'" title="'+title+'" border="0" />';
	document.getElementById(photo_title).innerHTML = '<h2>'+title+'</h2>';
	document.getElementById(photo_caption).innerHTML = '<p>'+caption+'</p>';
}
function matte_close() {
	document.getElementById("the_client_photo_matte").style.display = "none";
}