var __snShow = 'http://show.newzshop.sn00.net';
var __snImg = 'http://img.sn00.net';
pageSN = Number(readCookie('snewsPage'));
if (pageSN >= 5 ) pageSN = 0;
setCookie('snewsPage',pageSN+1);

document.write('\
<style>\
.snNews1790 {\
	margin: 0px;\
	padding-left:0px; \
}\
.snTitle1790 {\
	margin-right:3px;\
                     margin-left:0px;\
       text-align: center;\
}\
.snImg1790 {\
/*float:left;*/\
margin-left:0px;\
text-align:center;\
display:none;\
}\
a.snLink1790 {\
	color:#CC3333;\
}\
a.snLink1790:hover {\
	color:#CC3333;\
}\
a.snLink1790 {\
	text-decoration:none;\
}\
a.snLink1790:hover {\
	text-decoration:underline;\
}\
.snBorder1790 {\
	border-color:#FFFFFF;\
}\
.snBorder1790 {\
	border-style:solid;\
}\
.snBorder1790 {\
	border-width:0px;\
}\
.snBody1790 {\
	font-family:Tahoma, Arial, serif;\
}\
.snBody1790 {\
	font-size:11px;\
}\
.snBody1790 {\
	font-weight:bold;\
}\
\
</style>\
\
<div class="snBody1790" id="snInformer1790" style="display:none; width:100%;overflow:hidden;height:100%">\
<table cellpadding="0" cellspacing="3"  width="100%">\
\
	<tr class="snNews1790">\
        <td align="center" valign="top"  class="snNews1790 snBorder1790 snBgColor21790" style="padding-top:3px; padding-bottom:3px;">\
\
            <a class="snLink1790" href="" target="_blank" id="sn_link_1790_0">\
                <img class="snImg1790" src="http://img.sn00.net/1x1.gif" id="sn_img_1790_0" border="0">\
            </a>\
            <div> \
              <a class="snLink1790" href="" target="_blank" id="sn_link2_1790_0">\
                <span class="snTitle1790" id="sn_title_1790_0"> </span>\
              </a>\
            </div>\
        </td>\
    </tr>\
\
	<tr class="snNews1790">\
        <td align="center" valign="top"  class="snNews1790 snBorder1790 snBgColor21790" style="padding-top:3px; padding-bottom:3px;">\
\
            <a class="snLink1790" href="" target="_blank" id="sn_link_1790_1">\
                <img class="snImg1790" src="http://img.sn00.net/1x1.gif" id="sn_img_1790_1" border="0">\
            </a>\
            <div> \
              <a class="snLink1790" href="" target="_blank" id="sn_link2_1790_1">\
                <span class="snTitle1790" id="sn_title_1790_1"> </span>\
              </a>\
            </div>\
        </td>\
    </tr>\
\
	<tr class="snNews1790">\
        <td align="center" valign="top"  class="snNews1790 snBorder1790 snBgColor21790" style="padding-top:3px; padding-bottom:3px;">\
\
            <a class="snLink1790" href="" target="_blank" id="sn_link_1790_2">\
                <img class="snImg1790" src="http://img.sn00.net/1x1.gif" id="sn_img_1790_2" border="0">\
            </a>\
            <div> \
              <a class="snLink1790" href="" target="_blank" id="sn_link2_1790_2">\
                <span class="snTitle1790" id="sn_title_1790_2"> </span>\
              </a>\
            </div>\
        </td>\
    </tr>\
\
	<tr class="snNews1790">\
        <td align="center" valign="top"  class="snNews1790 snBorder1790 snBgColor21790" style="padding-top:3px; padding-bottom:3px;">\
\
            <a class="snLink1790" href="" target="_blank" id="sn_link_1790_3">\
                <img class="snImg1790" src="http://img.sn00.net/1x1.gif" id="sn_img_1790_3" border="0">\
            </a>\
            <div> \
              <a class="snLink1790" href="" target="_blank" id="sn_link2_1790_3">\
                <span class="snTitle1790" id="sn_title_1790_3"> </span>\
              </a>\
            </div>\
        </td>\
    </tr>\
\
</table>\
</div>\
<div id="ubl1790" class="disp-no"></div>\
');
document.write('<sc'+'ript type="text/javascript" src="http://show.newzshop.sn00.net/a/1790/' + (pageSN + 1) + '.js"></scr'+'ipt>');

