//  ||||||||||||||||||||||||||||||||||||||||||||||||||
//  sorbéliving.com global javascript
//  ||||||||||||||||||||||||||||||||||||||||||||||||||

//--------------------------------------------------------------->
// Declare Images
//--------------------------------------------------------------->

var path = "http://www.sorbeliving.com/";
var img_path = path + "img/";
var nav_img_path = img_path + "nav/";

homeBTout = new Image();
homeBTout.src = nav_img_path + "homeBTout.gif";

homeBTover = new Image();
homeBTover.src = nav_img_path + "homeBTover.gif";

aboutBTout = new Image();
aboutBTout.src = nav_img_path + "aboutBTout.gif";

aboutBTover = new Image();
aboutBTover.src = nav_img_path + "aboutBTover.gif";

porfolioBTout = new Image();
porfolioBTout.src = nav_img_path + "porfolioBTout.gif";

productsBTover = new Image();
productsBTover.src = nav_img_path + "productsBTover.gif";

contactBTout = new Image();
contactBTout.src = nav_img_path + "contactBTout.gif";

contactBTover = new Image();
contactBTover.src = nav_img_path + "contactBTover.gif";

emBTout = new Image();
emBTout.src = img_path + "emBTout.gif";

emBTover = new Image();
emBTover.src = img_path + "emBTover.gif";

loginBTout = new Image();
loginBTout.src = img_path + "loginBTout.gif";

loginBTover = new Image();
loginBTover.src = img_path + "loginBTover.gif";

//--------------------------------------------------------------->
var ie = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);
//--------------------------------------------------------------->
MyDate = {
	days : ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
	months : ["January","February","March","April","May","June","July","August","September","October","November","December"],

	setDate : function(){
		var now = new Date();
		this.day = this.days[now.getDay()];
		this.date = now.getDate();
		this.month = this.months[now.getMonth()];
		this.year = now.getFullYear();
	},
	getDate : function(){
		this.setDate();
		return this.day+", "+this.month+" "+this.date+", "+this.year;
	}
}
//--------------------------------------------------------------->
function insertAfter(parent, node, referenceNode) {
	parent.insertBefore(node, referenceNode.nextSibling);
}
//--------------------------------------------------------------->
Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};
//--------------------------------------------------------------->
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}
//--------------------------------------------------------------->
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
//--------------------------------------------------------------->
function addEvent(el, evType, fn, useCapture) {
	if (el.addEventListener) {
		el.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (el.attachEvent) {
		var r = el.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		el['on' + evType] = fn;
	}
}
//--------------------------------------------------------------->
function addEvent(el, evType, fn, useCapture) {
	if (el.addEventListener) {
		el.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (el.attachEvent) {
		var r = el.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		el['on' + evType] = fn;
	}
}
//--------------------------------------------------------------->
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
//--------------------------------------------------------------->
function showDate(){
	document.getElementById("theDate").innerHTML = MyDate.getDate();
}
//--------------------------------------------------------------->
function initDate(){
	showDate();
}
//--------------------------------------------------------------->
function toTop() {
        self.scrollTo(0, 0)
}
//--------------------------------------------------------------->
function noSpam(user,domain) {
locationstring = "mailto:" + user + "@" + domain;
window.location = locationstring;
}
//--------------------------------------------------------------->
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
}
//--------------------------------------------------------------->
function setStatus(msg){
	window.status = msg;
	return true;
}
//--------------------------------------------------------------->
function hideStatus(){
var statusmsg=""
window.status = statusmsg
return true;
}
//--------------------------------------------------------------->
function disable()
{
event.button == false;
}
//--------------------------------------------------------------->
// Heinle's function for retrieving a cookie.
function getCookie_old (name) {
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    begin = dc.indexOf(cname);
    if (begin != -1) {
      begin += cname.length;
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    }
  }
  return null;
}
//--------------------------------------------------------------->
// An adaptation of Dorcht's function for setting a cookie.
function setCookie_old (name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) +
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}
//--------------------------------------------------------------->
// An adaptation of Dorcht's function for deleting a cookie.
function delCookie_old (name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
//--------------------------------------------------------------->
function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
//--------------------------------------------------------------->
function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}
//--------------------------------------------------------------->
function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
//--------------------------------------------------------------->
var firstCall = true;

