var myref = document.referrer;
if(myref.indexOf("energy-medicine.info") == -1 && myref.length > 7){
	document.cookie = "REFERRER=" + myref + "; path=/;";
}
// Image preload
var bild1 = new Image(); bild1.src="/templates/inergetix_frontpage_draft2/images/nav01_h.gif";
var bild2 = new Image(); bild2.src="/templates/inergetix_frontpage_draft2/images/nav02_h.gif";
var bild3 = new Image(); bild3.src="/templates/inergetix_frontpage_draft2/images/nav03_h.gif";
var bild4 = new Image(); bild4.src="/templates/inergetix_frontpage_draft2/images/nav04_h.gif";
var bild5 = new Image(); bild5.src="/templates/inergetix_frontpage_draft2/images/nav05_h.gif";
var bild6 = new Image(); bild6.src="/templates/inergetix_frontpage_draft2/images/nav06_h.gif";
var bild7 = new Image(); bild7.src="/templates/inergetix_frontpage_draft2/images/nav07_h.gif";
var bild11 = new Image(); bild11.src="/templates/inergetix_frontpage_draft2/images/nav01_a.gif";
var bild21 = new Image(); bild21.src="/templates/inergetix_frontpage_draft2/images/nav02_a.gif";
var bild31 = new Image(); bild31.src="/templates/inergetix_frontpage_draft2/images/nav03_a.gif";
var bild41 = new Image(); bild41.src="/templates/inergetix_frontpage_draft2/images/nav04_a.gif";
var bild51 = new Image(); bild51.src="/templates/inergetix_frontpage_draft2/images/nav05_a.gif";
var bild61 = new Image(); bild61.src="/templates/inergetix_frontpage_draft2/images/nav06_a.gif";
var bild71 = new Image(); bild71.src="/templates/inergetix_frontpage_draft2/images/nav07_a.gif";
var bild171 = new Image(); bild171.src="/templates/inergetix_frontpage_draft/images/de_mo.jpg";
var bild172 = new Image(); bild172.src="/templates/inergetix_frontpage_draft/images/nl_mo.jpg";
var bild173 = new Image(); bild173.src="/templates/inergetix_frontpage_draft/images/seminars_mo.jpg";
//Globals
CURRENT_SECTION = "";
function donothing(){
	return;
}
function setTopMenu(){
	var myimg = "/templates/inergetix_frontpage_draft2/images/";
	var myimgid = "";
    var cs = CURRENT_SECTION.toLowerCase();
	switch ( cs ) {
	  case "products":
	    myimg += "nav01_a.gif";
	    document.images['tm1'].src = myimg;
	    document.images['tm1'].onmouseover = donothing;
	    document.images['tm1'].onmouseout = donothing;
	    break;
	  case "fields of use":
	    myimg += "nav02_a.gif";
	    document.images['tm2'].src = myimg;
	    document.images['tm2'].onmouseover = donothing;
	    document.images['tm2'].onmouseout = donothing;
	    break;
	  case "energetic medicine":
	    myimg += "nav03_a.gif";
	    document.images['tm3'].src = myimg;
	    document.images['tm3'].onmouseover = donothing;
	    document.images['tm3'].onmouseout = donothing;
	    break;
	  case "informational medicine":
	    myimg += "nav04_a.gif";
	    document.images['tm4'].src = myimg;
	    document.images['tm4'].onmouseover = donothing;
	    document.images['tm4'].onmouseout = donothing;
	    break;
	  case "technologies":
	    myimg += "nav05_a.gif";
	    document.images['tm5'].src = myimg;
	    document.images['tm5'].onmouseover = donothing;
	    document.images['tm5'].onmouseout = donothing;
	    break;
	  case "associates":
	    myimg += "nav06_a.gif";
	    document.images['tm6'].src = myimg;
	    document.images['tm6'].onmouseover = donothing;
	    document.images['tm6'].onmouseout = donothing;
	    break;
	  case "support":
	    myimg += "nav07_a.gif";
	    document.images['tm7'].src = myimg;
	    document.images['tm7'].onmouseover = donothing;
	    document.images['tm7'].onmouseout = donothing;
	    break;
	  default:
	    break;
	}	
	highlightMenu();
}
function highlightMenu(){
	var ss = location.href;
	var lnks = document.links.length;
	var arrlnk = document.links;
	for(i=0;i<lnks;i++){
		if( arrlnk[i].href.indexOf(ss) != -1 && arrlnk[i].className == "sublevel" ){
			arrlnk[i].style.fontWeight = "bold";
		}
	}
}
function openCRMWindow(_url){
		htw = window.open(_url, 'crmwin','width=600,height=600,left=100,top=100,resizable=no,scrollbars=yes');
		htw.focus();
}
function openTestimonial( _url ){
		//prepare html code
		var swfcode = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
		+ 'width="260" height="240" '
		+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
		+ '<param name="movie" value="' + _url + '" /> <param name="swliveconnect" value="true"><param name="quality" value="high" />'
		+ '<embed src="' + _url + '" quality="high" '
		+ 'width="260" height="240" align="middle" '
		+ 'play="true" '
		+ 'swLiveConnect="true" '				
		+ 'loop="false" '
		+ 'type="application/x-shockwave-flash" '
		+ 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
		+ '<\/embed>'
		+ '<\/object>';
         
        var htmlheader = '<html><head><title>CoRe Inergetix - Testimonial</title></head><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">';
        var htmlbodyend = '</body></html>';
        var wbody = htmlheader + swfcode + htmlbodyend;
        
        var w = 260;
        var h = 240;
        var props = "width=" + w + ",height=" + h + ",left=300,top=300,resizable=no,scrollbars=no,location=no,menubar=no,status=no,toolbar=no";
		mtw = window.open('','moodwin', props);
        mtw.document.open();
        mtw.document.write( wbody );
        mtw.document.close();
		mtw.focus();
}
window.onload = setTopMenu;
    // Detects if the browser supports Ajax 
    function browserSupportsAjax()
    {
        if (typeof XMLHttpRequest == "undefined" && typeof ActiveXObject == "undefined" && window.createRequest == "undefined")
        {
            return false;
        }
        return true
    }
