// Functions from Netscape's JavaScript Guide
// http://developer.netscape.com/docs/manuals/js/client/jsguide/

function setCookie(name, value, expire, path) {
	document.cookie = name + '=' + escape(value)
		+ ((expire == null)? '' : ('; expires=' + expire.toGMTString()))
		+ ((path == null)? '' : ('; path=' + path));
}

function getCookie(Name) {
	var search = Name + '='
	if (document.cookie.length > 0) { // if there are any cookies
		offset = document.cookie.indexOf(search) 
		if (offset != -1) { // if cookie exists 
			offset += search.length 
			// set index of beginning of value
			end = document.cookie.indexOf(';', offset) 
			// set index of end of cookie value
			if (end == -1) 
				end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		}
	}
	return '';
}

// banner cookies

function getFormValue(name) {
	var search = name + '='
	if (document.location.search.length > 0) {
		var offset = document.location.search.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			var end = document.location.search.indexOf('&', offset);
			if (end == -1) end = document.location.search.length;
			return unescape(document.location.search.substring(offset, end))
		}
	}
	return '';
}

function setBannerCookie() {
	var rbValue = getFormValue('rb');
	if ( rbValue != '' ) {
		var expDate = new Date();
		expDate.setDate( expDate.getDate() + 14 );
		setCookie('rb', rbValue, expDate, '/');
	}
}

setBannerCookie();

// top menu

var menuImages = new Array();
if (document.images) {
	function preloadedImage(imgURI) {
		var newImage = new Image();
		newImage.src = imgURI;
		return newImage;
	}
	
	menuImages['feedback'] = [preloadedImage('/off-line/feedback/p.gif'), preloadedImage('/off-line/feedback/p-a.gif')];
	menuImages['products'] = [preloadedImage('/off-line/products/p.gif'), preloadedImage('/off-line/products/p-a.gif')];
	menuImages['catalog'] = [preloadedImage('/images/p_catalog1.gif'), preloadedImage('/images/p_catalog2.gif')];
	menuImages['contacts'] = [preloadedImage('/images/p_contacts1.gif'), preloadedImage('/images/p_contacts2.gif')];

	menuImages['press'] = [preloadedImage('/images/p_press1.gif'), preloadedImage('/images/p_press2.gif')];
	menuImages['about'] = [preloadedImage('/off-line/about/p.gif'), preloadedImage('/off-line/about/p-a.gif')];
	menuImages['main'] = [preloadedImage('/images/p_main1.gif'), preloadedImage('/images/p_main2.gif')];
	menuImages['sitemap'] = [preloadedImage('/off-line/sitemap/p.gif'), preloadedImage('/off-line/sitemap/p-a.gif')];
}

function overItem(itemName) {
	if ( menuImages[itemName] && document.images[itemName + 'Img'] ) document.images[itemName + 'Img'].src = menuImages[itemName][1].src;
}

function outItem(itemName, imagePtr) {
	if ( menuImages[itemName] && document.images[itemName + 'Img'] ) document.images[itemName + 'Img'].src = menuImages[itemName][0].src;
}

function clickStatistic(id) {
	var unique=(new Date()).getTime();
	a=new Image();
	a.src='/_click.html?id='+id+'&unique='+unique;
}
