function newPicWindow (p_title, p_image, p_w, p_h)
{
	var l_w = p_w + 30;
	var l_h = p_h + 50;

	var CW_PW = open ('', 'CW_Zoom', 'resizable=yes,scrollbars=yes,width=' +
		l_w + ',height=' + l_h);
	CW_PW.document.write('<HTML><HEAD><TITLE>' + p_title + '</TITLE></HEAD>' +
		'<BODY><link rel="stylesheet" href="/cpu_world.css" type="text/css"><TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0 CLASS="CW_cpudata"><TR BGCOLOR="#C0C0C0"><TD ALIGN=CENTER><B>' + p_title + '</B></TR>' +
		'<TR><TD ALIGN=CENTER STYLE="border-style: solid; border-width: 1"><IMG SRC="' + p_image + '" ALT="' + p_title + '"></TR>' +
		'<TR><TD ALIGN=RIGHT BGCOLOR="#404040"><FONT SIZE=1 COLOR="#FFFFFF">(c) Copyright 2003 - 2007 Gennadiy Shvets</FONT>&nbsp;</TR>' +
		'</TABLE></BODY></HTML>');
	CW_PW.document.close();
}

function newWindow (p_script, p_w, p_h)
{
	var l_w = p_w + 30;
	var l_h = p_h + 50;

	var GenWindow = open (p_script, 'GenericWindow', 'resizable=yes,scrollbars=yes,width=' +
		l_w + ',height=' + l_h);
	if (GenWindow.opener == null) GenWindow.opener = self;
}

function newDieWindow (p_title, p_image, p_w, p_h)
{
	var l_w = p_w + 30;
	var l_h = p_h + 50;

	var CW_PW = open ('', 'CW_Die_Zoom', 'resizable=yes,scrollbars=yes,width=' +
		l_w + ',height=' + l_h);
	CW_PW.document.write('<HTML><HEAD><TITLE>' + p_title + '</TITLE></HEAD>' +
		'<BODY><link rel="stylesheet" href="/cpu_world.css" type="text/css"><TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0 CLASS="CW_cpudata"><TR BGCOLOR="#C0C0C0"><TD ALIGN=CENTER><B>' + p_title + '</B></TR>' +
		'<TR><TD ALIGN=CENTER STYLE="border-style: solid; border-width: 1"><IMG SRC="' + p_image + '" ALT="' + p_title + '"></TR>' +
		'<TR><TD ALIGN=RIGHT BGCOLOR="#404040"><FONT SIZE=1 COLOR="#FFFFFF">(c) Copyright 2005 - 2007 <A HREF="/info/die_pictures.html">William Blair</A></FONT>&nbsp;</TR>' +
		'</TABLE></BODY></HTML>');
	CW_PW.document.close();
}

function newUploadWindow (p_title, p_image, p_w, p_h)
{
	var l_w = p_w + 40;
	var l_h = p_h + 50;

	var CW_PW = open ('', 'CW_Upload_Zoom', 'resizable=yes,scrollbars=yes,width=' +
		l_w + ',height=' + l_h);
	CW_PW.document.write('<HTML><HEAD><TITLE>' + p_title + '</TITLE></HEAD>' +
		'<BODY style="margin: 2px"><div style="font-family: arial, helvetica; font-size: 14; font-weight: bold; text-align: center; background-color: #C0C0C0; margin: 0">' + p_title + '</div><div style="padding: 5px; text-align: center; vertical-align: middle"><IMG SRC="' +
		p_image + '" alt="' + p_title + '"></div><div style="font-family: arial, helvetica; text-align: right; background-color: #404040; color: #FFFFFF; font-size: 11; padding-right: 5px; margin: 0">(c) Image is copyrighted by its author</div></BODY></HTML>');
	CW_PW.document.close();
}

function newPriceChartWindow (p_title, p_image, p_w, p_h)
{
	var l_w = p_w + 40;
	var l_h = p_h + 65;

	var CW_PW = open ('', 'CW_PriceChart', 'resizable=yes,scrollbars=yes,width=' +
		l_w + ',height=' + l_h);
	CW_PW.document.write('<html><head><title>' + p_title + '</title></head>' +
		'<body style="margin: 1px"><div style="font-family: arial, helvetica; font-size: 14; font-weight: bold; text-align: center; background-color: #C0C0C0; margin: 0">' + p_title + '</div><div style="padding: 5px; text-align: center; vertical-align: middle"><IMG SRC="' +
		p_image + '" alt="' + p_title + '"></div><div style="font-family: arial, helvetica; font-size: 11">' +
		'<div style="padding: 3px 3px 3px 30px; margin: 0"><b>OEM processors</b>: price per CPU is for 1000-quantity lots<br><b>Boxed processors</b>: price is for one CPU.</div></BODY></HTML>' +
		'<div style="text-align: right; background-color: #404040; color: #FFFFFF; padding-right: 5px; margin: 0">(c) Copyright 2003 - 2007 Gennadiy Shvets</div></div></BODY></HTML>');

	CW_PW.document.close();

	return false;
}

