// JavaScript Document

// cookie functions

function set_cookie(name, value) {
	var cookie_string = name + "=" + escape(value);
	document.cookie = cookie_string;
}

function get_cookie(cookie_name) {
	var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
	if(results)
		return (unescape(results['path']));
	else
		return null;
}

// functions

// BROWSER DETECT
browser = navigator.appName;

function setAfterTime(func, time, color) {
	var banner_image = document.getElementById('banner_image');
	var banner_link = document.getElementById('banner_link');
	// adding values into element
	document.getElementById('btn1').title = link1['title'];
	document.getElementById('link1').innerHTML = "<strong>" + link1['title'] + "</strong>";
	document.getElementById('link1').href = "#" + link1['title'];
	document.getElementById('btn2').title = link2['title'];
	document.getElementById('link2').innerHTML = "<strong>" + link2['title'] + "</strong>";
	document.getElementById('link2').href = "#" + link2['title'];
	document.getElementById('btn3').title = link3['title'];
	document.getElementById('link3').innerHTML = "<strong>" + link3['title'] + "</strong>";
	document.getElementById('link3').href = "#" + link3['title'];
	document.getElementById('btn4').title = link4['title'];
	document.getElementById('link4').innerHTML = "<strong>" + link4['title'] + "</strong>";
	document.getElementById('link4').href = "#" + link4['title'];
	//
	time = time + '000';
	if(get_cookie("banner_cookie") == null) {
		setBannerImg('0');
		set_cookie("banner_cookie", "1");
		t = setTimeout(func, time);
	} else {
		t = null;
		setBannerImg('1');
		document.getElementById('btn1').className = 'selected';
		banner_link.style.cursor = 'pointer';
		banner_link.href = link1['link'];
		banner_link.title = link1['title'] + ' - ' + link1['link'];
	}
	if(color) {
		$('.customBackground').css({'background-color':''+color+''});$('.customColor').css({'color':''+color+''});
	}
}

function setBannerImg(id) {
	var banner_image = document.getElementById('banner_image');
	var banner_link = document.getElementById('banner_link');
	if(id==null) {
		img_path = link1['path'];
		img_height = link1['height'] + 'px';

		// DETECT IF SAFARI/NETSCAPE IS USED
		if(browser=='Netscape') {
			style = "<img src='" + img_path + "' width='610' height='" + img_height + "' />";
		} else {
			style = "<BR><style> .bannerIMG { background-image: url(" + img_path + "); width: 610px; height: " + img_height + "; } * html .bannerIMG { background: none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img_path + "', sizingMethod='crop'); } </style>";
		}

		banner_image.innerHTML = style;
		banner_image.className = 'bannerIMG';
		banner_link.style.cursor = 'pointer';
		document.getElementById('btn1').className = 'selected';
		banner_link.href = link1['link'];
		banner_link.title = link1['title'] + ' - ' + link1['link'];
	} else {
		if(id==0) {
			img_path = link0['path'];
			img_height = link0['height'] + 'px';

			// DETECT IF SAFARI/NETSCAPE IS USED
			if(browser=='Netscape') {
				style = "<img src='" + img_path + "' width='610' height='" + img_height + "' />";
			} else {
				style = "<BR><style> .bannerIMG { background-image: url(" + img_path + "); width: 610px; height: " + img_height + "; } * html .bannerIMG { background: none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img_path + "', sizingMethod='crop'); } </style>";
			}

			banner_image.innerHTML = style;
			banner_image.className = 'bannerIMG';
		} else {
			img_path = link1['path'];
			img_height = link1['height'] + 'px';

			// DETECT IF SAFARI/NETSCAPE IS USED
			if(browser=='Netscape') {
				style = "<img src='" + img_path + "' width='610' height='" + img_height + "' />";
			} else {
				style = "<BR><style> .bannerIMG { background-image: url(" + img_path + "); width: 610px; height: " + img_height + "; } * html .bannerIMG { background: none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img_path + "', sizingMethod='crop'); } </style>";
			}

			banner_image.innerHTML = style;
			banner_image.className = 'bannerIMG';
		}
	}
}

