function BrowserInfo() {
	var agent = window.navigator.userAgent;
	if (agent.indexOf("MSIE") != -1) {
			var start = agent.indexOf("MSIE");
			this.name = "MSIE";
			this.version = parseFloat(agent.substring(start + 5, agent.indexOf(";", start)));
	} else if (agent.indexOf("Firefox") != -1) {
			var start = agent.indexOf("Firefox");
			this.name = "Firefox";
			this.version = agent.substring(start + 8, agent.length);
			var firstDec = this.version.indexOf(".") + 1;
			while (this.version.indexOf(".", firstDec) != -1)
				this.version = this.version.substring(0, firstDec) + this.version.substring(firstDec).replace(".", "");
			this.version = parseFloat(this.version);
	} else {
			this.name = "Unknown";
			this.version = 0;
	}
}

var info = new BrowserInfo();
var userAgent = window.navigator.userAgent
var isIE = (window.navigator.userAgent.indexOf("MSIE") != -1);
var isIE6 = (info.name == "MSIE" && info.version < 7);
var isSafari = (window.navigator.userAgent.indexOf("Safari") != -1);
var isMac = navigator.appVersion.indexOf("Mac")!=-1;
var isFireFox = (window.navigator.userAgent.indexOf("Firefox") != -1);
var isFireFox3 = ((window.navigator.userAgent.indexOf("Firefox") != -1) && info.version >= 3);
var isMacFireFox = isMac && isFireFox;
var isMacFireFox3 = isMac && isFireFox3;
var is_iPod = navigator.appVersion.indexOf("iPod")!=-1;
var is_iPhone = navigator.appVersion.indexOf("iPhone")!=-1;



if (info.name == "MSIE" && info.version < 7)
	document.writeln('<link href="stylesIE6.css" rel="stylesheet" type="text/css" />');
else
	document.writeln('<link href="stylesDynamic.css" rel="stylesheet" type="text/css" />');

if (isIE)
	document.writeln('<link href="stylesIE.css" rel="stylesheet" type="text/css" />');

function renderFlash(src, width, height, features) {
	document.writeln('<embed wmode="transparent" src="' + src + '" quality="high" width="' + width + 
					 '" height="' + height + '" align="middle" allowscriptaccess="sameDomain" ' +
					 'type="application/x-shockwave-flash" ' + features + 
					 'pluginspage="http://www.macromedia.com/go/getflashplayer" />');
}