function	OnOff ()
{
	var i;
	var obj;
	var field;
	var visible = 1;
	var len = arguments.length;
	for (i = 0; i < len; i++)
	{
		field = arguments[i];
		if	(field == '')
		{
			visible = 0;
			continue;
		}
		obj = document.getElementById (field);
		if	(obj == null)	continue;
		obj.style.display = (visible)?
			((obj.nodeName.match(/^(TABLE|TBODY|TR)$/))? '': 'block'): 'none';
	}
	return false;
}

function	SetupSearch ()
{
	document.TOP_F_SE.SEARCH.value = ' Search ';
	document.TOP_F_SE.SEARCH.style.color = '#D0D0D0';
	document.TOP_F_ID.PART.value = ' Identify ';
	document.TOP_F_ID.PART.style.color = '#D0D0D0';
	if	(CW_cookie_status != -1)
	{
		var state = GetCookie('SE');
		if	(state == 'I')
		{
			OnOff("TOP_ID", "", "TOP_SE");
			document.getElementById("TOP_RI").checked = true;
		}
	}
}

function	SetupFilter ()
{
	var obj = document.getElementById('CW_FILTER');
	if	(obj == null)	return;
	obj.value = ' Filter ';
	obj.style.color = '#D0D0D0';
}

function SwSearch (p_type)
{
	if	(p_type == 'S')
		OnOff("TOP_SE", "", "TOP_ID");
	else
		OnOff("TOP_ID", "", "TOP_SE")
	SetCookie ('SE', p_type, 365);
}

var CW_cookie_status = 1;
var CW_last_visit;

function GetCookie (p_name)
{

	if	(CW_cookie_status == -1)	return '';
	var c = document.cookie;
	var start = c.indexOf (p_name + '=');
	if	(start == -1)	return '';
	var len = start + p_name.length + 1;
	var end = c.indexOf (";", len);
	if	(end == -1)		end = c.length;
	return unescape (c.substring (len, end));
}

function SetCookie (p_name, p_value, p_days)
{

	if	(CW_cookie_status == -1)	return;
	var exp_date = new Date();
	exp_date.setTime (exp_date.getTime () + p_days * 86400000);
	var expires = exp_date.toGMTString ();
    document.cookie = p_name + "=" + escape (p_value) +
		"; expires=" + expires + "; path=/";
}

//	See if the browser accepts cookies
if	(GetCookie ('XX') == "")
{
	SetCookie ('XX', 'OK', 1);
	if	(GetCookie ('XX') != "OK")
		CW_cookie_status = -1;
}
if	(CW_cookie_status != -1)
	SetVisitTime();

function	SetVisitTime ()
{

	if	(CW_cookie_status == -1)	return;
	var current_date = new Date();
	var l_now = parseInt (current_date.getTime () / 1000);

	// Find out when the user visited us the last two times
	var l_last = GetCookie ('LV1');
	l_last = (l_last == '')? l_now: parseInt (l_last);
	var l_last2 = GetCookie ('LV2');
	l_last2 = (l_last2 == "")? l_now: parseInt (l_last2);

	// Determine what time to use as the last visit time - if the last time
	// is less than one hour ago then use the time before the last time
	if	(l_now > (l_last + 3600))
	{
		CW_last_visit = l_last;
		l_last2 = l_last;
	}
	else
		CW_last_visit = l_last2;
	l_last = l_now;
	// Save updated visit times
	SetCookie ('LV1', l_last, 365);
	SetCookie ('LV2', l_last2, 365);
}

var CW_data_onload = new Array ();
var CW_onload_initialized = 0;
function	SetOnload (p_func)
{

	if	(window.addEventListener)
		window.addEventListener("load", p_func, false);
	else if (window.attachEvent)
		window.attachEvent ("onload", p_func);
	else
	{
		if	(!CW_onload_initialized)
		{
			if	(window.onload)
    			CW_data_onload.push(window.onload);

			if  ((window.onload_cw == null)&&(window.onload != null))
				window.onload_cw = window.onload;
			// Assign new onload function
			window.onload = CW_ProcessOnload;
		}
		CW_onload_initialized = 1;
		CW_data_onload.push (p_func);
	}
}