function getBannerImg(id) {
	var banner_link = document.getElementById('banner_link');
	banner_link.style.cursor = 'pointer';
	if(t!=null) {
		clearTimeout(t);
	}
	var banner_image = document.getElementById('banner_image');
	var btn_id = 'btn' + id;
	var btn_id = document.getElementById(btn_id);
	var btn1 = document.getElementById('btn1');
	var btn2 = document.getElementById('btn2');
	var btn3 = document.getElementById('btn3');
	var btn4 = document.getElementById('btn4');
	btn_id.className = 'selected';
	if(id==1) {
		img_path = link1['path'];
		img_height = link1['height'] + 'px';
		// DETECT IF SAFARI/NETSCAPE IS USED
		if(browser=='Netscape') {
			style = "<img src='" + img_path + "' width='610' height='" + img_height + "' />";
		} else {
			style = "<BR><style> .bannerIMG { background-image: url(" + img_path + "); width: 610px; height: " + img_height + "; } * html .bannerIMG { background: none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img_path + "', sizingMethod='crop'); } </style>";
		}
		banner_image.innerHTML = style;
		banner_image.className = 'bannerIMG';
		id.className = 'selected';
		if(link1['link']!='') {
			banner_link.href = link1['link'];
			banner_link.title = link1['title'] + ' - ' + link1['link'];
		} else {
			banner_link.removeAttribute('href');
			banner_link.title = '';
			banner_link.style.cursor = 'default';
		}
		btn2.className = '';
		btn3.className = '';
		btn4.className = '';
	}
	if(id==2) {
		img_path = link2['path'];
		img_height = link2['height'] + 'px';
		// DETECT IF SAFARI/NETSCAPE IS USED
		if(browser=='Netscape') {
			style = "<img src='" + img_path + "' width='610' height='" + img_height + "' />";
		} else {
			style = "<BR><style> .bannerIMG { background-image: url(" + img_path + "); width: 610px; height: " + img_height + "; } * html .bannerIMG { background: none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img_path + "', sizingMethod='crop'); } </style>";
		}
		banner_image.innerHTML = style;
		banner_image.className = 'bannerIMG';
		id.className = 'selected';
		if(link2['link']!='') {
			banner_link.href = link2['link'];
			banner_link.title = link2['title'] + ' - ' + link2['link'];
		} else {
			banner_link.removeAttribute('href');
			banner_link.title = '';
			banner_link.style.cursor = 'default';
		}
		btn1.className = '';
		btn3.className = '';
		btn4.className = '';
	}
	if(id==3) {
		img_path = link3['path'];
		img_height = link3['height'] + 'px';
		// DETECT IF SAFARI/NETSCAPE IS USED
		if(browser=='Netscape') {
			style = "<img src='" + img_path + "' width='610' height='" + img_height + "' />";
		} else {
			style = "<BR><style> .bannerIMG { background-image: url(" + img_path + "); width: 610px; height: " + img_height + "; } * html .bannerIMG { background: none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img_path + "', sizingMethod='crop'); } </style>";
		}
		banner_image.innerHTML = style;
		banner_image.className = 'bannerIMG';
		id.className = 'selected';
		if(link3['link']!='') {
			banner_link.href = link3['link'];
			banner_link.title = link3['title'] + ' - ' + link3['link'];
		} else {
			banner_link.removeAttribute('href');
			banner_link.title = '';
			banner_link.style.cursor = 'default';
		}
		btn1.className = '';
		btn2.className = '';
		btn4.className = '';
	}
	if(id==4) {
		img_path = link4['path'];
		img_height = link4['height'] + 'px';
		// DETECT IF SAFARI/NETSCAPE IS USED
		if(browser=='Netscape') {
			style = "<img src='" + img_path + "' width='610' height='" + img_height + "' />";
		} else {
			style = "<BR><style> .bannerIMG { background-image: url(" + img_path + "); width: 610px; height: " + img_height + "; } * html .bannerIMG { background: none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img_path + "', sizingMethod='crop'); } </style>";
		}
		banner_image.innerHTML = style;
		banner_image.className = 'bannerIMG';
		id.className = 'selected';
		if(link4['link']!='') {
			banner_link.href = link4['link'];
			banner_link.title = link4['title'] + ' - ' + link4['link'];
		} else {
			banner_link.removeAttribute('href');
			banner_link.title = '';
			banner_link.style.cursor = 'default';
		}
		btn1.className = '';
		btn2.className = '';
		btn3.className = '';
	}
}

function preLoader() {
	var loader = document.getElementById('loader');
	var img_error_msg = document.getElementById('img_error_msg');
	img_error_msg.innerHTML = "";
	loader.style.background = 'url(/images/loading.gif) no-repeat 50% 50%';
	l = setTimeout("loader()", 10000);
}

function loader() {
	var loader = document.getElementById('loader');
	var img_error_msg = document.getElementById('img_error_msg');
//	loader.style.background = 'none';
	loader.style.background = 'url(/images/noimage.gif) no-repeat 50% 50%';
	img_error_msg.innerHTML = "image error, please <strong>reload</strong> page";
	clearTimeout(l);
}