/**
 * Create a new Document object. If no arguments are specified,
 * the document will be empty. If a root tag is specified, the document
 * will contain that single root tag. If the root tag has a namespace
 * prefix, the second argument must specify the URL that identifies the
 *namespace.
 */
function XMLnewDocument(rootTagName, namespaceURL) {
    if (!rootTagName) rootTagName = "";
    if (!namespaceURL) namespaceURL = "";

    if (document.implementation && document.implementation.createDocument) {
        // This is the W3C standard way to do it
        return document.implementation.createDocument(namespaceURL, 
                       rootTagName, null);
    }
    else { // This is the IE way to do it
        // Create an empty document as an ActiveX object
        // If there is no root element, this is all we have to do
        var doc = new ActiveXObject("MSXML2.DOMDocument");

        // If there is a root tag, initialize the document
        if (rootTagName) {
            // Look for a namespace prefix
            var prefix = "";
            var tagname = rootTagName;
            var p = rootTagName.indexOf(':');
            if (p != -1) {
                prefix = rootTagName.substring(0, p);
                tagname = rootTagName.substring(p+1);
            }

            // If we have a namespace, we must have a namespace prefix
            // If we don't have a namespace, we discard any prefix
            if (namespaceURL) {
                if (!prefix) prefix = "a0"; // What Firefox uses
            }
            else prefix = "";

            // Create the root element (with optional namespace) as a
            // string of text
            var text = "<" + (prefix?(prefix+":"):"") + tagname +
                (namespaceURL
                 ?(" xmlns:" + prefix + '="' + namespaceURL +'"')
                 :"") +
                "/>";
            // And parse that text into the empty document
            doc.loadXML(text);
        }
        return doc;
    }
};

/**
 * Synchronously load the XML document at the specified URL and
 * return it as a Document object
 */
function XMLload(url) {
    // Create a new document with the previously defined function
    var xmldoc = XMLnewDocument();
    xmldoc.async = false;  // We want to load synchronously
    xmldoc.load(url);      // Load and parse
    return xmldoc;         // Return the document
}; 


/**
 * Asynchronously load and parse an XML document from the specified URL.
 * When the document is ready, pass it to the specified callback function.
 * This function returns immediately with no return value.
 */
function XMLloadAsync(url, callback) {
    var xmldoc = XMLnewDocument();

    // If we created the XML document using createDocument, use
    // onload to determine when it is loaded
    if (document.implementation && document.implementation.createDocument) {
        xmldoc.onload = function() { callback(xmldoc); };
    }
    // Otherwise, use onreadystatechange as with XMLHttpRequest
    else {
        xmldoc.onreadystatechange = function() {
            if (xmldoc.readyState == 4) callback(xmldoc);
        };
    }

    // Now go start the download and parsing
    xmldoc.load(url);
}; 

/**
 * Parse the XML document contained in the string argument and return
 * a Document object that represents it.
 */
/*XML.parse = function(text) {*/
function XMLparse(text) {
    if (typeof DOMParser != "undefined") {
        // Mozilla, Firefox, and related browsers
        return (new DOMParser()).parseFromString(text, "application/xml");
    }
    else if (typeof ActiveXObject != "undefined") {
        // Internet Explorer.
        var doc = XMLnewDocument( );   // Create an empty document
        doc.loadXML(text);              //  Parse text into it
        return doc;                     // Return it
    }
    else {
        // As a last resort, try loading the document from a data: URL
        // This is supposed to work in Safari. Thanks to Manos Batsis and
        // his Sarissa library (sarissa.sourceforge.net) for this technique.
        var url = "data:text/xml;charset=utf-8," + encodeURIComponent(text);
        var request = new XMLHttpRequest();
        request.open("GET", url, false);
        request.send(null);
        return request.responseXML;
    }
};



function readCookie(name) {
	var b=/^\s*(\S+)\s*=\s*(\S*)\s*$/,
	c=document.cookie.split(';');
	for(var i=0;i<c.length;i++)
	  if(b.exec(c[i]) && RegExp.$1==name) return unescape(RegExp.$2);
	return null;
}

