window.reviewcount = 0;
window.whisperscount = 0;


function autoResize(id)
{
	var newheight;
	var newwidth;
	newheight=document.getElementById(id).contentWindow.document.body.scrollHeight;
	document.getElementById(id).style.height= (newheight+300) + "px";
}

function countup(id)
{
	var self=this;
	this.container = document.getElementById(id);
	this.amount = parseInt(container.innerHTML);

	this.counter = 0;
	this.step=1;
	this.microtimer=4000;
	this.maintimer=12000;
	this.animationtimer = 0;
	this.flashcount = 0;
	this.flashmax = 1;

	self.animationtimer = setTimeout(function(){self.count();},1000);

	this.count = function()
		{
			if(self.counter > self.amount)
				{
					self.container.innerHTML = self.amount;
					self.microtimer = 75;
					self.maintimer = 1000;
					self.counter = 0;
					self.animationtimer = setTimeout(function(){self.flash();},25);
				}
			else
				{
					self.counter += self.step;
					self.container.innerHTML = self.counter;
					if(self.microtimer > 25)
						{
							self.microtimer = self.microtimer/2;
						}
					if(self.step < 10)
						{
							self.step++;
						}
					self.animationtimer = setTimeout(function(){self.count();},self.microtimer);
				}
		}

	this.flash = function()
		{
			if(self.counter >= 100)
				{
					if(self.flashcount == self.flashmax)
						{
							self.flashcount = 0;
							self.microtimer = 4000;
							self.maintimer = 12000;
							self.step = 1;
							self.counter = 0;
							self.container.style.color="#000000";
							self.animationtimer = setTimeout(function(){self.count();},self.maintimer);
						}
					else
						{
							self.flashcount++;
							self.counter = 0;
							self.animationtimer = setTimeout(function(){self.flash();},self.maintimer);

						}
				}
			else
				{
					self.container.style.color="#ff3333";
					self.container.style.opacity=(self.counter * .01);
					self.container.style.filter="alpha(opacity="+(self.counter)+")";
					self.counter += 5;
					self.animationtimer = setTimeout(function(){self.flash();},self.microtimer);
				}
		}
}

function resizecalimg(ob)
{
	if(ob.offsetHeight > 644)
		{
			ob.style.top = "-" + ((ob.offsetHeight-644)/2) + "px";
		}
	if(ob.offsetHeight < 644)
		{
			mlo = ob.src;
			ob.style.height = '644px';
			ob.style.width = '';
			ob.src='';
			ob.src=mlo;
		}
	if(ob.offsetWidth > 740)
		{
			ob.style.left = "-" + ((ob.offsetWidth-740)/2) + "px";
		}
}