function	ProcessOnload ()
{

	var len = CW_data_onload.length;
	for (var i = 0; i < len; i++)
	{
		CW_data_onload[i]();
	}
	CW_data_onload.length = 0;
}

var W_delay = 500;
var	W_function;
var	W_timeout_id;
var	W_obj;
var	W_filter_last;

function	Watching_Start (p_event, p_obj, p_function, p_delay)
{
	W_obj = p_obj;
	W_function = p_function;
	W_delay = (p_delay == null)? 500: p_delay;
	p_obj.onkeyup = Watching_ResetTimer;
	p_obj.onkeydown = Watching_ResetTimer;
	Watching_ResetTimer ();
	W_filter_last = p_obj.value;
}

function	Watching_Stop (p_event, p_obj, p_function)
{
	p_obj.onkeyup = null;
	p_obj.onkeydown = null;
	if	(W_timeout_id)		window.clearTimeout (W_timeout_id);
	W_timeout_id = null;
	if	(p_function != null)
		p_function (p_event);
}

function	Watching_ResetTimer ()
{
	if	(W_timeout_id)	window.clearTimeout (W_timeout_id);
	W_timeout_id = window.setTimeout(Watching_Timeout, W_delay);
}

function	Watching_Timeout ()
{
	W_timeout_id = null;
	var value = W_obj.value;
	if	((W_filter_last == null)||(W_filter_last != value))
		W_function (W_obj.id, value);
	W_filter_last = value;
}

// gs_links.js
// Dynamic Link builder script
// Copyright 2007 Gennadiy Shvets
// The program is distributed under the terms of the GNU General
// Public License 3.0

var L_urlPrefix = '';
var L_allLinks = new Array (
'ABM', '/Glossary/A/Advanced_Bit_Manipulation.html',
'AMD64', '/Glossary/A/AMD64_technology.html',
'AUTOHALT_MODE', '/Glossary/A/Auto_Halt_Power_Down_state.html',
'CLOCK_MULT', '/Glossary/B/Bus_clock_multiplier.html',
'COOLCORE', '/Glossary/C/CoolCore_technology.html',
'DDA', '/Glossary/D/Dual_Dynamic_Acceleration.html',
'DEEP_SLEEP_MODE', '/Glossary/D/Deep_Sleep_state.html',
'DEEPER_SLEEP', '/Glossary/D/Deeper_Sleep_state.html',
'DPD', '/Glossary/D/Deep_Power_Down_state.html',
'DUAL_DYN_POWER', '/Glossary/D/Dual_dynamic_power_management.html',
'DYN_CACHE_SIZING', '/Glossary/D/Dynamic_Cache_Sizing.html',
'DYN_FSB_FREQ', '/Glossary/D/Dynamic_FSB_Frequency_Switching.html',
'EM64T', '/Glossary/E/Extended_Memory_64_technology_(EM64T).html',
'ENH_DEEPER_SLEEP', '/Glossary/E/Enhanced_Deeper_Sleep_state.html',
'ENH_POWERNOW', '/Glossary/E/Enhanced_PowerNow_technology.html',
'ENH_SSTEP', '/Glossary/E/Enhanced_SpeedStep_technology.html',
'EVP_XD', '/Glossary/E/EVP_XD.html',
'FREQ', '/Glossary/C/CPU_Frequency.html',
'FSB', '/Glossary/F/Front_Side_Bus_(FSB).html',
'HTRANSPORT', '/Glossary/H/HyperTransport_technology.html',
'IDA', '/Glossary/D/Dynamic_Acceleration_technology.html',
'INDEP_DYN_CORE', '/Glossary/I/Independent_dynamic_core_technology.html',
'L1', '/Glossary/L/Level_1_cache.html',
'L2', '/Glossary/L/Level_2_cache.html',
'MIN_MAX_POWER', '/Glossary/M/Minimum_Maximum_power_dissipation.html',
'MIN_MAX_TEMP', '/Glossary/M/Minimum_Maximum_operating_temperatures.html',
'MODELN', '/Glossary/P/Processor_Model_number.html',
'SLEEP_MODE', '/Glossary/S/Sleep_state.html',
'SSE4', '/Glossary/S/SSE4.html',
'SSE41', '/Glossary/S/SSE4.1.html',
'SSE42', '/Glossary/S/SSE4.2.html',
'SSE4A', '/Glossary/S/SSE4a.html',
'SSPEC', '/Glossary/S/Specification_(S-Spec)_number.html',
'SSTEP', '/Glossary/S/SpeedStep_technology.html',
'STOP_GRANT_MODE', '/Glossary/S/Stop_Grant_state.html',
'TDP', '/Glossary/T/Thermal_Design_Power_(TDP).html',
'TBT', '/Glossary/T/Turbo_Boost_Technology.html',
'VCORE', '/Glossary/C/Core_voltage.html'
);