function coremailer(){
	var _f = document.forms['coremailer'];
	if ( _f.xemail.value.length < 5 || _f.xemail.value.indexOf("@") == -1 || _f.xemail.value.indexOf(".") == -1 ){
		alert("Please fill in the form correctly, before submitting your message.");
		return false;
	} else {
      	  	var w = 300;
       	 	var h = 120;
        	var props = "width=" + w + ",height=" + h + ",left=300,top=300,resizable=no,scrollbars=no,location=no,menubar=no,status=no,toolbar=no";
		cmw = window.open('','mailerwin', props);
		document.forms['coremailer'].method= "post";
		document.forms['coremailer'].target = "mailerwin";
		document.forms['coremailer'].action = "/freecrm/coremailer.php";
		document.forms['coremailer'].submit();
		return true;
	}
}
function insertTA( _sna ){
	if( arguments.length > 0){
		document.write("<textarea name=\"" + _sna + "\" cols=\"60\" rows=\"10\">&nbsp;</textarea>");
	} else {
		document.write("<textarea name=\"xfield-MESSAGE\" cols=\"60\" rows=\"10\">&nbsp;</textarea>");
	}
}
xFormContent = "";
function xOpen() {
	if( xFormContent.length == 0 ){
		xFormContent = document.getElementById("div1").innerHTML;
	}
	document.getElementById("div1").style.display = "inline";
	document.getElementById("adiv1").innerHTML = "<a href=\"javascript: void 0;\" onclick=\"xClose();\">CLOSE FORM</a>";
	document.getElementById("div1").innerHTML = xFormContent;
}
function xClose() {
	document.getElementById("div1").style.display = "none";
	document.getElementById("adiv1").innerHTML = "<a href=\"javascript: void 0;\" onclick=\"xOpen();\">OPEN FORM</a>";	
}
function validateGeneric() {
	var ref = document.forms["coremailer"].elements;
	for( i = 0; i < ref.length; i++ ){
		if( ref[i].type == "text" || ref[i].type == "textarea" ){
			if( ref[i].name.indexOf("x-") == -1 && ref[i].name.indexOf("nr-") == -1){
				if( ref[i].value.length < 2 ){
					alert("Please fill in the missing field: " + ref[i].name );
					return false;
				}
			}
		}
	}
	return true;
}
function contactPractitioner(_id, name) {
	document.getElementById("div1").style.display = "block";
	document.getElementById("div1").style.position = "fixed";
	//document.getElementById("div1").style.left = "100px";
	document.getElementById("div1").style.bottom = "50px";
	document.getElementById("error").style.display = "none";
	document.getElementById("success").style.display = "none";
	self.location.hash = "#form";
	var ref = document.coremailer.elements;
  ref["x-RKEY"].value = _id;
	ref["Practitioner"].value = name;
	}
	// 
	
