// JavaScript Document
var sect = 0;

function bodyOnLoadHandler(){
	document.domain = "guruenergy.com";
/*
	if (window.location.protocol.toLowerCase() =='http:') {
		// alert('secure');
		window.location.href = window.location.href.replace('http:','https:');
		return;
	}
*/
	if (top == self)
	{
		 // window.location = '../'+'#'+location.href
		var url = location.href;
		url = url.replace(/http:\/\/[^\/]+/i,"");
		window.location = '/'+'#'+url;
		/*
		if (url == "/qc/drinks.php")
			window.location = '/'+'#'+url;
		else
			window.location = '/?lang=fr'+'#'+url;
		*/
	}
	if (window != parent) {
		// parent.setThemeId(0);
		parent.setThemeId(sect);
		var url = location.href;
		// url = url.replace("http://www.domain.com",""); 
		url = url.replace(/http:\/\/[^\/]+/i,"");
		parent.location.hash = '#'+url;
		parent.document.title = document.title;
		parent.deactivateTopMenu();
	}
}

function load_value(variable) 
{ 
// http://www.elguruprogramador.com.ar/articulos/pasando-datos-entre-paginas-con-javascript.htm
	var remplaza = /\+/gi; 
	var url = window.location.href;

	url = unescape(url);
	url = url.replace(remplaza, " ");
	url = url.toUpperCase();
	var variable_may = variable.toUpperCase();
	var variable_pos = url.indexOf(variable_may);
	if (variable_pos != -1) 
	{
		var pos_separador = url.indexOf("&", variable_pos);
		if (pos_separador != -1) {
			return url.substring(variable_pos + variable_may.length + 1, pos_separador);
		} else {
			return url.substring(variable_pos + variable_may.length + 1, url.length);
		}
	} else {
		return " ";
	}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function findPos(divId) {
// http://www.webdeveloper.com/forum/archive/index.php/t-73755.html
	document.domain = "guruenergy.com";
	var obj = document.getElementById(divId);
	var posX = obj.offsetLeft;
	var posY = obj.offsetTop;
	/*
while(obj.parentNode){
		posX=posX+obj.parentNode.offsetLeft;
		posY=posY+obj.parentNode.offsetTop;
		if(obj==document.getElementsByTagName('body')[0]){break}
		else{obj=obj.parentNode;}
	}
*/
	// alert(posX+'-'+posY)
	return posY;
}
function jumpDiv(divId) {
	document.domain = "guruenergy.com";
	var jump = findPos(divId)+500; // -100;
	parent.scrollToDiv(jump);
}

function actSection(change) {
	sect = change;
}
function loadSubscribe() {
	document.domain = "guruenergy.com";	
parent.openSubscribe();
}