function imageroller(id,fade,aut,time)
{
	var self=this;
	this.SwitchTimer=0;
	this.AnimationTimer=0;
	this.direction=1;
	this.auto = 0;
	if(aut)
		{
			this.auto = 1;
		}
	var current=0;
	var divs=document.getElementById(id).getElementsByTagName("div");
	var imagearray = new Array();
	var enlargearray = new Array();
	var imgcount = 0;
	var enlargecount = 0;
	var step = 0;
	if(!fade)
		{
			var fadestep = 100;
		}
	else
		{
			var fadestep = 10;
		}
	if(navigator.appName=="Microsoft Internet Explorer")
		{
				var ua = navigator.userAgent;
    				var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    				if (re.exec(ua) != null)
      				rv = parseFloat( RegExp.$1 );
				if(rv < 9)
				{
					fadestep = 100;
				}
		}
	var interval = time;
	var animationinterval = 25;
	for(var i=0;i<divs.length;i++)
		{

			if(divs[i].className == "imgrollerleft")
				{
					divs[i].onclick = function()
						{
							self.CDirection(0);
						}
				}
			if(divs[i].className == "previous")
				{
					divs[i].onclick = function(){self.CDirection(0);}
					divs[i].onmouseout = function(){self.glow(this,0);}
					divs[i].onmouseover = function(){self.glow(this,1);}
				}
			if(divs[i].className == "imgrollerright")
				{
					divs[i].onclick = function()
						{
							self.CDirection(1);
						}
				}
			if(divs[i].className == "next")
				{
					divs[i].onclick = function(){self.CDirection(1);}
					divs[i].onmouseout = function(){self.glow(this,0);}
					divs[i].onmouseover = function(){self.glow(this,1);}
				}
			if(divs[i].className == "play")
				{
					divs[i].onclick = function()
						{
							self.auto = 1;
							self.SwitchImg('auto');
						}
					divs[i].onmouseout = function(){self.glow(this,0);}
					divs[i].onmouseover = function(){self.glow(this,1);}
				}
			if(divs[i].className == "pause")
				{
					divs[i].onclick = function()
						{
							if(self.SwitchTimer)
								{
									clearTimeout(self.SwitchTimer);
									self.SwitchTimer=0;
								}
							if(self.AnimationTimer)
								{
									clearTimeout(self.AnimationTimer);
									self.AnimationTimer=0;
								}
							self.auto = 0;
						}
					divs[i].onmouseout = function(){self.glow(this,0);}
					divs[i].onmouseover = function(){self.glow(this,1);}
				}		
			if(divs[i].className == "imgbox")
				{
					imagearray[imgcount] = divs[i];
					imgcount++;
				}
			if(divs[i].className == "enlargeimg")
				{
					enlargearray[enlargecount] = divs[i];
					enlargecount++;
				}
		}
	


	self.SwitchTimer=setTimeout(function(){self.SwitchImg(0);},25);


	this.glow = function(ob,on)
		{
			if(on)
				{
					ob.style.backgroundPosition='0px -39px';
				}
			else
				{
					ob.style.backgroundPosition='0px -3px';
				}				
		}

	this.CDirection = function(d)
		{
			this.direction = d;
			self.SwitchImg("auto");
		}
	this.SwitchImg = function(x)
		{
			if(self.SwitchTimer)
				{
					clearTimeout(self.SwitchTimer);
					self.SwitchTimer=0;
				}
			if(self.AnimationTimer)
				{
					clearTimeout(self.AnimationTimer);
					self.AnimationTimer=0;
				}
			for(var i=0;i<imagearray.length;i++)
				{
					imagearray[i].style.opacity=0;
					imagearray[i].style.filter="alpha(opacity=0)";
					imagearray[i].style.display="none";
					if(enlargearray[i])
						{
							enlargearray[i].style.display="none";
						}
				}
			if(x=="auto")
				{
					if(this.direction)
						{
							if(current == (imgcount-1))
								{
									current = 0;
								}
							else
								{
									current++;
								}
						}
					else
						{
							if(current == 0)
								{
									current = imgcount-1;
								}
							else
								{
									current=current-1;
								}
						}

					
				}
			else
				{
					if (parseInt(x) < current)
						{
							this.direction = 0;
						}
					else
						{
							this.direction = 1;
						}
					current = x;
				}
			imagearray[current].style.display="block";

			if(fadestep == 100)
				{
					imagearray[current].style.opacity=1;
					imagearray[current].style.filter="alpha(opacity=100)";
					if(this.auto)
						{
							self.SwitchTimer=setTimeout(function(){self.SwitchImg('auto');},interval);
						}
				}
			else
				{
					self.AnimationTimer=setTimeout(function(){self.animate();},animationinterval);
				}
		}
	this.animate = function()
		{
			if(step>100)
				{	
					self.AnimationTimer=0;
					if(this.auto)
						{
							self.SwitchTimer=setTimeout(function(){self.SwitchImg('auto');},interval);
						}
					step=0;
				}
			else
				{
					imagearray[current].style.opacity=(step * .01);
					imagearray[current].style.filter="alpha(opacity="+(step)+")";
					step += fadestep;
					self.AnimationTimer=setTimeout(function(){self.animate();},animationinterval);
				}
		}

}














