// JavaScript Document


/***********************************************
* Highlight Table Cells Script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Specify highlight behavior. "TD" to highlight table cells, "TR" to highlight the entire row:
var highlightbehavior="TD"

var ns6=document.getElementById&&!document.all
var ie=document.all

function eventTrigger(e)
{
  if (!e)
  e = event;
  return e.target || e.srcElement;
}

function changeto(e,highlightcolor){
	source=ie? event.srcElement : e.target
	if (source.tagName=="TABLE")
	return
	while(source.tagName!=highlightbehavior && source.tagName!="HTML")
	source=ns6? source.parentNode : source.parentElement
	if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
	source.style.backgroundColor=highlightcolor
	source.style.cursor = "hand";
	}

function contains_ns6(master, slave) { //check if slave is contained by master
return;
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}

function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
	source.style.backgroundColor=originalcolor
	source.style.cursor = "hand";
}

function print_r(obj) {
  output = "";
  for(i in obj) {
    output += "<br>" + i + "=" + obj[i];
  }
  document.getElementById('debugDiv').innerHTML = output;
}

function changeforheader(type,e){
  source = e["target"] || window.event["srcElement"];
  //print_r(source);
	if(type == 'hand'){
		source.style.cursor = "hand";
	}else if (type == 'notallowed'){	
		//alert('k');
		source.style.cursor ="not-allowed";
	}else if (type == 'text'){	
		//alert('k');
		source.style.cursor ="text";	
	}else{
		source.style.cursor = "arrow";
	}

}

function recordCount(count){
	
	if(count == ''){
		count = 0;
	}
	parent.document.getElementById("RC").innerHTML= count;
	
	
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function changeCompany(){
	frmChangeCompany.submit();
}

function changePlant(){
	frmChangePlant.submit();
}

function fowardTo(link)
{
	window.location = link;
}

function open_new_window(url) {
	var newwindow;
	newwindow = new_window = window.open(url,'window_name','scrollbars=1,toolbar=0,menubar=0,resizable=0,dependent=0,status=0,width=700,height=600,left=25,top=25')
	newwindow.focus();
}

function open_new_windows(url){
		var newwindow;
		newwindow = new_window = window.open(url,'window_name_excel','scrollbars=1,toolbar=0,menubar=0,resizable=1,dependent=0,status=0,width=600,height=400,left=25,top=25')
		newwindow.focus();
}

function clearSearch(href){
	document.frmSearch.searchfield.value='';
	//href += "?s="  + document.frmSearch.searchfield.value;
	//href += "&sb=" + document.frmSearch.searchBy.value;
	document.getElementById("one").src = href;
	document.frmSearch.searchfield.focus();
	//alert(href);
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function centerContent(div_id) {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentElement = document.getElementById(div_id);
			var contentHeight = contentElement.offsetHeight;
			if (windowHeight - contentHeight > 0) {
				contentElement.style.position = 'relative';
				contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
			}
			else {
				contentElement.style.position = 'static';
			}
		}
	}
}

function loading(theiframe,height,width) {
  d = window.parent.document.getElementById("loading_div");
  d.style.visibility = "visible";
  if (height != '')
    d.style.height = height;
  if (width != '')
    d.style.width = width;
  if (theiframe != '') {
    ifr = parent.document.getElementById(theiframe);
    if (ifr) {
      ifr.style.position = "relative";
      ifr.style.overflowx = "hidden";
      ifr.style.overflowy = "hidden";
      ifr.style.scrolling = "no";
      ifr.width = ifr.width + 50;
      //ifr.style.width = ifr.style.width + 50;
      d.style.width = ifr.width;
      d.style.height = ifr.height;
    }
  }
}

function finished_loading(parent) {
  if (typeof parent == "undefined") {
    parent = 0;
  }
  if (parent == 1)
    d = window.parent.document.getElementById("loading_div");
  else
    d = window.document.getElementById("loading_div");
  d.style.visibility = "hidden";
  d.style.zindex = -1;
  d.style.width = 0;
  d.style.height = 0;
}

/*
	This function takes a front_div_id, and back_div_id.
	It will make the front visible and centered and will disable the back
*/
function front_and_center(front_div_id,outer_front_div_id,back_div_id,div_height,div_width,page_height,page_width,front_iframe_src,is_iframe){
  browser = navigator.appName;
  //alert(browser);

	if (is_iframe) {
		front_div = window.parent.document.getElementById(front_div_id);
		outer_front_div = window.parent.document.getElementById(outer_front_div_id);
		back_div = window.parent.document.getElementById(back_div_id);

    if(browser != "Microsoft Internet Explorer")
      window.parent.scrollTo(0,0);

  	/*window.document.body.style.scrolling = "no";
  	window.document.body.style.overflowx = "hidden";
  	window.document.body.style.overflowy = "hidden";
  	window.document.body.style.overflow = "hidden";*/
	}
	else {
		front_div = document.getElementById(front_div_id);
		outer_front_div = document.getElementById(outer_front_div_id);
		back_div = document.getElementById(back_div_id);

    if(browser != "Microsoft Internet Explorer")
      window.parent.scrollTo(0,0);
	}

  //alert(back_div.style.height);
  //alert(h_div.style.height);
  //back_div.style.height = h_div.style.height;
	back_div.style.height = 1200;
  //alert(back_div.style.height);
  //alert(h_div.style.height);
	back_div.style.zIndex = 200;
	back_div.style.visibility = "visible";


	outer_front_div.style.visibility = "visible";
	outer_front_div.style.zIndex = 201;

	front_div.style.zIndex = 202;
  //alert(parent.document.body.scrollTop);
  //alert(front_div.style.top);
  if(browser == "Microsoft Internet Explorer")
    front_div.style.top = (parent.document.body.scrollTop + 20) + "px";
  //alert(front_div.style.top);
	front_div.innerHTML = "<iframe name=\"product_frame_popout\" width=\""+div_width+"\" height=\""+div_height+"\" src=\""+front_iframe_src+"\" frameborder=\"0\">	</iframe>";
	front_div.style.visibility = "visible";
}


function undo_front_and_center(front_div_id,outer_front_div_id,back_div_id,is_iframe) {

	if (is_iframe) {
		front_div = window.parent.document.getElementById(front_div_id);
		outer_front_div = window.parent.document.getElementById(outer_front_div_id);
		back_div = window.parent.document.getElementById(back_div_id);
  	window.document.body.style.scrolling = "no";
  	window.document.body.style.overflowx = "auto";
  	window.document.body.style.overflowy = "auto";
  	window.document.body.style.overflow = "auto";
	}
	else {
		front_div = document.getElementById(front_div_id);
		outer_front_div = document.getElementById(front_div_id);
		back_div = document.getElementById(back_div_id);
	}

//	back_div.style = "back_div_fade_in";

	front_div.style.visibility = "hidden";
	back_div.style.visibility = "hidden";
	front_div.style.zIndex = -1;
  outer_front_div.style.zIndex = -1;
	back_div.style.zIndex = -1;
	front_div.innerHTML = "<iframe name=\"front_div_iframe\" width=\"100%\" height=\"100%\" src=\"empty.php\" frameborder=\"0\">	</iframe>";


  return false;
}

function setIds() {
  var all = document.getElementsByTagName("*");
  //alert(document.getElementById("testing").id);
  for (j = 0; j < all.length; j++) {
    //for (i in all[j]){
    //alert(all[j].id);
      if (all[j].id == "" && all[j].name != "")
        all[j].id = all[j].name;
    //}
  }
  alert(document.getElementById("testing").id);
}
//setIds();

