﻿// JScript File
p_ssCount = 0;
p_defRotTimeout = 7000;
function clickNewWin(a,name,w,h){
	try{
		window.frames(name).focus();//exhibitorInfo.focus();
	}catch(e){
		//alert(event.srcElement.href);
		var wT = '', hT = '';
		if(w)
			wT = ',width=' + w;
		if(h)
			hT = ',height=' + h;
		var str = new String('status=yes'+wT+hT+',toolbar=no,menubar=no,location=no');

		var a = window.open(a.href, name ,str);
		a.focus();
		return false;
	}
}
function createSlideShow(id,period,mode){
	var c = p_ssCount;
	var p = period || p_defRotTimeout;
	p_ssCount++;
	var req = envGetXMLHTTP();
	if ( req != null )
	{
		
		var areaID = 'ssShow_'+id+'_'+c+'_a';
		document.write('<a id="'+areaID+'" href="" style="visibility:hidden;"><img alt="" src=""></a>');
		req.open('POST','/srvs/ss.asp',true);
		req.setRequestHeader("Content-Type", "text/xml");
		req.onreadystatechange = function(){ if( req.readyState == 4 ){if( req.status >= 200 && req.status < 300 || req.status == 304 ) initRotator(req,areaID,p)}};
		req.send('<get id="'+id+'"/>');
	}
	
}
function initRotator(req,id,period){
	//alert( req.responseXML.xml );
	if( req.responseXML.documentElement.tagName == 'list' )
	{
		var items = req.responseXML.documentElement.childNodes;
		var adList = new Array();
		for( var c = 0, l = items.length; c < l; c++ )
		{
			var cNode = items.item(c);
			if( cNode.nodeName == 'item' && cNode.nodeType == 1 && cNode.getAttribute('id') != null )
			{
				var ccc = [];
				ccc['src'] = cNode.getAttribute('img');
				ccc['alt'] = cNode.getAttribute('name');
				var tHrf = String(cNode.getAttribute('link'));
				ccc['href'] = tHrf;
				if( tHrf.indexOf('http://') != -1 )
					ccc['target'] = '_blank';
				else
					ccc['target'] = null;
				adList.push(ccc);
			}
		}
		if(adList.length > 0)
		{
			
			document.getElementById(id).style.visibility="visible";
			updateRotator(id,adList,0,period)
		}

	}
}
function updateRotator(id,adList,c,period){

	if(adList.length > 0)
	{
	
		var cPos
		if(c != null && c > 0 && adList.length > c)
			cPos = c;
		else
			cPos = 0;

		var cRef = document.getElementById(id);
		cRef.setAttribute("href",adList[cPos]['href']);
		if( adList[cPos]['target'] != null)
			cRef.setAttribute("target",adList[cPos]['target']);
		else
			cRef.removeAttribute("target");
		cRef = cRef.firstChild;
		cRef.setAttribute("src",adList[cPos]['src']);
		cRef.setAttribute("alt",adList[cPos]['alt']);

		if(adList.length > 1)
			window.setTimeout(function(){updateRotator(id,adList,cPos + 1,period);}, period);
			
	}

}
function envGetXMLHTTP(){
    var httpRequest;

    if (window.XMLHttpRequest) {
        httpRequest = new XMLHttpRequest();
        if (httpRequest.overrideMimeType) {
            httpRequest.overrideMimeType('text/xml');
        }
    } 
    else if (window.ActiveXObject) { // IE
        try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
            } 
            catch (e) {
                       try {
                            httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                           } 
                         catch (e) {}
                      }
    }
    if (!httpRequest) {
        return null;
    }
    else
		return httpRequest;
}