function sectionfeature(ob,aut,int)
	{
		var self=this;
		this.AnimationTimer=0;
		var animationinterval = (int * 1000);
		var divs = document.getElementById(ob).getElementsByTagName('div');
		var featurearray = new Array();
		var listarray = new Array();
		var featurearraycount = 0;
		var featureindex = 0;
		var listindex = 0;
		var current = 0;
		this.auto = 0;
		if(aut){this.auto = 1}
		for (var i = 0;i<divs.length;i++)
			{
				if(divs[i].className == "sectionlist")
					{
						var max = divs[i].offsetHeight;
						var childdivs = divs[i].getElementsByTagName('div');
						var accumulate = 0;
						var childcount = 0;
						while(childcount < childdivs.length)
							{
								if(childdivs[childcount].className == "sectionitem")
									{
										accumulate += childdivs[childcount].offsetHeight;
										if (accumulate > max)
											{
												childdivs[childcount].style.display = "none";
											}
									}
								childcount++;
							}
					}
			}
		for (var i = 0;i<divs.length;i++)
			{
				if (divs[i].className == "sectionfeature")
					{
						featurearray[featureindex] = divs[i];
						featureindex++;
					}
				if ((divs[i].className == "sectionitem") || (divs[i].className == "smallitem"))
					{
						if(divs[i].style.display != "none")
							{
								listarray[listindex] = divs[i];
								divs[i].index = listindex;
								divs[i].onmouseover = function()
									{
										self.animate(this.index);
									};
								listindex++;
							}
					}
			}
		if(this.auto)
			{
				self.AnimationTimer=setTimeout(function(){self.animate(0);},25);
			}
		this.animate = function(x)
			{
				if(x == 'none')
				{x = current}
				else
				{current = x;}
				if(self.AnimationTimer)
					{
						clearTimeout(this.AnimationTimer);
					}
				self.showfeature(current);
				current++;
				if(current >= listindex)
					{
						current = 0;
					}
				if(self.auto)
					{
						self.AnimationTimer=setTimeout(function(){self.animate('none');},animationinterval);
					}
			}
		this.showfeature = function(x)
			{
				for (var i = 0;i<featurearray.length;i++)
					{
						if (i == x)
							{
								featurearray[i].style.display = "block";	
							}
						else
							{
								featurearray[i].style.display = "none";	
							}
					}
				for (var i = 0;i<listarray.length;i++)
					{
						if (i == x)
							{
								if(listarray[i].className == "sectionitem")
									{
										listarray[i].className = "sectionitemhilite";
									}
								if(listarray[i].className == "smallitem")
									{
										listarray[i].className = "smallitemhilite";
									}
							}
						else
							{
								if(listarray[i].className == "sectionitemhilite")
									{
										listarray[i].className = "sectionitem";
									}
								if(listarray[i].className == "smallitemhilite")
									{
										listarray[i].className = "smallitem";
									}
							}
					}
			}				
	}