var L_text2Link = new Object;

function L_findLinks ()
{

	// Copy all data to associative array
	var len = L_allLinks.length;
	for (var i = 0; i < L_allLinks.length; i += 2)
	{
		L_text2Link[L_allLinks[i]] = L_allLinks[i + 1];
	}
	// Loop through all DIV and SPAN tags on the page
	L__processElements ('DIV');
	L__processElements ('SPAN');
	// Free some memory
	L_text2Link = null;

	if	(window.onload_gsl_saved)
		window.onload_gsl_saved();
}

function L__processElements (p_type)
{

	var array = document.getElementsByTagName(p_type);
	if	(array == null)  return;
	var cl;
	var one_el;
	var text;
	var url;
	var prefix = (L_urlPrefix == null)? '': L_urlPrefix;
	for (var i = 0; i < array.length; i++)
	{
		one_el = array[i];
		cl = one_el.className;
		if	(!cl.match(/^_link(\s+|$)/))  continue;
		text = cl.replace(/^_link\s*/, '');
		text = text.replace(/^[^\s_]\S+\s*/, '');
		if	(!text.match(/^_/))
			text = text.replace(/^\S+\s*/, '');
		if	(text)
			text = text.replace(/^_/, '');
		else
		{
			text = one_el.innerHTML.replace(/<[^>]+>/g, '');
			text = text.replace(/&nbsp;/g, '');
		}
		url = L_text2Link[text];
		if	(url == null)  continue;
		one_el.innerHTML = '<a href="' + prefix + url + '" target="_blank">' + one_el.innerHTML + '</a>';
	}
}

SetOnload(L_findLinks);

//
//	Tabs - based on http://akrabat.com/dynamic-javascript-tabs/
//
function getChildrenByClass(p_parent, p_class)
{
	var result = new Array();
	var pattern = new RegExp("\\b" + p_class + "\\b");

	var els = p_parent.getElementsByTagName('*');
	for	(var i = 0; i < els.length; i++)
	{
		if	(els[i].className.search(pattern) != -1)
			result.push(els[i]);
	}
	return result;
}

function TabsBuild(p_id, p_n)
{
	var i, th, title, tabElement, li, tabLink;

	// assume that if document.getElementById exists, then this will work...
	if(! eval('document.getElementById') ) return;

	var tabContainer = document.getElementById(p_id);
	if	(tabContainer == null)	return;

	var tabContents = getChildrenByClass(tabContainer, 'tab-content');
	if(tabContents.length == 0)
		return;
	var div = document.createElement("div");
	div.className = 'tab-header';
	div.id = p_id + '-header';
	var ul = document.createElement("ul");
	ul.className = 'tab-list';

	tabContainer.insertBefore(div, tabContents[0]);
	div.appendChild(ul);

	for(i = 0; i < tabContents.length; i++)
	{
		th = getChildrenByClass(tabContents[i], 'tab');
		if	(th == null)	continue;
//		title = th[0].childNodes[0].nodeValue;
		title = th[0].innerHTML;
		title = title.replace (/<[^>]*>/g, '');

		// create the tabs as an unsigned list
		li = document.createElement("li");
		li.id = p_id + '-tab-' + i;
		ul.appendChild(li);

		tabLink = document.createElement("a");
		tabLink.className = "tab-item";
		tabLink.setAttribute("href","javascript://");
		tabLink.setAttribute( "title", th[0].getAttribute("title"));
		tabLink.onclick = new Function ("TabsActivate('" + p_id + "', " + i + ")");

		li.appendChild(tabLink);
		tabLink.appendChild(document.createTextNode(title));

		th[0].style.display = 'none';
	}

	TabsActivate (p_id, p_n);
}

function TabsActivate(p_id, activeTabIndex)
{
	var tabContainer = document.getElementById(p_id);
	if	(tabContainer == null)	return;

	var tabContents = getChildrenByClass(tabContainer, 'tab-content');
	if(tabContents.length == 0)	return;
	var i;
	for(i = 0; i < tabContents.length; i++)
		tabContents[i].style.display = "none";

	tabContents[activeTabIndex].style.display = "block";

	tabList = document.getElementById(p_id + '-list');
	tabs = getChildrenByClass(tabContainer, 'tab-item');
	if(tabs.length > 0)
	{
		for(i = 0; i < tabs.length; i++)
			tabs[i].className = "tab-item";

		tabs[activeTabIndex].className = "tab-item tab-active";
		tabs[activeTabIndex].blur();
	}
}

function TabsInit () {	TabsBuild('tab-container', 0); }

SetOnload (TabsInit);