function setCookie(szName, szValue, szExpires, szPath, szDomain, bSecure)
{
        var szCookieText =         escape(szName) + '=' + escape(szValue);
        szCookieText +=            (szExpires ? '; EXPIRES=' + szExpires.toGMTString() : '');
        szCookieText +=            (szPath ? '; PATH=' + escape(szPath) : '');
        szCookieText +=            (szDomain ? '; DOMAIN=' + szDomain : '');
        szCookieText +=            (bSecure ? '; SECURE' : '');

        document.cookie = szCookieText;
}

function getXmlHttp(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function loadNews(snInfNum){
    if(typeof snLocalNews == 'undefined') snLocalNews = false;
    if(snLocalNews) return;
    var js = document.createElement('SCRIPT');
    js.src = __snShow+'/a/'+iid+'/' + (snInfArr[snInfNum]['ads_currentNews'] + 1) + '.js';
    js.type = "text/javascript";
    var hh = document.getElementsByTagName('head')[0];
    hh.appendChild(js);
    //__id('ubl'+iid).appendChild(js)
}
function __id(sI){
    return document.all ? document.all[sI] : document.getElementById(sI);
}
__Images =
{
  count: [] /* keep track of the number of images */
  ,loaded: [] /* keeps track of how many images have loaded */
  ,onComplete: function(iid){
    var oInformer = __id('snInformer'+iid);
    if(oInformer) oInformer.style.display = 'block';
  } /* fires when all images have finished loadng */
  ,onLoaded: function(){} /*fires when an image finishes loading*/
  ,loaded_image: "" /*access what has just been loaded*/
  ,images: [] /*keeps an array of images that are loaded*/
  ,incoming:[] /*this is for the process queue.*/
  /* this will pass the list of images to the loader*/
  ,reset: function(iid)
  {
    //make sure to reset the counters
    this.loaded[iid] = 0;
    this.count[iid] = 0;

    //reset the images array 
    this.images[iid] = [];
    //reset queue array also
    this.incoming[iid] = [];
  }
  ,add: function(image,iid)
  {
    if(!image) return;
    //increment the number of images
    this.count[iid]++;

    //store the image name
    this.incoming[iid].push(image);

    //start processing the images one by one
    this.process(iid);

  }
  ,process: function(iid)
  {
    //pull the next image off the top and load it
    this.load(this.incoming[iid].shift(),iid);
  }
  /* this will load the images through the browser */
  ,load: function(image,iid)
  {
    if(!image) return
    var this_ref = this;
    var i = new Image;

    i.onload = function()
    {
      //store the loaded image so we can access the new info
      this_ref.loaded_image = i;

      //push images onto the stack
      this_ref.images[iid].push(i);

      //note that the image loaded
      this_ref.loaded[iid] +=1;

      //fire the onloaded
      (this_ref.onLoaded)();

      //if all images have been loaded launch the call back
      if(this_ref.count[iid] == this_ref.loaded[iid])
      {
        (this_ref.onComplete)(iid);
      }
      //load the next image
      else
      {
        this_ref.process(iid);
      }
    }
    i.src = image;
  }
  ,done:function(iid){
    return (this.count[iid] == this.loaded[iid])
  }
}
function fillNews(iid, xmlDoc){
	var oldframe = __id('snf'+iid);
	if(oldframe) oldframe.style.display = 'none';
	var xmlDoc = XMLparse(xmlDoc);
	var snInfNum = 0;
	for (snInfNum in snInfArr) {
		if (snInfArr[snInfNum]['iid'] == iid) break;
	}
	snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']] = [];
        __Images.reset(iid);
	for(var i = 0 ; i < snInfArr[snInfNum]['mn'] ; i++){
		var descr = '';
		if (xmlDoc.getElementsByTagName('guid')[i] == undefined) continue;
		if (xmlDoc.getElementsByTagName('description').length != 0){
			if (xmlDoc.getElementsByTagName('description')[i].firstChild != null) {
				descr = xmlDoc.getElementsByTagName('description')[i].firstChild.nodeValue;
			}
		}
                var image = __snImg+"/1x1.gif";
                if(snInfArr[snInfNum]['show_image']) {
                    image = xmlDoc.getElementsByTagName('image')[i].firstChild.nodeValue;
                    if(image.length < 6){
                            while (image.length < 6) {
                                    image = "0"+image;
                            }
                    }
                    var d1 = image.slice(0, image.length - 4),
                    d2 = image.slice(image.length - 4, image.length - 2),
                    img_suffix = "sized",
                    img_size = snInfArr[snInfNum]['img_size'];
                    if (img_size !== undefined){
                            if (img_size != '80')
                            {
                                    img_suffix = img_size;
                            }
                    }else if(snInfArr[snInfNum]['img_suffix']){
                            img_suffix = snInfArr[snInfNum]['img_suffix'];
                    }
                    image = __snImg+"/"+d1+"/"+d2+"/"+image+"_"+img_suffix+".jpg";
                }
                __Images.add(image,iid);
		snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i]= [
			xmlDoc.getElementsByTagName('guid')[i].firstChild.nodeValue,
			xmlDoc.getElementsByTagName('title')[i].firstChild.nodeValue,
			xmlDoc.getElementsByTagName('link')[i].firstChild.nodeValue,
			descr,
			image,
			xmlDoc.getElementsByTagName('partnerId')[i].firstChild.nodeValue,
			xmlDoc.getElementsByTagName('directLink')[i].firstChild.nodeValue,
			xmlDoc.getElementsByTagName('partnerName')[i].firstChild.nodeValue
                        ];
	}
	ads_loadNews(iid);
}