function slidedivs()
	{
		var self=this;
		var divs = document.getElementsByTagName('div');
		var imgs = document.getElementsByTagName('img');
		var buttonindex = 0;
		var divindex = 0;
		this.divarray = new Array();
		for(var i = 0;i < divs.length; i++)
			{
				if((divs[i].className == "hicon") || (divs[i].className == "hbutton") || (divs[i].className == "lbutton"))
					{
						divs[i].index=buttonindex;
						if((divs[i].className == "hbutton") || (divs[i].className == "lbutton"))
							{
								divs[i].onmouseover = function()
									{
										this.style.color="#ff0000";
									}
								if(divs[i].className == "hbutton")
									{
										divs[i].onmouseout = function()
											{
												this.style.color="#ffffff";
											}
									}
								if(divs[i].className == "lbutton")
									{
										divs[i].onmouseout = function()
											{
												this.style.color="#000000";
											}
									}
								if(divs[i].className == "hbutton")
									{
										divs[i].onmousedown = function()
											{
												this.style.backgroundPosition="0px -28px";
											}
									}
								divs[i].onmouseup = function()
									{
										this.style.backgroundPosition="0px 0px";
									}
							}
						divs[i].onclick = function()
							{
								if(self.divarray[this.index].style.display == "block")
									{
										self.divarray[this.index].style.display = "none";
									}
								else
									{
										self.show(this.index);
									}
							}
						buttonindex++;
					}
				if(divs[i].className == "hiddenitem" || divs[i].className == "loptions")
					{
						this.divarray[divindex] = divs[i];
						divindex++;
					}
			}
		for(var i = 0;i < imgs.length; i++)
			{
				if(imgs[i].className == "closehidden")
					{
						imgs[i].onclick = function()
							{
								self.hideall();
							}
					}
			}
		this.hideall = function()
			{
				for(var i =0;i< self.divarray.length;i++)
					{
						self.divarray[i].style.display="none";
					}
			}
		this.show = function(x)
			{
				self.hideall();
				self.divarray[x].style.display="block";
			}
	}



function ServerRequest(url, target, rettype)
	{
		var Request= null;
		var TargetObj = document.getElementById(target);
		var RetType = rettype;	
		try{Request=new XMLHttpRequest();}
			catch (e)
				{
				try{Request=new ActiveXObject("Msxml2.XMLHTTP");}
					catch (e)
						{
							Request=new ActiveXObject("Microsoft.XMLHTTP");
						}
  				}
		Request.onreadystatechange = function()
			{
				if (Request.readyState == 4)
					{ 
						if((RetType == 1) || (RetType == 2))
							{
								TargetObj.innerHTML="<span style='display:none'>fill</span>"+Request.responseText;
								var scr=TargetObj.getElementsByTagName("script");
								for(var i=0;i<scr.length;i++){eval(scr[i].text);}
								

							}
						else
							{
								TargetObj.value=Request.responseText;
							}
					}
				else
					{
						if(RetType == 1)
							{
								TargetObj.innerHTML="<img src='/imgs/ajaxloader.gif' alt='loading...' />";
							}
						if(RetType == 0)
							{
								TargetObj.value="waiting...";
							}	
					}
			}
		Request.open("GET",url,true);
		Request.send(null);
	}


function popcircle()
	{
		var self = this;
		this.stepincrement = 5;
		if(navigator.appName=="Microsoft Internet Explorer")
			{
				var ua = navigator.userAgent;
    				var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    				if (re.exec(ua) != null)
      				rv = parseFloat( RegExp.$1 );
				if(rv < 9)
					{
						this.stepincrement = 50;
					}
			}
		this.divs = new Array();
		animationdivs = new Array();
		this.animationtimer = 0;
		this.evaporatetimer = 0;
		var anch = document.getElementsByTagName("a");
		var divs = document.getElementsByTagName("div");
		var controlindex = 0;
		var animationindex = 0;
		for (var i = 0; i < anch.length; i++)
			{
				if(anch[i].className == "menulink")
					{
						anch[i].index = controlindex;
						anch[i].onmouseover = function ()
							{
								if(self.animationtimer){clearTimeout(self.animationtimer);}
								self.evaporate();
								self.expand(this.index);
							}
						controlindex++;
					}
			}
		for (var i = 0; i < divs.length; i++)
			{
				if(divs[i].className == "popcontainer")
					{
						divs[i].onmouseover = function ()
							{
								self.evaporate();
							}
					}
				if(divs[i].className == "popdiv")
					{
						animationdivs[animationindex] = divs[i];
						animationindex++;
					}
			}
		this.expand = function(x)
			{
				if(!this.step){this.step=0;}
				animationdivs[x].parentNode.style.display = "block";
				if(this.step < 50 && animationdivs[x])
					{
						this.step += self.stepincrement;
						animationdivs[x].style.top = (50-this.step) + "px";
						animationdivs[x].style.left = (50-this.step) + "px";
						animationdivs[x].style.width = (this.step * 2) + "px";
						animationdivs[x].style.height = (this.step * 2) + "px";
						self.animationtimer = setTimeout(function(){self.expand(x);},25);
					}
				else
					{
						var subdiv = animationdivs[x].getElementsByTagName("div");
						subdiv[0].style.display = "block";
						subdiv[0].style.top = (Math.round((subdiv[0].offsetParent.offsetHeight - subdiv[0].offsetHeight)/2))+"px";
						this.step = 0;
						self.animationtimer = 0;
						self.evaporatetimer = setTimeout(function(){self.evaporate();},2000);
					}
			}
		this.evaporate = function()
			{
				if(self.evaporatetimer){clearTimeout(self.evaporatetimer);}
				for(var i = 0; i < animationdivs.length; i++)
					{
						var subdiv = animationdivs[i].getElementsByTagName("div");
						subdiv[0].style.display = "none";
						animationdivs[i].style.top = "50px";
						animationdivs[i].style.left = "50px";
						animationdivs[i].style.width = "0px";
						animationdivs[i].style.height = "0px";
						animationdivs[i].parentNode.style.display = "none";
					}
			}
	}

