// JavaScript Document

function setFlashDiv() {
	if (!document.getElementById('maintd')) { return false; }
	var pos = objFindPos(document.getElementById('maintd'));
	var flash = document.getElementById('mag');
	var left = pos[0]; 
	flash.style.left = left + 'px';
	var top = pos[1] + 4; 
	flash.style.top = top + 'px';
	flash.style.display = '';
}
function objFindPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
function toc() {
	if (!document.getElementById('mag')) { 
		document.location.href='/index.php?toc=1';
		return;
	}
		
	document.magflash.SetVariable("doZoomPage", "toc");
}
function add(id, op) {
	document.form1.action = "https://headquest-net.vsourceweb.com/catalog/product_info.php?products_id="+id+"&action=add_product";
	document.form1.products_id.value = id;
	document.getElementById('issues').selectedIndex = op-1;
	document.form1.submit();
}

setTimeout('changeAd()', 1000);
setTimeout('changeAd2()', 1000);

var G = new Array();
G['AD'] = 1;
G['AD2'] = 1;
G['adtime'] = 0;
G['adtime2'] = 0;
function changeAd() {
	G['adtime']++;
	var ad = document.getElementById('ad'+G['AD']);
	var airtime = ad.getAttribute('airtime');
	if (G['adtime'] < airtime) { G['adtimeout'] = setTimeout('changeAd();', 1000); return; }
	
	// Change ad.
	G['AD']++;
	if (!document.getElementById('ad'+G['AD'])) { G['AD'] = 1; }
	
	// Hide all the ads.
	var i = 1;
	while (1) { 
		if (!document.getElementById('ad'+i)) { break; }
		document.getElementById('ad'+i).style.display = 'none';
		i++;
	}
	
	document.getElementById('ad'+G['AD']).style.display = '';
	G['adtime'] = 0;
	G['adtimeout'] = setTimeout('changeAd();', 1000);
}
function changeAd2() {
	G['adtime2']++;
	var ad = document.getElementById('2ad'+G['AD2']);
	var airtime = ad.getAttribute('airtime');
	if (G['adtime2'] < airtime) { G['adtimeout2'] = setTimeout('changeAd2();', 1000); return; }
	
	// Change ad.
	G['AD2']++;
	if (!document.getElementById('2ad'+G['AD2'])) { G['AD2'] = 1; }
	
	// Hide all the ads.
	var i = 1;
	while (1) { 
		if (!document.getElementById('2ad'+i)) { break; }
		document.getElementById('2ad'+i).style.display = 'none';
		i++;
	}
	
	document.getElementById('2ad'+G['AD2']).style.display = '';
	G['adtime2'] = 0;
	G['adtimeout2'] = setTimeout('changeAd2();', 1000);
}
function lastAd() {
	clearTimeout(G['adtimeout']);
	if (G['AD'] == 1) { 
		var i = 1;
		while (1) { 
			if (!document.getElementById('ad'+i)) { break; }
			i++;
		}
		G['AD'] = i-1;
	} else {
		G['AD']--;
	}
	
	// Hide all the ads.
	var i = 1;
	while (1) { 
		if (!document.getElementById('ad'+i)) { break; }
		document.getElementById('ad'+i).style.display = 'none';
		i++;
	}
	
	document.getElementById('ad'+G['AD']).style.display = '';
	G['adtime'] = 0;
	G['adtimeout'] = setTimeout('changeAd();', 1000);
}
function lastAd2() {
	clearTimeout(G['adtimeout2']);
	if (G['AD2'] == 1) { 
		var i = 1;
		while (1) { 
			if (!document.getElementById('2ad'+i)) { break; }
			i++;
		}
		G['AD2'] = i-1;
	} else {
		G['AD2']--;
	}
	
	// Hide all the ads.
	var i = 1;
	while (1) { 
		if (!document.getElementById('2ad'+i)) { break; }
		document.getElementById('2ad'+i).style.display = 'none';
		i++;
	}
	
	document.getElementById('2ad'+G['AD2']).style.display = '';
	G['adtime2'] = 0;
	G['adtimeout2'] = setTimeout('changeAd2();', 1000);
}
function nextAd() {
	clearTimeout(G['adtimeout']);
	G['AD']++;
	if (!document.getElementById('ad'+G['AD'])) { G['AD'] = 1; }
	
	// Hide all the ads.
	var i = 1;
	while (1) { 
		if (!document.getElementById('ad'+i)) { break; }
		document.getElementById('ad'+i).style.display = 'none';
		i++;
	}
	
	document.getElementById('ad'+G['AD']).style.display = '';
	G['adtime'] = 0;
	G['adtimeout'] = setTimeout('changeAd();', 1000);
}
function nextAd2() {
	clearTimeout(G['adtimeout2']);
	G['AD2']++;
	if (!document.getElementById('2ad'+G['AD2'])) { G['AD2'] = 1; }
	
	// Hide all the ads.
	var i = 1;
	while (1) { 
		if (!document.getElementById('2ad'+i)) { break; }
		document.getElementById('2ad'+i).style.display = 'none';
		i++;
	}
	
	document.getElementById('2ad'+G['AD2']).style.display = '';
	G['adtime2'] = 0;
	G['adtimeout2'] = setTimeout('changeAd2();', 1000);
}