function ads_loadNews(iid){
	var snInfNum = 0;
	for (snInfNum in snInfArr) {
		if (snInfArr[snInfNum]['iid'] == iid) break;
	}
        var oInformer = __id('snInformer'+iid);
        if(oInformer) oInformer.style.display = 'none';
	if (snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']]==undefined){
		loadNews(snInfNum);
		return;
	} else if(!snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']].length) {
                return;
        }
	for (var i = 0; i < snInfArr[snInfNum]['mn']; i++) {
		var sn_link = __id("sn_link_"+iid+"_"+i),
		    sn_link2 = __id("sn_link2_"+iid+"_"+i),
		    sn_link3 = __id("sn_link3_"+iid+"_"+i),
		    sn_partner = __id("sn_partner_"+iid+"_"+i),
		    sn_descr = __id("sn_desc_"+iid+"_"+i),
		    sn_img = __id("sn_img_"+iid+"_"+i),
		    sn_title = __id("sn_title_"+iid+"_"+i);

		if(snInfArr[snInfNum]['filled']) {
		// Очистка
		  if(sn_title) {
		    sn_title.innerHTML = "";
		    sn_title.style.display = "none";
		}
		  if (sn_partner){
			  sn_partner.firstChild.nodeValue = "";
			  sn_partner.style.display = "none";
		  }
		sn_link.href = "";
		if(sn_link2) sn_link2.href = "";
		if(sn_link3) sn_link3.href = "";
		  if (snInfArr[snInfNum]['show_descr'] && sn_descr) {
			  sn_descr.firstChild.nodeValue = "";
		}
                if (sn_img) {
                        sn_img.style.display = 'none';
                        sn_img.src = __snImg+"/1x1.gif";
                        sn_img.alt = "";
                        sn_img.title = "";
                }
		}
		// Заполнение
		if (snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i]==undefined) continue;
		var snTitle = snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i][1];
		if(snTitle.length > snInfArr[snInfNum]['mts']){
			snTitle = snTitle.slice(0,snInfArr[snInfNum]['mts']-3)+"...";
		}
		var descr = snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i][3];
		if(descr.length > snInfArr[snInfNum]['mds']){
			descr = descr.slice(0,snInfArr[snInfNum]['mds']-3)+"...";
		}
		var snLink = 'http://'+snInfArr[snInfNum]['shh']+'/link.php?'+ //link/?
			'pid='+snInfArr[snInfNum]['pid']+'&iid='+iid+'&d='+snInfArr[snInfNum]['directlink']+
			'&nid='+snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i][0]+
			'&npid='+snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i][5]+
			'&pd='+snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i][6]+
			'&url='+escape(snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i][2])+
			'&r='+escape(document.location.href);
		snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i]['reallink'] = snLink;
		//snLink = snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i][2];
		snLink = snLink + '&f=1';
		if(sn_title) {
		  sn_title.innerHTML = snTitle;
		  sn_title.style.display = "inline";
		}
		if (sn_partner){
			var name = snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i][7];
			sn_partner.firstChild.nodeValue = name;
			sn_partner.style.display = "inline";
		}
		sn_link.href = snLink;
		sn_link.setAttribute('onMouseOver', 'snGetLink("sn_link_' + iid + '_' + i + '",'+ snInfNum + ',' + i + ')');
		if(sn_link2) sn_link2.href = snLink;
		if(sn_link2) sn_link2.setAttribute('onMouseOver', 'snGetLink("sn_link2_' + iid + '_' + i + '",'+ snInfNum + ',' + i + ')');
		if(sn_link3) sn_link3.href = snLink;
		if(sn_link3) sn_link3.setAttribute('onMouseOver', 'snGetLink("sn_link3_' + iid + '_' + i + '",'+ snInfNum + ',' + i + ')');
		if (snInfArr[snInfNum]['show_descr']) {
			if (sn_descr) 
				sn_descr.firstChild.nodeValue = descr;
		}
		if (snInfArr[snInfNum]['show_image']) {
			if (sn_img) {
				sn_img.src = snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i][4];
				sn_img.style.display = 'inline';
				sn_img.alt = snTitle;
				sn_img.title = snTitle;
			}
		}
		snInfArr[snInfNum]['filled']=1;
	}
        if(__Images.done(iid)) __Images.onComplete(iid);
}

