//
// client_full_image.js
//
// by Mark Ward / Oasis Technologies
//
// for flannelworld.com
//
// 20071208
//



function hide_div(div_name) {
        document.getElementById(div_name).style.display='none';
}


function show_div(div_name) {
        document.getElementById(div_name).style.display='block';
}


fi_orig_state="";

function show_cfi_div() {
        make_full_size("fi_translucence");
	fi_orig_state=document.getElementById(fi_translucence).style.display;
        show_div("fi_translucence");
        show_div("client_full_image_div");
}


function hide_cfi_div() {
        hide_div("client_full_image_div");
	if (fi_orig_state=="none") {
	        hide_div("fi_translucence");
	}
}

N = (document.all) ? 0 : 1;


var request;


function xcreateRequest() {
    request = new XMLHttpRequest();
  if (!request)
    alert("Error initializing XMLHttpRequest!");
}



function createRequest() {
  try {
    request = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        request = false;
      }
    }
  }

  if (!request)
    alert("Error initializing XMLHttpRequest!");
}


function client_display_full_notion_image(id) {
        createRequest();
        document.getElementById("full_image").src="http://www.flannelworld.com/Images/ajax-load.gif";
        var myurl = "/ajax/cl_fi_n_module.php?id="+id;
        request.open("GET",myurl, true);
        request.onreadystatechange =fin_handle_response;
        request.send(null);
}

function client_display_full_image(id) {
        get_doc_vert_pos();
        show_div("client_full_image_div");
        document.getElementById("client_full_image_div").style.top=doc_vert_pos;
        //document.getElementById("full_image").src="http://www.flannelworld.com/Images/blank.gif";
        document.getElementById("full_image").src="http://www.flannelworld.com/Images/ajax-load.gif";
        createRequest();
        var myurl = "/ajax/cl_fi_module.php?id="+id;
        request.open("GET",myurl, true);
        request.onreadystatechange =fi_handle_response;
        request.send(null);
}


var doc_vert_pos;


function get_doc_vert_pos() {
        // navigator.appVersion;
        // MSIE 7.0
        if(navigator.appName == "Netscape") {
                doc_vert_pos=window.pageYOffset;
        }
        else if(navigator.appName == "Microsoft Internet Explorer") {
                // works in ie7
                doc_vert_pos=document.documentElement.scrollTop;
                //doc_vert_pos=document.body.scrollTop;
        }
        doc_vert_pos+="px";
        return doc_vert_pos;
}


var window_width;
var window_height;
var doc_height;


function get_window_dimensions() {
        if(navigator.appName == "Netscape") {
                window_width = window.innerWidth;
                window_height = window.innerHeight;
                doc_height = document.body.parentNode.clientHeight;
                doc_height = document.body.parentNode.scrollHeight;
        }
        else if(navigator.appName == "Microsoft Internet Explorer") {
                window_width = document.body.clientWidth;
                window_height = document.body.clientHeight;
                doc_height = document.body.scrollHeight;
        }
}


function fi_handle_response() {
        if(request.readyState==4) {
                var xmlDoc = request.responseXML;
                document.getElementById("full_image").src=xmlDoc.getElementsByTagName("data")[0].firstChild.nodeValue;
                if (xmlDoc.getElementsByTagName("material_name")[0].firstChild.nodeValue) {
                        document.getElementById("fi_material").innerHTML=xmlDoc.getElementsByTagName("material_name")[0].firstChild.nodeValue;
                }
                show_div("client_full_image_div");
        }
}

function fin_handle_response() {
        if(request.readyState==4) {
                var xmlDoc = request.responseXML;
                document.getElementById("full_image").src=xmlDoc.getElementsByTagName("data")[0].firstChild.nodeValue;
                document.getElementById("fi_prod_name").innerHTML=xmlDoc.getElementsByTagName("product_name")[0].firstChild.nodeValue;
                get_doc_vert_pos();
                document.getElementById("client_full_image_div").style.top=doc_vert_pos;
                show_div("client_full_image_div");
        }
}

function make_full_size(div_name) {
        get_window_dimensions();
        document.getElementById(div_name).style.width=window_width+"px";
        document.getElementById(div_name).style.height=doc_height+"px";
}

