﻿function getElementLeft(id) {
 var value;
 value = -1;
 if (document.defaultView) {
  elm = document.getElementById(id);
  cst= document.defaultView.getComputedStyle(elm, "");
  if (cst != null) { 
   value = cst.getPropertyValue("left");
  }
 } else if (document.getElementById(id).currentStyle) {
  value = document.getElementById(id).currentStyle.left;
 }
 if (value != -1) {
  value = value.toString();
  if (value.indexOf('px') != -1) { 
   value = value.substr(0,value.length-2); //remove 'px' from string
  }
 }
 return parseInt(value);
}

function getElementRight(id) {
 var value;
 value = -1;
 if (document.defaultView) {
  elm = document.getElementById(id);
  cst= document.defaultView.getComputedStyle(elm, "");
  if (cst != null) { 
   value = cst.getPropertyValue("right");
  }
 } else if (document.getElementById(id).currentStyle) {
  value = document.getElementById(id).currentStyle.right;
 }
 if (value != -1) {
  value = value.toString();
  if (value.indexOf('px') != -1) { 
   value = value.substr(0,value.length-2); //remove 'px' from string
  }
 }
 return parseInt(value);
}


function getElementTop(id) {
 var value;
 value = -1;
 if (document.defaultView) {
  elm = document.getElementById(id);
  cst= document.defaultView.getComputedStyle(elm, "");
  if (cst != null) { 
   value = cst.getPropertyValue("top");
  }
 } else if (document.getElementById(id).currentStyle) {
  value = document.getElementById(id).currentStyle.top;
 }
 if (value != -1) {
  value = value.toString();
  if (value.indexOf('px') != -1) { 
   value = value.substr(0,value.length-2); //remove 'px' from string
  }
 }
 return parseInt(value);
}

function getElementBottom(id) {
 var value;
 value = -1;
 if (document.defaultView) {
  elm = document.getElementById(id);
  cst= document.defaultView.getComputedStyle(elm, "");
  if (cst != null) { 
   value = cst.getPropertyValue("bottom");
  }
 } else if (document.getElementById(id).currentStyle) {
  value = document.getElementById(id).currentStyle.bottom;
 }
 if (value != -1) {
  value = value.toString();
  if (value.indexOf('px') != -1) { 
   value = value.substr(0,value.length-2); //remove 'px' from string
  }
 }
 return parseInt(value);
}

function getElementHeight(id) {
 var value;
 value = -1;
 if (document.defaultView) {
  elm = document.getElementById(id);
  cst= document.defaultView.getComputedStyle(elm, "");
  if (cst != null) { 
   value = cst.getPropertyValue("height");
  }
 } else if (document.getElementById(id).currentStyle) {
   value = document.getElementById(id).currentStyle.height;
 }
 
 if (value != -1) {
  value = value.toString();
  if (value.indexOf('px') != -1) { 
   value = value.substr(0,value.length-2); //remove 'px' from string
  }
 }
 
 return parseInt(value);
}
function getElementWidth(id) {
 var value;
 value = -1;
 if (document.defaultView) {
  elm = document.getElementById(id);
  cst= document.defaultView.getComputedStyle(elm, "");
  if (cst != null) { 
   value = cst.getPropertyValue("width");
  }
 } else if (document.getElementById(id).currentStyle) {
  value = document.getElementById(id).currentStyle.width;
 }
 
 if (value != -1) {
  value = value.toString();
  if (value.indexOf('px') != -1) { 
   value = value.substr(0,value.length-2); //remove 'px' from string
  }
 }
 return parseInt(value);
}


getViewportScrollTop = function() {
	var x;
	if (self.scrollTop) // all except Explorer
	{
		x = self.scrollTop;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.scrollTop;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.scrollTop;
	}
	return x;		
};

getViewportScrollLeft = function() {
	var x;
	if (self.scrollLeft) // all except Explorer
	{
		x = self.scrollLeft;
	}
	else if (document.documentElement && document.documentElement.scrollLeft)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.scrollLeft;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.scrollLeft;
	}
	return x;		
};

getViewportWidth = function() {
	var x;
	if (self.innerWidth) // all except Explorer
	{
		x = self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
	}
	return x;
		
};

scrollVertPresent = function() {
	var winheight = -1;
	var boheight = 0;
	
	if (document.documentElement.scrollHeight && document.body.scrollHeight) {
	 winheight = parseInt(document.documentElement.scrollHeight);
	 boheight  = parseInt(document.body.scrollHeight);	
	}
	
	if ( (winheight >= boheight) || (getViewportScrollTop() > 0) || (getViewportScrollLeft() > 0) ) { 
	 return true; 
	} else { 
	 return false; 
	}

}


getViewportHeight = function() {
	var y;
	if (self.innerHeight) // all except Explorer
	{
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		y = document.body.clientHeight;
	}	
	return y;
	
};


//var detect = navigator.userAgent.toLowerCase();
var appN = navigator.appName.toLowerCase();
function ieCheck() {
 if ( appN.indexOf('microsoft') != -1) {
  return true;
 } else { 
  return false; 
 }
}

var userAg = navigator.userAgent.toLowerCase();
function safariCheck() {
 if ( userAg.indexOf('safari') + 1) {
  return true;
 } else { 
  return false; 
 }

}