function changeFontSize(fSize, increment) {
  if (firstCall) {
    firstCall = false;
    if (increment != "")
      changeFontSize('12', '');
  }
  if (document.getElementsByTagName) {
    tags = new Array ("p", "li", "h3", "h4", "h5", "h6", "body");
    for (j=0; j<tags.length; j++) {
      var getElement = document.getElementsByTagName(tags[j]);
      var eachElement, currentFontSize, fontIncrease, newFontSize;
      for (i=0; i<getElement.length; i++) {
        eachElement = getElement[i];
        if (increment != "") {
          currentFontSize = parseInt(eachElement.style.fontSize);
          fontIncrease = parseInt(increment);
          newFontSize = currentFontSize + fontIncrease;
          }
        else if (fSize != "")
          newFontSize = parseInt(fSize);
        if (tags[j] == "li")
          eachElement.style.lineHeight = Math.round(newFontSize*1.2) + "px";
        else
          eachElement.style.lineHeight = Math.round(newFontSize*1.5) + "px";
        if (fSize != "") {
          switch(tags[j]) {
          case "h1": newFontSize += 4; break;
          case "h2": newFontSize += 3; break;
          case "h3": newFontSize += 2; break;
          case "h4": newFontSize += 1; break;
          case "h5": newFontSize += 1; break;
          case "h6": newFontSize += 1;
          }
        }
        eachElement.style.fontSize = newFontSize + "px";
        setCookie('fontSize', newFontSize);
      }
    }
  }
}
//--------------------------------------------------------------->
function chgBG(id,color)
{
document.getElementById(id).style.background=color;
}
//--------------------------------------------------------------->
function blinkTxt() 
{
    if(document.getElementById) 
	{
	var div = document.getElementById("loader");
		if (div.style.visibility=="hidden")
		{
		div.style.visibility="visible";
    	}
    	else 
		{
		div.style.visibility="hidden";
    	}
	}
}
//--------------------------------------------------------------->
function randTxt(id)
{
	if(document.getElementById) 
	{
		var num = Math.floor(Math.random()* coverTxt.length)
		var div = document.getElementById(id);
		div.innerHTML = ""; 
		div.innerHTML = coverTxt[num];
	}
}
//--------------------------------------------------------------->
function randImg(id)
{
	if(document.getElementById)
	{
		var num = 5;
		var div = top.document.getElementById(id);
		div.style.backgroundImage = "url(img/home/rand/rand_"+[Math.floor(Math.random() * num)+ 1]+".jpg)";
	}
}
//--------------------------------------------------------------->
function randImgHome(id,str)
{
	if(document.getElementById)
	{
		var num = 5;
		var div = top.document.getElementById(id);
		div.style.backgroundImage = "url(img/home/rand_"+[str]+"/rand_"+[str]+"_"+[Math.floor(Math.random() * num)+ 1]+".jpg)";
	}
}
//--------------------------------------------------------------->
function randBgdImg()
{
	var num = 5;
	if(document.getElementById)
	{
    	bdy = document.getElementsByTagName("body");
    	bdy[0].style.width = "100%";
    	bdy[0].style.height = "100%";
        bdy[0].style.margin = "0px";
		bdy[0].style.backgroundImage = "url(img/bgd/bgdimg"+[Math.floor(Math.random() * num)+ 1]+".jpg)";
		bdy[0].style.backgroundRepeat = "no-repeat";

	}
}
//--------------------------------------------------------------->
function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}
//--------------------------------------------------------------->
function blurAnchors(){
	if(document.getElementById){
    		var a=document.getElementsByTagName("a");
    		for(i=0;i<a.length;i++){
    			a[i].onfocus=function(){this.blur()};
    		}
	}
}
//--------------------------------------------------------------->
function preloadImages(){
	if (document.images){
	var myimages=new Array();
	for (i=0;i<preloadImages.arguments.length;i++){
	myimages[i]=new Image();
	myimages[i].src=preloadImages.arguments[i];
	}
}
}
//--------------------------------------------------------------->
function preload_alt(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}
//--------------------------------------------------------------->
// img swap
//--------------------------------------------------------------->
function On(imgName)
{
	if (document.images)
	{
		document[imgName].src = eval(imgName +"On.src");
	}
}
//--------------------------------------------------------------->
function Off(imgName)
{
	if (document.images)
	{
		document[imgName].src = eval(imgName +"Off.src");
	}
}
//--------------------------------------------------------------->
function imgSwap(imgName,imgObj) {
	if (document.images) {
	document.images[imgName].src = eval(imgObj+".src")
	}
}
//--------------------------------------------------------------->
function imgSwap_alt(imgName,imgObj,divNames){
	if(document.layers && divnames != null){
		divnames = divnames.split(',');
		var d = '';
		for(var i=0; i<divnames.length; i++){
			d += 'document.'+divnames[i]+'.';
		}
		eval(d+'document.images["'+imgname+'"].src = '+imgobj+'.src');
	}else{
		document.images[imgname].src = eval(imgobj+'.src');
	}
}
//--------------------------------------------------------------->
function setStyle(){
				
				var platform
				if (navigator.userAgent.indexOf('Mac') != -1){
					var platform = "mac";
  				}else{
  					var platform = "pc";
  				}
  				
  				
  				if (navigator.appName.indexOf('Microsoft') != -1){
      				var browser = "IE"
  				} else {
  					var browser = "NS"
  				}

  				if ((navigator.appName.indexOf('Mac') != 1) && (navigator.appName.indexOf('Microsoft') != 1)){
      				var browser = "other"
  				} 
  				
  				
  				
  				if (platform == "mac") {
  				if (browser == "IE"){
  				document.write('<link rel="stylesheet" media="screen" type="text/css" href="global_iemac.css">')
  				}else if (browser == "NS") {
  					document.write('<link rel="stylesheet" media="screen" type="text/css" href="global_iepc.css">')
  				}
  				}
  				if (platform == "pc") {
  				if (browser == "IE"){
  				document.write('<link rel="stylesheet" media="screen" type="text/css" href="global_iepc.css">')
  				}else if (browser == "NS") {
  					document.write('<link rel="stylesheet" media="screen" type="text/css" href="global_nspc.css">')
  				}
  				}
  				}
			