function snGetLink(id, snInfNum, i){
	var e = __id(id);
	if (e) e.href = snInfArr[snInfNum]['ads_news'][snInfArr[snInfNum]['ads_currentNews']][i]['reallink'];
	return true;
}

function ads_arrOut(id){
	__id(id).style.backgroundColor="#eeeeff";
}

function ads_hasPrev(){
	var st = __id("smap").style;
	if (ads_currentNews > 0){
		st.backgroundColor="#9999ff";
		st.cursor="pointer";
	}else{
		st.backgroundColor="#eeeeff";
		st.cursor="default";
	}
}

function ads_hasNext(){
	var st = __id("sman").style;
	if (ads_currentNews+1 < ads_maxNews){
		st.backgroundColor="#9999ff";
		st.cursor="pointer";
	}else{
		st.backgroundColor="#eeeeff";
		st.cursor="default";
	}
}

function ads_prev(){
	if (ads_currentNews > 0){
		ads_currentNews = ads_currentNews-1;
		ads_loadNews();
		ads_hasPrev();
	}
}

function ads_next(){
	if (ads_currentNews+1 < ads_maxNews){
		ads_currentNews = ads_currentNews+1;
		ads_loadNews();
		ads_hasNext();
	}
}

/**
 * Get argument value from URL by name
 */ 
function gup( name ) 
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


if (typeof(snInfArr) == 'undefined') snInfArr = [];
snInfNum = snInfArr.length;
snInfArr[snInfNum] = [];

snInfArr[snInfNum]['iid'] = 1790;
snInfArr[snInfNum]['filled'] = 0;
snInfArr[snInfNum]['pid'] = 1230;
snInfArr[snInfNum]['mn'] = 4;
snInfArr[snInfNum]['mts'] = 80;
snInfArr[snInfNum]['mds'] = 150;
snInfArr[snInfNum]['show_descr'] = 0;
/*snInfArr[snInfNum]['img_size'] = '0';*/
snInfArr[snInfNum]['img_suffix'] = '140x140';
snInfArr[snInfNum]['img_height'] = 140;
snInfArr[snInfNum]['img_width'] = 140;
snInfArr[snInfNum]['directlink'] = 0;
snInfArr[snInfNum]['shh'] = 'www.selectornews.com';
snInfArr[snInfNum]['show_image'] = 1;

snInfArr[snInfNum]['ads_currentNews'] = pageSN;
snInfArr[snInfNum]['ads_maxNews'] = 3;
snInfArr[snInfNum]['ads_news'] = [];

    