function writePngImage(url, width, height, alt) {
	if (!isIE6)
		document.write("<img alt=\"" + alt + "\" src=\"" + url + "\" style=\"width: " + width + "px; height: " + height + "px;\">");
	else
		document.write("<img alt=\"" + alt + "\" src=\"spacer.png\" style=\"width: " + width + "px; height: " + height + 
			"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "', sizingMethod=scale);\">");
}

function writePngClass(url, width, height, alt, className) {
	if (!isIE6)
		document.write("<img class=\"" + className + "\" alt=\"" + alt + "\" src=\"" + url + "\" style=\"width: " + width + "px; height: " + height + "px;\">");
	else
		document.write("<img class=\"" + className + "\" alt=\"" + alt + "\"  src=\"spacer.png\" style=\"width: " + width + "px; height: " + height + 
			"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "', sizingMethod=scale);\">");
}

String.prototype.format = function()
{
	var pattern = /\{\d+\}/g;
	var args = arguments;
	return this.replace(pattern, function(capture){ return args[capture.match(/\d+/)]; });
}   

reset_form_value = function(str1, str2, val) {
	if(str1 == val.value.trim())
		val.value = str2;
}

 var sliderPanels = new Array("homeSlider_set01", "homeSlider_set02", "homeSlider_set03");
 var curSliderIndex = 0;
 var isAnim = false;
 
 function slideRight() {
	var anim = CSNGAnim.create({
		objectId: sliderPanels[curSliderIndex],
		property: "left",
		speed: 10,
		steps: 35,
		start: 0,
		stop: -975,
		onComplete: function() { this.object.style.display = "none"; }
	});
	
	curSliderIndex++;
	if (curSliderIndex >= sliderPanels.length) {
		curSliderIndex--;
		return;
	}
	
	document.getElementById("left_arrow").className = "left_arrow";
	
	document.getElementById(sliderPanels[curSliderIndex]).style.top = "-192px";
	document.getElementById(sliderPanels[curSliderIndex]).style.display = "block";
	anim.start();
	
	var anim2 = CSNGAnim.create({
		objectId: sliderPanels[curSliderIndex],
		property: "left",
		speed: 10,
		steps: 35,
		start: 975,
		stop: 0,
		onComplete: function() { this.object.style.top = "0px"; }
	});
	anim2.start();
	
	if (curSliderIndex + 1 >= sliderPanels.length) {
		document.getElementById("right_arrow").className = "right_arrow_empty";
	}
 }
 
 function slideLeft() {
	var anim = CSNGAnim.create({
		objectId: sliderPanels[curSliderIndex],
		property: "left",
		speed: 10,
		steps: 35,
		start: 0,
		stop: 975,
		onComplete: function() { this.object.style.display = "none"; this.object.style.top = "0px"; }
	});
	
	var prevSlider = curSliderIndex;
	curSliderIndex--;
	if (curSliderIndex < 0) {
		curSliderIndex++;
		return;
	}
	
	document.getElementById("right_arrow").className = "right_arrow";
	
	document.getElementById(sliderPanels[prevSlider]).style.top = "-192px";
	document.getElementById(sliderPanels[curSliderIndex]).style.display = "block";
	anim.start();
	
	var anim2 = CSNGAnim.create({
		objectId: sliderPanels[curSliderIndex],
		property: "left",
		speed: 10,
		steps: 35,
		start: -975,
		stop: 0,
		onComplete: function() { isAnim = false; }
	});
	anim2.start();
	
	
	if (curSliderIndex == 0) {
		document.getElementById("left_arrow").className = "left_arrow_empty";
	}
 }

if (typeof(CSNGAnim) == 'undefined') {
/*** Generates quadratic, or "normal" easing in-out tween (two half tweens fused together) where equation for motion is based on a squared variable.* @param t		time* @param b		beginning position* @param c		total change in position* @param d		duration of the tween* @return		position*/function easeInOutQuad(t, b, c, d) {	if ((t /= d/2)<1) {		return c/2*t*t+b;	}	return -c/2*((--t)*(t-2)-1)+b;}

	CSNGAnim = {
		curAnims: Array(),
		
		isIE: (window.navigator.userAgent.indexOf("MSIE") != -1),
		isIE6: (parseFloat(window.navigator.userAgent.substring(window.navigator.userAgent.indexOf("MSIE ") + 5)) <= 6),

		proxy: function(index) {
			if (index != -1) {
				var anim = this.curAnims[index];
				anim.runStep();
			}
		},
		
		create: function(info) { /*objectId, property, start, stop, steps, speed) {*/
			if (info.steps == undefined) {
				info.steps = Math.abs(info.start - info.stop);
			}
			
			if (info.autoDelete == undefined)
				info.autoDelete = true;
				
			if (info.onComplete == undefined)
				info.onComplete = function() { };
			
			var newAnim = {
				proxyIndex: -1,
				curStep: 0,
				numSteps: info.steps,
				startValue: info.start,
				stopValue: info.stop,
				objProp: info.property,
				object: document.getElementById(info.objectId),
				animSpeed: info.speed,
				isRunning: false,
				deleteOnCompletion: info.autoDelete,
				onComplete: info.onComplete,
				
				reset: function() {
					this.curStep = 0;
				},
				start: function() {
					this.isRunning = true;
					setTimeout('CSNGAnim.proxy(' + this.proxyIndex + ')', this.animSpeed);
				},
				stop: function() {
					this.isRunning = false;
				},
				runStep: function() {
					if (this.isRunning) {
						this.curStep++;
						
						var dist = (this.stopValue - this.startValue);
						var value = this.startValue + (dist * (this.curStep / this.numSteps));
						
						value = easeInOutQuad(this.curStep, this.startValue, dist, this.numSteps);
						this.update(value);
						
						if (this.curStep >= this.numSteps) {
							this.isRunning = false;
						}
						
						if (this.isRunning) {
							setTimeout('CSNGAnim.proxy(' + this.proxyIndex + ')', this.animSpeed);
						} else if (this.deleteOnCompletion) {
							CSNGAnim.curAnims[this.proxyIndex] = null;
							this.proxyIndex = -1;
						}
						
						if (!this.isRunning) {
							this.onComplete();
						}
					}
				},
				update: function(value) {
					eval('CSNGAnim.curAnims[' + this.proxyIndex + '].object.style.' + this.objProp + ' = "' + value + 'px"');
				}
			};
			
			this.curAnims.push(newAnim);
			newAnim.proxyIndex = this.curAnims.length - 1;
			return newAnim;
		}
	};
}
