/*
(c) 2006-2008  Carmil 1, Surveylyzer.com, Carmil.net
surveylyzer5_6a45.js
*/

if ( typeof(window.nssy) == 'undefined' ) { window.nssy= new Object (); };

function Surveylyzer5 ()
{
this.idContainer = null;
this.nodeContainer= null;
this.idPleaseWait = "idSyPleaseWaitJs5";
this.idPoll = 0;
this.publisherUser= new Array();
this.refCode= "";
this.style= "";
this.countVisibleItems= 10;
this.urlTarget= "";
this.frameTarget= "";
this.caption= "";
this.lang= "";
this.width= 0;
this.unitWidth= "";
this.height= 0;
this.unitHeight= "";
this.debugParam= "";

this.hostname= "www.surveylyzer.com";
 

this.port= 80;

this.scripts = "/cgi-bin";
 

this.getMsgWait = function ()
{
return "Loading...";
};

this.setContainer = function (id)
{
this.idContainer = id;
};

this.getContainerNode = function ()
{
return this.nodeContainer;
};

this.getUrlPrefix = function ()
{
var schema= (location && location.protocol && ( /^(http|https)[:]/i.test(location.protocol) )) ? location.protocol : "http:";

var prefix= schema + "//" + this.hostname;
if ((!isNaN(this.port)) &&
(((this.port != "80") && (schema == "http:")) || ((this.port != "443") && (schema == "https:"))))
{
prefix= prefix + ":" + this.port;
}
return prefix;
};


this.setReferrerCode = function (refcode)
{
this.refCode= refcode;
};

this.getReferrerCode = function ()
{
return this.refCode;
};

this.setStyle = function (style)
{
this.style = style;
};

this.getStyle = function ()
{
return this.style;
};

this.setHost = function (host)
{
var isOK= /^[a-zA-Z0-9\-]+[.]surveylyzer[.]com$/i.test(host);
if (isOK)
{
this.hostname= host;
if (this.hostname == "local.surveylyzer.com")
{
this.scripts = "/cgi-bin";
}
 
}
else
{
this.trace( "Cannot set host: " + host );
}
};

this.setPort = function (port)
{
this.port= port;
};

this.addPublisherUser = function (user)
{
this.publisherUser.push( user );
};

this.setUrlTarget = function (url)
{
this.urlTarget= url;
};

this.getUrlTarget = function ()
{
return this.urlTarget;
};

this.setCaption = function (caption)
{
this.caption= caption;
};

this.getCaption = function ()
{
return this.caption;
};

this.setLang = function (lang)
{
this.lang= lang;
};

this.getLang = function ()
{
return this.lang;
};

this.setVisibleItems = function (count)
{
this.countVisibleItems= count;
}

this.getVisibleItems = function ()
{
return this.countVisibleItems;
}


this.setWidth = function (size)
{
this.width= size;
this.unitWidth= "px";
};

this.getWidth = function ()
{
var str= "";
if (this.unitWidth != "")
{
str= new Number(this.width).toString() + this.unitWidth;
}
this.trace("Width:" + str);
return str;
};

this.setHeight = function (size)
{
this.height= size;
this.unitHeight= "px";
};

this.getHeight = function ()
{
var str= "";
if (this.unitHeight != "")
{
str= new Number(this.height).toString() + this.unitHeight;
}
this.trace("Height:" + str);
return str;
};

this.setFrameTarget = function (frame)
{
this.frameTarget= frame;
};

this.getFrameTarget = function ()
{
return this.frameTarget;
};

this.getIdPleaseWait = function ()
{
return this.idPleaseWait;
};

this.trace = function (msg)
{
var outmsg= "Surveylyzer5: " + msg + "\n";
if (window.dump) { window.dump(outmsg); }
else if ((window.Debug) && (window.Debug.write)) { window.Debug.write(outmsg); }
};

this.getNodePreferHead = function ()
{
var node= null
var heads = document.getElementsByTagName('head');
if (heads && (heads.length > 0))
{
node= heads[0];
}
else
{
node= document.getElementById(this.idContainer);
}
return node;
}

this.putStylesheet = function (file)
{
var urlcss= this.getUrlPrefix() + file ;
var nodeCSS= document.createElement("LINK");
nodeCSS.setAttribute("href", urlcss );
nodeCSS.setAttribute("type", "text/css");
nodeCSS.setAttribute("rel", "stylesheet");
this.getNodePreferHead().appendChild(nodeCSS);
}

this.go = function ()
{
this.trace("go: " + new Date().toString());

 

this.nodeContainer= document.getElementById(this.idContainer);
while ( this.nodeContainer.hasChildNodes() )
{
this.nodeContainer.removeChild( this.nodeContainer.lastChild );
}

if (this.nodeContainer.className == "")
{
this.nodeContainer.className= "clsSy";
}

this.putStylesheet( this.scripts + "/ap_style.pl?caller=jssy5&style=SyWwDyn&container=" +
encodeURIComponent(this.idContainer) + "&width=" + encodeURIComponent(this.getWidth()) +
"&height=" + encodeURIComponent(this.getHeight()) + "&styleext=" + encodeURIComponent(this.style) +
"&debug=" + encodeURIComponent(this.debugParam) );

 
 

if ((this.debugParam != null) && (this.debugParam != ""))
{
var nodeDivDebug= document.createElement("DIV");
nodeDivDebug.className= this.debugParam;
this.nodeContainer.appendChild(nodeDivDebug);
this.nodeContainer= nodeDivDebug;
}

if ((this.style != null) && (this.style != ""))
{
 
var nodeDivStyled= document.createElement("DIV");
nodeDivStyled.className= this.style;
this.nodeContainer.appendChild(nodeDivStyled);
this.nodeContainer= nodeDivStyled;
}

nssy.surveylyzer5= this;
var url= this.getUrlPrefix() + this.scripts + "/ap_js_sy5.pl?host=" + encodeURIComponent( this.hostname ) +
"&port=" + encodeURIComponent( this.port );
var i= 0;
for ( ; i < this.publisherUser.length; ++i )
{
url= url + "&who=" + encodeURIComponent( this.publisherUser[i] );
}
 

var nodeDivPleaseWait= document.createElement("DIV");
nodeDivPleaseWait.setAttribute("id", this.idPleaseWait);
nodeDivPleaseWait.setAttribute("class", "clsPleaseWait");
nodeDivPleaseWait.appendChild( document.createTextNode(this.getMsgWait()) );
this.nodeContainer.appendChild(nodeDivPleaseWait);

var nodeJS= document.createElement("SCRIPT");
nodeJS.setAttribute("src", url );
nodeJS.setAttribute("type", "text/javascript");
nodeJS.setAttribute("defer", "defer" );
this.getNodePreferHead().appendChild(nodeJS);

return 0;
};
}

if (window.nssy && window.nssy.onLoadScript) { window.nssy.onLoadScript('surveylyzer5_6a45'); }

/* End of file */