var glossary = new Array("energy medicine", "informational medicine", "Illness", "disease", "Diagnosis", "Remedy", "Cure", "Treatment");	
	
function highlightKeywords(glossary, where) {
	var html = document.getElementById(where).innerHTML;
	var expresion = new RegExp();
	for(var i = 0; i < glossary.length; i++)
    {
     expresion = new RegExp("(" +glossary[i]+ ")([\\s|<])", "gi");
     html = html.replace(expresion, "$1*$2");
    }
   document.getElementById(where).innerHTML = html; 
	}
	
	
function showMovie( width, height, src ){
if (!QTinstalled())
{ 
document.getElementById("noqt").style.display = "block";
return true;
}
document.getElementById("noqt").style.display = "none";
var iframe = document.getElementById("MovieIframe");
iframe.width = width;
iframe.height = height;
iframe.src = src;
var container = document.getElementById("MovieIframeContainer");
container.style.display = "block";
}
function QTinstalled()
{
if (window.ActiveXObject) {
    var control = null;
    try {
        control = new ActiveXObject('QuickTime.QuickTime');
    } catch (e) {
        // Do nothing
    }
    if (control) {
        // In case QuickTimeCheckObject.QuickTimeCheck does not exist
        return true;
    }
    try {
        // This generates a user prompt in Internet Explorer 7
        control = new ActiveXObject('QuickTimeCheckObject.QuickTimeCheck');
    } catch (e) {
        return;
    }
    if (control) {
        // In case QuickTime.QuickTime does not exist
        return true;
        // Get version
        //version = control.QuickTimeVersion.toString(16); // Convert to hex
        //version = version.substring(0, 1) + '.' + version.substring(1, 3);
        //version = parseFloat(version);
    }
} else {
    // Check navigator.plugins for "QuickTime Plug-in"
    if (navigator.plugins) {
          for (i=0; i < navigator.plugins.length; i++ ) {
               if (navigator.plugins[i].name.indexOf("QuickTime") >= 0)
                    { return true; }
            }
        }
}
return false;
}
function FlashInstalled(){
var version = null;
if (window.ActiveXObject) {
    var control = null;
    try {
        control = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
    } catch (e) {
        return false;
    }
    if (control) {
        return true;
        //version = control.GetVariable('$version').substring(4);
        //version = version.split(',');
        //version = parseFloat(version[0] + '.' + version[1]);
    }
} else {
    // Check navigator.plugins for "Shockwave Flash"
        if (navigator.plugins) {
          for (i=0; i < navigator.plugins.length; i++ ) {
               if (navigator.plugins[i].name.indexOf("Flash") >= 0)
                    { return true; }
            }
        }
}
}
function insertFlickrFlashShow( id, style, height, width ){
document.getElementById("flickrShowContainer").innerHTML = "<iframe id=\"MyIframe\" marginwidth=\"0\" marginheight=\"0\" style=\""+ style + "\" src=\"http://www.flickr.com/slideShow/index.gne?nsid=&amp;set_id=" + id + "&amp;text=&amp;tags=&amp;tag_mode=&amp;user_id=&amp;favorites=&amp;group_id=&amp;contacts=&amp;frifam=&amp;single=&amp;firstIndex=&amp;firstId=&amp;sort=&amp;v=1.6&amp;codeV=1.36&amp;full=0\" align=\"middle\" frameborder=\"0\" height=\"" + height + "\" scrolling=\"no\" width=\"" + width +"\"></iframe>";
}
var salesReps = new Array(
	new Array(68, 244, "Sonia Haramilio", "/images/stories/Advantages/CoRe_Team/sonia_jaramillo.jpg", "Headquarter Sales,<br />California, USA", "English and Spanish", "http://www.energy-medicine.info/freecrm/sr_contact.php?id=sonia", "/sonia.html"),
	new Array(75, 244, "Caroline Alexakhin", "/images/stories/Advantages/CoRe_Team/caroline_alexakhin.jpg", "Headquarter Sales,<br />California, USA", "English", "http://www.energy-medicine.info/freecrm/sr_contact.php?id=caroline", "/caroline-alexakhin.html"),
	new Array(110, 227, "Gwen Foster", "/images/people/gwen-foster.jpg", "Headquarter Sales,<br />Texas, USA", "English", "http://www.energy-medicine.info/freecrm/sr_contact.php?id=gwen", "/gwen-foster.html")
	);
	
	function populateMap()
	{
		for(i=0; i < salesReps.length; i++)
			placeItemOnMap(salesReps[i][0],salesReps[i][1], i, salesReps[i][2], salesReps[i][3], salesReps[i][4], salesReps[i][5], salesReps[i][6] , salesReps[i][7]);
	}
	
	function placeItemOnMap(x, y, id, name, imageSrc, country, languages, contactURL, pageURL)
	{
		document.getElementById("map").innerHTML += "<img src=\"/images/graphics/dot.gif\" style=\"position: absolute; bottom: " + y +"px; left: "+ x+ "px;\" onmouseover=\"document.getElementById(\'" + id + "\').style.display = \'block\';\" />";
		document.getElementById("map").innerHTML +="<div id=\"" + id + "\" style=\"position: absolute;bottom: " + y +"px; left: "+ (x-115) + "px; display: none;\" onmouseout=\"this.style.display = \'none\'\" onmouseover=\"document.getElementById(\'" + id + "\').style.display = \'block\';\"><table width=\"240\" cellspacing=\"0\"cellpadding=\"3\"><tr><td colspan=\"4\" valign=\"top\" style=\"border-top: 1px green solid; border-right: 1px green solid;border-left: 1px green solid;-moz-border-radius: 12px 12px 0 0; top: -100px; background: white;\"><div align=\"center\"><b>" + name +"</b></div><img src=\""+ imageSrc + "\" width=\"80\" style=\"float: left; border: 1px solid rgb(128,128,128); margin: 3px;\" />" + country + "<p>Speaking: <br /><b>" + languages + "</b><br /><a href=\"" + pageURL + "\">More...</a></p></td></tr><tr><td style=\"border-left: 1px green solid; border-bottom: 2px green solid;background: white; -moz-border-radius: 0 0 0 12px;\">&nbsp;</td><td style=\"background: white;\" align=\"center\" colspan=\"2\"><a href=\"" + contactURL +"\" style=\"font-weight:bold\">Contact</a></td><td style=\"border-right: 1px green solid; border-bottom: 2px green solid;background: white; -moz-border-radius: 0 0 12px 0;\">&nbsp;</td></tr></table><table width=\"240\" cellspacing=\"0\"cellpadding=\"3\"style=\"position: relative; margin-top: -2px;\"><tr><td style=\"background: transparent;\">&nbsp;</td><td style=\" width: 100px;border-top: 2px green solid; border-right: 1px green solid;background: transparent; -moz-border-radius: 0 12px 0 0;\"><br /></td><td style=\"width: 100px;border-top: 2px green solid; border-left: 1px green solid;background: transparent; -moz-border-radius: 12px 0 0 0;\"><br /></td><td style=\"background: transparent;\">&nbsp;</td></tr><tr><td colspan=\"4\" style=\"height: 6px;\"></td></tr></table></div>";
	}
