

// global variables 

var is_msie = (navigator.appName == "Microsoft Internet Explorer") ? true : false;




function go_page(page_name) {
top.window.location.href=page_name;
}

function go_page_replace(page_name) {
top.window.location.replace(page_name);
}




function get_el(d) {
	return document.getElementById(d);
}

function hide_div(d) {
	document.getElementById(d).style.display = "none";
}

function show_div(d) {
	document.getElementById(d).style.display = "block";
}


function show_hide_div(id,zindex) {
var el = document.getElementById(id);
	if (el.style.display != "none") {
	el.style.display = "none";
		if (zindex) {
		el.style.zIndex = "0";
		}
	}
	else {
	el.style.display = "";
		if (zindex) {
		el.style.zIndex = zindex;
		}
	}
}



function show_project_image(what) {
	if (what == 'next') {
	} else {
	divid = document.getElementById('project_image_layer'+what);
	show_hide_div(divid);
	}
}





var option_divs = ['div_sizes','div_finishes','div_hanging','div_techniques'];

function pop_div(id) {
	for(i=0;i<option_divs.length;i++) {
		if (get_el(option_divs[i])) {
		get_el(option_divs[i]).style.display = 'none';
		}
	}
	get_el(id).style.display = 'block';
}

function preload_img(img_path) {
var img_file = new Image();
img_file.src = img_path;
}



var fade_timer;
var div_fadeamt = 0;
var fade_div_name;

function fade_div(div_name,direction,max_opacity) {
	max_opacity = (!max_opacity) ? 10 : max_opacity;
	if (!is_msie) {
	fade_div_name = div_name;
var divobj = document.all ? document.all[div_name] : document.getElementById ? document.getElementById(div_name) : "";
	//clearTimeout(fade_timer);
	if (direction == 'in') {
		divobj.style.display = "";
		//show_hide_div(fade_div_name,'1000');
		if(div_fadeamt < max_opacity) {
		div_fadeamt++;
		divobj.style.filter = "alpha(opacity="+div_fadeamt*10+")";
		divobj.style.opacity = div_fadeamt/10;
		fade_timer = setTimeout("fade_div('"+fade_div_name+"','in',"+max_opacity+")",15);
		} else {
		clearTimeout(fade_timer);
		}
	} else if (direction == 'out') {
		if(div_fadeamt > 0) {
		div_fadeamt--;
		divobj.style.filter = "alpha(opacity="+div_fadeamt*10+")";
		divobj.style.opacity = div_fadeamt/10;
		fade_timer = setTimeout("fade_div('"+fade_div_name+"','out')",20);
		} else {
		clearTimeout(fade_timer);
		//show_hide_div(fade_div_name,'0');
		divobj.style.display = "none";
		div_fadeamt = 0;
		}
	}
	} else {
		show_hide_div(div_name,'100');
	}
}







// unique functions


function blog_images(blog_id) {
var url = '/blog-images.php?id=' + blog_id;

var width = '540';
var height = '600';
var windowName = 'blogWin' ;
var featureString = ',' + 'status=yes,toolbar=no,directories=no,location=no,resizable=yes,scrolling=yes,scrollbars=yes,favorites=no,menubar=no';

var x = Math.round((screen.availWidth - width) / 2);
var y = Math.round((screen.availHeight - height) / 2);
windowStuff = 'left=' + x + ',top=' + y + ',width=' + width + ',height=' + height + featureString;
return open (url, windowName, windowStuff);
}


function show_project_img(img_num,next) {
//alert(project_img_total);
	if (next) {
	next_num = (project_img_current == project_img_total-1) ? 0 : project_img_current+1;
	document.getElementById('project_image_layer'+img_num).style.display = 'none';	
	document.getElementById('project_image_layer'+(next_num)).style.display = 'block';
	project_img_current = (project_img_current == project_img_total-1) ? 0 : img_num+1;
	} else {
	next_num = img_num;
	document.getElementById('project_image_layer'+project_img_current).style.display = 'none';	
	document.getElementById('project_image_layer'+(next_num)).style.display = 'block';
	project_img_current = img_num;
	}
	
	for(i=0;i<project_img_total;i++) {
	document.getElementById('img_num_link'+i).className = 'link_main_nav';
	}
document.getElementById('img_num_link'+next_num).className = 'link_main_nav_on';
}	