var xmlHttp;

function createXMLHttpRequest()
{
	if(window.ActiveXObject)
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");	
	}
	else if (window.XMLHttpRequest)
	{
		xmlHttp = new XMLHttpRequest();	
	}
}
function requestInfo (info_id, cat)
{
	createXMLHttpRequest();
	
	var queryString = "../app/shared/php/getInfo.php?info_id=" + info_id + "&cat=" + cat;
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.open("GET", queryString, true);
	xmlHttp.send(null);
}
function handleStateChange()
{
	if(xmlHttp.readyState == 4)
	{
		if(xmlHttp.status == 200)
		{
			parseResults();	
		}
	}
}
function parseResults()
{
	var responseDiv = document.getElementById("feature_info");
	
	var responseText = document.createTextNode(xmlHttp.responseText);
	document.getElementById("feature_info").innerHTML = xmlHttp.responseText;
}




function writeiframe (url, name)
{
	if(!name)
	{
		name = "content";	
	}
	document.write('<iframe height="100%" width="100%" scrolling="no" allowtransparency="true" frameborder="0" name="' + name + '" id="' + name + '" style="height:100%; width:100%;" src="'+ url +'"></iframe>');	
}

function displaypng (url, height, width, styleid, classid)
{
	var bname = navigator.appName;
						
	if (bname.search(/netscape/i) == 0)
	{
		document.write('<img src="' + url + '" alt="" border="0" style="height:'+ height +'px; width:'+ width +'px;"');
		if(styleid)
		{
			document.write(' id="' + styleid + '" ');
		}
		if(classid)
		{
			document.write(' class="' + classid + '" ');
		}
		document.write('/>');
	}
	else if (bname.search(/microsoft/i) == 0)
	{
		document.write('<img src="../images/blank.gif" border="0" alt="" style="width: ' + width + 'px; height:' + height + 'px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(');
		document.write("src='" + url + "', sizingMethod='scale');");
		document.write('"');
		if(styleid)
		{
			document.write(' id="' + styleid + '" ');
		}
		if(classid)
		{
			document.write(' class="' + classid + '" ');
		}
		document.write('/>');
		
		
	}
	else
	{
		document.write('<img src="' + url + '" alt="" border="0" style="height:'+ height +'px; width:'+ width +'px;"');
		if(styleid)
		{
			document.write(' id="' + styleid + '" ');
		}
		if(classid)
		{
			document.write(' class="' + classid + '" ');
		}
		document.write('/>');
	}	
}

function checkFlashBrowser (url, height, width, wmode, color, flashvars)
{

	var bname = navigator.appName;
				
				
	if (bname.search(/netscape/i) == 0)
	{
		
		document.write('<object type="application/x-shockwave-flash" data="' + url + '.swf' + '" width="' + width +'" height="' + height +'">');
		document.write('<param name="movie" value="' + url + '.swf' + '" />');
		document.write('<param name="wmode" value="'+wmode+'" />');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="flashVars" value="'+flashvars+'" />');
		document.write('<param name="quality" value="high" />');
		document.write('</object>');
	}
	   
	   
	else if (bname.search(/microsoft/i) == 0)
	   {
		   
		   if (AC_FL_RunContent == 0) {
				alert("There is an error with the ActiveX control. Please contact admin@eleven2.com to let them know about the error. Thank you.");
			} else {
				AC_FL_RunContent(
					'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
					'width', width,
					'height', height,
					'src', url,
					'quality', 'high',
					'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
					'align', 'middle',
					'play', 'true',
					'loop', 'true',
					'scale', 'noscale',
					'wmode', wmode,
					'devicefont', 'false',
					'id', 'index',
					'bgcolor', '#'+ color,
					'name', 'index',
					'menu', 'true',
					'allowScriptAccess','sameDomain',
					'movie', url,
					'salign', 'tl',
					'flashVars', flashvars
					); //end AC code
			}
	   }
	else
	   {
			document.write('<object type="application/x-shockwave-flash" data="' + url + '.swf' + '" width="' + width +'" height="' + height +'">');
		document.write('<param name="movie" value="' + url + '.swf' + '" />');
			document.write('<param name="wmode" value="'+wmode+'" />');
			document.write('<param name="allowScriptAccess" value="sameDomain" />');
			document.write('<param name="quality" value="high" />');
			document.write('<param name="flashVars" value="'+flashvars+'" />');
			document.write('</object>');
	   }
}


function popupInTheMiddle(url,name,w,h,tl,lo,st,me,sc,res){
	var osName = navigator.appVersion;
	var browser = navigator.appName;
	var sw = screen.width;
	var sh = screen.height;
	x = (sw-w)/2;
	y = (sh-h)/2-50;
	var newwin = window.open(url,name,'width='+w+',height='+h+',left='+x+',top='+y+',toolbar='+tl+',location='+lo+',status='+st+',menubar='+me+',scrollbars='+sc+',resizable='+res+'')
	newwin.focus();
}

function pageScrollToTop(){
	var speed1 = 2;
	var speed2 = 5;
	var sec = 20;
	var y;
	var cy;
	var gy = 0;
	var scrollEngine;
	if(document.all){
		cy = document.body.scrollTop;
	}else if(document.layers || document.getElementById){
		cy = pageYOffset;
	}
	y = cy-gy;
	if(Math.abs(y)>50){
		cy = Math.round(cy-(y/speed1));
		window.scroll(0,cy);
		scrollEngine = setTimeout("pageScrollToTop()",sec);	
	}else if(Math.abs(y)>2){
		cy = Math.round(cy-(y/speed2));
		window.scroll(0,cy);
		scrollEngine = setTimeout("pageScrollToTop()",sec);	
	}else{
		window.scroll(0,0);
		clearTimeout(scrollEngine);
	}
}

function pageScrollToPoint(goaly){
	var speed1 = 2;
	var speed2 = 5;
	var sec = 20;
	var y;
	var cy;
	var gy = goaly;
	var path;
	var scrollEngine;
	if(document.all){
		cy = document.body.scrollTop;
	}else if(document.layers || document.getElementById){
		cy = pageYOffset;
	}
	y = cy-gy;
	if(Math.abs(y)>50){
		cy = Math.round(cy-(y/speed1));
		window.scroll(0,cy);
		path="pageScrollToPoint("+gy+")"
		scrollEngine = setTimeout(path,sec);	
	}else if(Math.abs(y)>2){
		cy = Math.round(cy-(y/speed2));
		window.scroll(0,cy);
		path="pageScrollToPoint("+gy+")"
		scrollEngine = setTimeout(path,sec);
	}else{
		window.scroll(0,gy);
		clearTimeout(scrollEngine);
	}
}
function getScreenHeight () {
	return window.height;
}
function externalLinks() { 
	if (!document.getElementsByTagName) return; 
		var anchors = document.getElementsByTagName("a"); 
		for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && 
			anchor.getAttribute("rel") == "external") 
			anchor.target = "_blank"; 
	} 
} 
window.onload = externalLinks;