function playMedia(where, width, height, what, how){
if(how == "flash")
{
document.getElementById(where).innerHTML = "<embed src=\"/mediaplayer.swf\" width=\"" +width+ "\" height=\"" +height+ "\" allowscriptaccess=\"always\" allowfullscreen=\"true\" flashvars=\"height=" +height+ "&width=" +width+ "&file=" +what+ "&autostart=true\" />";
}
if(how == "qt")
{
if (!QTinstalled())
{ 
document.getElementById("noqt").style.display = "block";
return true;
}
document.getElementById(where).innerHTML = "<iframe src=\"" +what+ "\" width=\"" +width+ "\" frameborder=\"0\" height=\"" +height+ "\" scrolling=\"no\"></iframe>";
}
}	
/////////////////// Smooth Scroling to internal links ////
var ss = {
  fixAllLinks: function() {
    // Get a list of all links in the page
    var allLinks = document.getElementsByTagName('a');
    // Walk through the list
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) && 
          ( (lnk.pathname == location.pathname) ||
	    ('/'+lnk.pathname == location.pathname) ) && 
          (lnk.search == location.search)) {
        // If the link is internal to the page (begins in #)
        // then attach the smoothScroll function as an onclick
        // event handler
        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
  },
  smoothScroll: function(e) {
    // This is an event handler; get the clicked on element,
    // in a cross-browser fashion
    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;
    // Make sure that the target is an element, not a text node
    // within an element
    if (target.nodeName.toLowerCase() != 'a') {
      target = target.parentNode;
    }
  
    // Paranoia; check this is an A tag
    if (target.nodeName.toLowerCase() != 'a') return;
  
    // Find the <a name> tag corresponding to this href
    // First strip off the hash (first character)
    anchor = target.hash.substr(1);
    // Now loop all A tags until we find one with that name
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }
    if (!destinationLink) destinationLink = document.getElementById(anchor);
    // If we didn't find a destination, give up and let the browser do
    // its thing
    if (!destinationLink) return true;
  
    // Find the destination's position
    var destx = destinationLink.offsetLeft; 
    var desty = destinationLink.offsetTop;
    var thisNode = destinationLink;
    while (thisNode.offsetParent && 
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }
  
    // Stop any current scrolling
    clearInterval(ss.INTERVAL);
  
    cypos = ss.getCurrentYPos();
  
    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
    ss.INTERVAL =
setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);
  
    // And stop the actual click happening
    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },
  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
      // if we've just scrolled past the destination, or
      // we haven't moved from the last scroll (i.e., we're at the
      // bottom of the page) then scroll exactly to the link
      window.scrollTo(0,dest);
      // cancel the repeating timer
      clearInterval(ss.INTERVAL);
      // and jump to the link directly so the URL's right
      location.hash = anchor;
    }
  },
  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },
  addEvent: function(elm, evType, fn, useCapture) {
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,  NS6 and Mozilla
    // By Scott Andrew
    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  } 
}
ss.STEPS = 44;
ss.addEvent(window,"load",ss.fixAllLinks);
///////// End smooth scroling/////