//--------------------------------------------------------------->			
function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}
//--------------------------------------------------------------->
function show(obj) {
	if(document.getElementById){
	var el = top.document.getElementById(obj);
	el.style.display = "";
	return false;			
	}
}
//--------------------------------------------------------------->
function hide(obj) {
	if(document.getElementById){
	var el = top.document.getElementById(obj);
	el.style.display = "none";
	return false;			
	}
}
//--------------------------------------------------------------->
function toggle(obj)
{
	var el = document.getElementById(obj);
	if(document.getElementById)
	{
		if ( el.style.display != "none" ) 
		{
			el.style.display = "none";
		}
		else
		{
		el.style.display = "";
		}
	}
}
//--------------------------------------------------------------->
function toggleGroup(objs)
{
	els = new Array (objs);
	if (document.getElementById)
	{
		for(i=1;i<=els.length;i++)
		{
			var el = els[i];
			if (typeof el == 'string')
			{
				el = document.getElementById(el);
			}
			if ( el.style.display != "none" ) 
			{
				el.style.display = "none";
			}
			else
			{
			el.style.display = "";
			}
		}
	}
}
//--------------------------------------------------------------->
function setZIndex(id, zIndex) 
{
     if (document.getElementById)
	{
	var div = top.document.getElementById(id);
     div.style.zIndex = zIndex;
	}
}
//--------------------------------------------------------------->
function changeFrame(framename1,url1) {
	top[framename1].location.href = url1;
}
//--------------------------------------------------------------->
function changeFrames(framename1,url1,framename2,url2) {
     top[framename1].location.href = url1;
	top[framename2].location.href = url2;
}
//--------------------------------------------------------------->
function changeHTML(id,content) {
	if(document.getElementById){
		document.getElementById(id).innerHTML = ""; 
		document.getElementById(id).innerHTML = content; 
	}
}
//--------------------------------------------------------------->
function topchangeHTML(id,content) {
	if(document.getElementById){
		top.document.getElementById(id).innerHTML = ""; 
		top.document.getElementById(id).innerHTML = content;
	}
}
//--------------------------------------------------------------->

function pulldownLaunch (pulldown) {
	newlocation = pulldown[pulldown.selectedIndex].value;
	if(newlocation != "")
		window.open(newlocation);
}
//--------------------------------------------------------------->
function resetIfBlank (pulldown) {
	possiblenewlocation = pulldown[pulldown.selectedIndex].value;
	if(possiblenewlocation == "")
		pulldown.selectedIndex = 0;
}
//--------------------------------------------------------------->
function pulldownNewPage() {
var listItem = document.menuForm.newPage.selectedIndex;
var newPage = document.menuForm.newPage.options[listItem].value;
location.href = newPage;
}
//--------------------------------------------------------------->
function jumpMenu(targ,selObj,restore) { 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//--------------------------------------------------------------->
function submitForm() {
	var frm = document.forms["put name of form here"];
	frm.submit()
}
//--------------------------------------------------------------->
function formValue(obj,txt) {
	if (obj.value == txt) {
		obj.value = ""
	} else {
		if (obj.value == "") {
			obj.value = txt;
		}	
	}
}
//--------------------------------------------------------------->