function newslettersubmit()
	{
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var email = document.getElementById('newsletteremail');
		var name = document.getElementById('newslettername').value;
   		var address = email.value;
		if(address == ""){email.focus();return;}
   		if(reg.test(address) == false)
			{
				email.value = "Invalid email address";
				email.focus();
			}
		else
			{
				waitvalue = "<div style='width:100%;text-align:center'><img src='/imgs/ajaxtransmit.gif' /></div>";
				document.getElementById('newslettersubmit').innerHTML = waitvalue;
				send = "/newsletter/nlsubmit.php?email="+email.value+"&name="+name;
				new ServerRequest(send, 'newsletter',2);
			}
	}

function comment()
	{
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var email = document.getElementById('cemail');
		var name = document.getElementById('cname');
		var txt = document.getElementById('ctext');
   		var address = email.value;
		if(address == ""){alert('Please input your email');email.focus();return;}
		if(name.value == ""){alert('Please input your name');name.focus();return;}
		if(txt.value == ""){alert('Please input your comment');txt.focus();return;}
   		if(reg.test(address) == false)
			{
				email.value = "Invalid email address";
				email.focus();
			}
		else		
			{
				document.getElementById('commentform').submit();
				//waitvalue = "<div style='width:100%;text-align:center'>";
				//waitvalue += "<span style='font-weight:bold'>Transmitting Comment</span><br />";
				//waitvalue += "<img src='/imgs/ajaxtransmit.gif' /></div>";
				//document.getElementById('commentwrapper').innerHTML = waitvalue;
				document.getElementById('commentwrapper').style.display = 'none';
				document.getElementById('commenttransmit').style.display= 'block';
			}
	}

function modal(x)
	{
		if(x)
			{
				document.getElementById('modal').style.display = "block";
				document.getElementById('dimmer').style.display = "block";
			}
		else
			{
				document.getElementById('modalcontent').innerHTML = "";
				document.getElementById('modal').style.display = "none";
				document.getElementById('dimmer').style.display = "none";
			}
	}

