
function getEmail(e) {
	h = window.location.hostname;
	h = h.replace(/www\./,'');

 	e = e + '@' + h;
 	document.write(e);
}

function getEmailURL(e) {
        h = window.location.hostname;
        h = h.replace(/www\./,'');

        e = e + '@' + h;
        document.write('<a href="mailto:' + e + '" class="link">' + e + '</a>');
}

function toggleTR(id,imgname,myname,c_name) {
      var  divObj = document.getElementById(id);

        if ( divObj ) {
                if ( divObj.style.display == 'table-row' ) {
                        divObj.style.display = 'none';
                        switchimg(imgname,myname,'up');
                        if ( c_name ) {
                                savePage(id,c_name);
                        }
                } else {
                        divObj.style.display = 'table-row';
                        switchimg(imgname,myname,'down');
                        if ( c_name ) {
                                savePage(id,c_name);
                        }
                }
        }
}

function openTR(id,c_name) {
        var divObj = document.getElementById(id);

        if ( divObj ) {
                divObj.style.display = 'table-row';
                if ( c_name ) {
                        savePage(id,c_name);
                }
        }
}

function closeTR(id,c_name) {
        var divObj = document.getElementById(id);

        if ( divObj ) {
                divObj.style.display = 'none';
                if ( c_name ) {
                        savePage(id,c_name);
                }
        }
}

function toggleClass(id,classone,classtwo) {
 if ( document.getElementById(id) ) {
        if ( document.getElementById(id).className == classone ) {
                document.getElementById(id).className = classtwo;
        } else {
                document.getElementById(id).className = classone;
        }
 }

}

function togglePop(id,imgname,myname) {
        var divObj = document.getElementById(id);

        if ( divObj.style.visibility == 'visible' ) {
                if ( divObj ) {
                        divObj.style.visibility = 'hidden';
			switchimg(imgname,myname,'up');
                }
        } else {
                if ( divObj ) {
                        divObj.style.visibility = 'visible';
			switchimg(imgname,myname,'down');
                }
        }
}

function togglePopMover(id) {
        var divObj = document.getElementById(id);

        if ( divObj.style.visibility == 'visible' ) {
                if ( divObj ) {
                        divObj.style.visibility = 'hidden';
                }
        } else {
		openPopMover(id);
        }
}

function openPopMover(id) {
	var y = 125;

        var divObj = document.getElementById(id);

        if ( divObj ) {
                divObj.style.visibility = 'visible';
  
		var theTop = (document.all) ? document.body.scrollTop : window.pageYOffset;
		theTop += y;
		divObj.style.top = theTop + 'px' ;
	}
}

function openPop(id) {
	var divObj = document.getElementById(id);
	
	if ( divObj ) {
     		divObj.style.visibility = 'visible';
     	}
}

function closePop(id) {
        var divObj = document.getElementById(id);
        
        if ( divObj ) { 
        	divObj.style.visibility = 'hidden';
        }
}

function showPop(opens,closes) {
	var cs = closes.split(",");
	var os = opens.split(",");

	for (i=0; i < cs.length; i++ ) { // close tabs
		if ( document.getElementById(cs[i]) ) { 
   			closePop(cs[i]);
		}
	}
	
	for (i=0; i < os.length; i++ ) { // open tabs
		if ( document.getElementById(os[i]) ) { 
   			openPop(os[i]);
		}
	}	
}

function toggleDIV(id,imgname,myname,c_name) {
       var  divObj = document.getElementById(id);

	if ( divObj ) {
        	if ( divObj.style.display == 'block' ) {
         	       	divObj.style.display = 'none';
			switchimg(imgname,myname,'up');
			if ( c_name ) {
				savePage(id,c_name);
			}
       		} else {
                	divObj.style.display = 'block';
			switchimg(imgname,myname,'down');
			if ( c_name ) { 
				savePage(id,c_name);
			}
        	}
 	}
}

function openDIV(id,c_name) {
	var divObj = document.getElementById(id);
	
	if ( divObj ) {
     		divObj.style.display = 'block';
                if ( c_name ) {
                        savePage(id,c_name);
                }
     	}
}

