function getposOffset(overlay, offsettype){
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

var callout = "";

function printPage() {
	if(callout != "" && callout != "printCallout") {
		document.getElementById(callout).style.display = "none";
	}
	obj = document.getElementById("printCallout");
	obj2 = document.getElementById("print");
	temp = getposOffset(obj2, "top") + 16;
	temp2 = getposOffset(obj2, "left") - 165;
	obj.style.top = temp + "px";
	obj.style.left = temp2 + "px";
	obj.style.display = "block";
	callout = "printCallout";
}
function emailPage() {
	if(callout != "" && callout != "emailCallout") {
		document.getElementById(callout).style.display = "none";
	}
	obj = document.getElementById("emailCallout");
	obj2 = document.getElementById("email");
	temp = getposOffset(obj2, "top") + 16;
	temp2 = getposOffset(obj2, "left") - 185;
	obj.style.top = temp + "px";
	obj.style.left = temp2 + "px";
	obj.style.display = "block";
	callout = "emailCallout";
}
function subscribePage() {
	if(callout != "" && callout != "subscribeCallout") {
		document.getElementById(subscribe).style.display = "none";
	}
	obj = document.getElementById("subscribeCallout");
	obj2 = document.getElementById("subscribe");
	temp = getposOffset(obj2, "top") - 180;
	temp2 = getposOffset(obj2, "left") + 0;
	obj.style.top = temp + "px";
	obj.style.left = temp2 + "px";
	obj.style.display = "block";
	callout = "subscribeCallout";
}
function imagePage() {
	if(callout != "" && callout != "imageCallout") {
		document.getElementById(callout).style.display = "none";
	}
	obj = document.getElementById("imageCallout");
	obj2 = document.getElementById("image");
	temp = getposOffset(obj2, "top") - 300;
	temp2 = getposOffset(obj2, "left") - 246;
	obj.style.top = temp + "px";
	obj.style.left = temp2 + "px";
	obj.style.display = "block";
	callout = "imageCallout";
}

function hide(which) {
	document.getElementById(which).style.display = "none";
	callout = "";
}
/**
 * Creates Printable Format for Articles
 */
function printable(form) {
	hide('printCallout');
	var choice;
	for (counter = 0; counter < form.pImages.length; counter++)
	{
		if (form.pImages[counter].checked)
			choice = counter; 
	}
	var url = location.href;
	var print;
	if(url.indexOf('?') != -1) print = '&print=';
	else print = '?print=';
	
	if (form.pImages[choice].value == "no")
	{
		//setActiveStyleSheet('printable');
		window.open(location.href + print + '1');
	}
	else if (form.pImages[choice].value == "yes")
	{
		//setActiveStyleSheet('printable');
		window.open(location.href + print + '2');
	}
	return false;
}
/**
 * Determines which CSS file to call for Articles
 */
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  //alert('Query Variable ' + variable + ' not found');
}

/**
 *Check Go Button State on Samples page 
 */
function CheckGoButtonState() {
	//alert($('range').selectedIndex);
	if (jQuery('#range').attr("selectedIndex") == 0 || typeof jQuery('#range').attr('selectedIndex') == "undefined") {
		//Disable the Go button
		jQuery('#btnGo_active').hide();
		jQuery('#btnGo_inactive').show();
	} else {
		//Check if the Go button is already enabled
		//If it isn't then enable it
		if (jQuery('#btnGo_active').is(':hidden')) {
			jQuery('#btnGo_inactive').hide();
			jQuery('#btnGo_active').show();
		}
	}
}

/**
 * Clicking the 'Go' button on the samples page
 */
function Go() {
	//var options = jQuery('#range').options;
	//window.location=options[jQuery('#range').selectedIndex].value;
	location.href = jQuery('#range').val();
}





function savePage() {

	obj = document.getElementById("saveCallout");
	obj2 = document.getElementById("save");
	temp = getposOffset(obj2, "top") + 142;
	temp2 = getposOffset(obj2, "left") - 200;
	obj.style.top = temp + "px";
	obj.style.left = temp2 + "px";
	obj.style.display = "block";
	callout = "saveCallout";
}
function savePage2() {
	if(callout != "" && callout != "saveCallout") {
		document.getElementById(callout).style.display = "none";
	}
	obj = document.getElementById("saveCallout");
	obj2 = document.getElementById("save");
	temp = getposOffset(obj2, "top") + 15;
	temp2 = getposOffset(obj2, "left") + 40;
	obj.style.top = temp + "px";
	obj.style.left = temp2 + "px";
	obj.style.display = "block";
	callout = "saveCallout";
}
function hide(which) {
	document.getElementById(which).style.display = "none";
	callout = "";
}
function selectFolder(which){
	if ( which == "e" ) jQuery('#existingFolder').attr("checked","true");
	else if ( which == "n" ) jQuery('#newFolder').attr("checked","true");
}
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}
function sendToFlash (pathToSwf,version) {
	thisMovie("printables_print3x").printfp(pathToSwf,version);
}