function broller()
{
	var self = this;
	this.AnimationTimer = 0;
	this.MainAnimationTimer =0;
	var divs = document.getElementById('bar').getElementsByTagName('div');
	this.bitems = new Array();
	this.bindex = 0;
	var startx = -34;
	this.step = 34;
	this.direction = 0;
	this.primarytimeout = 4800;
	this.maintimeout=this.primarytimeout;
	if(navigator.appName=="Microsoft Internet Explorer")
			{
				var ua = navigator.userAgent;
    				var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    				if (re.exec(ua) != null)
      				rv = parseFloat( RegExp.$1 );
				if(rv < 9)
					{
						this.ieadapt = 1;
					}
				else
					{
						this.ieadapt = 0;
					}
			}
	for(var i =0;i<divs.length;i++)
		{
			if(divs[i].className == "barup")
				{
					
					divs[i].onclick = function()
						{
							self.maintimeout = 25;
							self.direction = 0;
							clearTimeout(self.MainAnimationTimer);
							self.Main();		
						}
					divs[i].onmousedown = function()
						{
							this.style.backgroundPosition = "0px -28px";
						}
					divs[i].onmouseup = function()
						{
							this.style.backgroundPosition = "0px 0px";
						}
				}
			if(divs[i].className == "bardown")
				{
					divs[i].onclick = function()
						{
							self.maintimeout = 25;
							self.direction = 1;
							clearTimeout(self.MainAnimationTimer);
							self.Main();
						}
					divs[i].onmousedown = function()
						{
							this.style.backgroundPosition = "0px -28px";
						}
					divs[i].onmouseup = function()
						{
							this.style.backgroundPosition = "0px 0px";
						}
				}
			if(divs[i].className == "baritemcontainer")
				{
					var idivs = divs[i].getElementsByTagName('div');
					for(var ii = 0;ii<idivs.length;ii++)
						{
							if(idivs[ii].className == "baritem")
								{
									this.bitems[this.bindex] = idivs[ii];
									this.bitems[this.bindex].style.top = startx + "px";
									self.bindex++;
									startx+=34;
								}
						}
				}
		}
	this.FLOOR = (parseInt(this.bitems[this.bindex-1].offsetTop))+34;
	if(this.bitems.length > 1)
		{
			self.MainAnimationTimer = setTimeout(function(){self.Main();},50);
		}

	this.Main = function()
		{
			if(!self.AnimationTimer)
					{
						if(self.direction){self.step=0;}else{self.step=34;}
						self.MainAnimationTimer = setTimeout(function(){self.Switch(self.direction);},self.maintimeout);
					}
			self.maintimeout=self.primarytimeout;
		}

	this.Switch = function(x)
		{
			if(x)
				{
					if(self.step > 34)
						{
							for(var i =0;i<self.bitems.length;i++)
								{
									c = parseInt(self.bitems[i].offsetTop);
									if( (parseInt(self.bitems[i].offsetTop)) >= self.FLOOR )
										{
											self.bitems[i].style.top = "-34px";
										}
								}
							clearTimeout(self.AnimationTimer);
							self.AnimationTimer=0;
							self.Main();
						}
					else
						{
							for(var i =0;i<self.bitems.length;i++)
								{
									c = parseInt(self.bitems[i].offsetTop);
									if(self.ieadapt)
										{
											self.step=34;
											self.bitems[i].style.top = (c + 34)+"px";
										}
									else
										{
											self.bitems[i].style.top = (c + 2)+"px";
										}
								}
							self.step += 2;
							self.AnimationTimer = setTimeout(function(){self.Switch(1);},50);
						}
				}
			else
				{
					if(self.step == 0)
						{
							for(var i =0;i<self.bitems.length;i++)
								{
									c = parseInt(self.bitems[i].offsetTop);
									if( (parseInt(self.bitems[i].offsetTop)) < -34 )
										{
											self.bitems[i].style.top = (self.FLOOR-34)+"px";
										}
								}
							clearTimeout(self.AnimationTimer);
							self.AnimationTimer=0;
							self.Main();
						}
					else
						{
							
							for(var i =0;i<self.bitems.length;i++)
								{
									c = parseInt(self.bitems[i].offsetTop);
									if(self.ieadapt)
										{
											self.step=2;
											self.bitems[i].style.top = (c - 34)+"px";
										}
									else
										{
											self.bitems[i].style.top = (c - 2)+"px";
										}
								}
							self.step -= 2;
							self.AnimationTimer = setTimeout(function(){self.Switch(0);},50);
						}
				}
		}
}