function closeDIV(id,c_name) {
        var divObj = document.getElementById(id);
        
        if ( divObj ) { 
        	divObj.style.display = 'none';
                if ( c_name ) {
                        savePage(id,c_name);
                }
        }
}

function showTAB(opens,closes) {
	var cs = closes.split(",");
	var os = opens.split(",");

	for (i=0; i < cs.length; i++ ) { // close tabs
		if ( document.getElementById(cs[i]) ) { 
   			closeDIV(cs[i]);
		}
	}
	
	for (i=0; i < os.length; i++ ) { // open tabs
		if ( document.getElementById(os[i]) ) { 
   			openDIV(os[i]);
		}
	}	
}

function showAll(name,total) {
	if ( !total && !name ) { 
		return; 
	}

        for (i=0; i <= total; i++ ) { 
                if ( document.getElementById(name + i) ) {
                        openDIV(name + i);
                }
        }
}

function closeAll(name,total) {
        if ( !total && !name ) { 
               return;
        }

        for (i=0; i <= total; i++ ) {
                if ( document.getElementById(name + i) ) {
                        closeDIV(name + i);
                }
        }
}

function warn(url,action) {
	var answer;

	if ( action ) {
		answer = confirm('Are you sure you wish to ' +action+ ' this item?');
	} else { 
		answer = confirm('Are you sure you wish to continue?');	
	}
	if ( answer ) {
		window.location = url;
		return true;
	}
 return false;
} 

function newWindow(f,w,h) {
	newWindow = open(f,"Footer","width="+w+",height="+h+",toolbar=no,location=0,directories=0,status=0,menubar=no,scrollbars=yes,resizable=no,copyhistory=0");
	this.newWindow.focus();
}

function validateDate(id) {
	var date = id.value;
	parts = date.split('/');
	var checkDate = new Date(date);

	if ( parts[0] < 0 || parts[0] >12 ) { checkDate = 'Invalid Date'; }
	if ( parts[1] < 0 || parts[1] >31 ) { checkDate = 'Invalid Date'; }
	if ( parts[2] < 2008 ) { checkDate = 'Invalid Date'; }

        if ( checkDate == 'Invalid Date' ) {
                alert('Sorry, invalid date format. Please re-enter date like mm/dd/yyyy.');
                return false;
        } else {
                return true;
        }
}

function addLoadEvent(func) {
	var oldonload = window.onload;

	if (typeof window.onload != 'function') {
    		window.onload = func;
	} else {
    		window.onload = function() {
      			oldonload();
      			func();
    		}
  	}
}

function prepareInputsForHints() {
	var inputs = document.getElementsByTagName("input");

	for (var i=0; i < inputs.length; i++){
		obj = inputs[i].parentNode.getElementsByTagName("span")[0];		

		if (obj) {
			inputs[i].onfocus = function () {
				var hint = 'hint_' + this.name;
				if ( document.getElementById(hint) ) { 
					document.getElementById(hint).style.display = 'inline';
				}
			}
			inputs[i].onblur = function () {
                                var hint = 'hint_' + this.name;
                                if ( document.getElementById(hint) ) {
                                        document.getElementById(hint).style.display = 'none';
                                }
			}
		}
	}

        var selects = document.getElementsByTagName("select");

        for (var i=0; i < selects.length; i++){
                obj = selects[i].parentNode.getElementsByTagName("span")[0];

                if (obj) {
                        selects[i].onfocus = function () {
                                var hint = 'hint_' + this.name;
                                if ( document.getElementById(hint) ) {
                                        document.getElementById(hint).style.display = 'inline';
                                }
                        }
                        selects[i].onblur = function () {
                                var hint = 'hint_' + this.name;
                                if ( document.getElementById(hint) ) {
                                        document.getElementById(hint).style.display = 'none';
                                }
                        }
                }
        }

}

function setCookie(c_name,value,expiredays) {
 var exdate=new Date();
 exdate.setDate(exdate.getDate()+expiredays);
 document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));


