isOP = (navigator.userAgent.indexOf('Opera') > 0)?true:false;
isIE = (navigator.appName=='Microsoft Internet Explorer' && !isOP)?true:false;
isMOZ = (navigator.appName.indexOf=='Netscape')?true:false;

if (!document.getElementById){
	document.getElementById = function(){return null;}
	document.getElementsByTagName = function(){return null;}
}
    function trim (str) {
           str = str.replace(/^\s+/, '');
           for (var i = str.length; --i >= 0;) {
                   if (/\S/.test(str.charAt(i))) {
                           str = str.substring(0, i + 1);
                           break;
                   }
           }
           return str;
   }

//Query string
var qsParm = new Array();
  var query = window.location.search.substring(1);
  var parms = query.split('&');
  for (var i=0; i<parms.length; i++) {
    var pos = parms[i].indexOf('=');
    if (pos > 0) {
      var key = parms[i].substring(0,pos);
      var val = parms[i].substring(pos+1);
		val=val.replace(/%20/g,' ');
		val=trim(val);
      qsParm[key] = val;
    }
  }
var searchString=qsParm['k'];

// Load functions
onLoadList = new Array();

// Example: addOnLoad('someFunction');
function addOnLoad(func){
	onLoadList[onLoadList.length] = func;
}

function runOnLoad(){
	for(i in onLoadList){
		var addPar = "";
		//alert(onLoadList[i])
		if (onLoadList[i].indexOf("(") == -1) addPar = "()";
		eval(onLoadList[i]+addPar);
	}
}

// Init
//addOnLoad('iterateDipers');
//window.onload = runOnLoad;

    function iterateDipers(){
	

      var tags = document.getElementsByTagName("a");
	    for (i = 0; i < tags.length; i++){
		    if(tags[i].className=='diperanimation')
          tags[i].onclick=function(){
            showDiperAnimation();
          }
      }
    }
    
function showDiperAnimation(){
  var h = window.open("/_layouts/1033/tnt/index.htm", "", "width=1024;height=569;status=no;toolbar=no");
}

function stripBlanks(fld) {
  var result = "";
  var c = 0;
  for (i=0; i<fld.length; i++) {
    if (fld.charAt(i) != " " || c > 0) {
      result += fld.charAt(i);
      if (fld.charAt(i) != " ") c = result.length;
    }
  }
  return result.substr(0,c);
}

function validField(fld) {
  fld = stripBlanks(fld);
  if (fld == '') return false;
  return true;
}
	
function doSearch(){
  setCookie('lang',scope);
  var strSearch = document.forms[0].searchfield.value;
  if(scope=='fibertex_search'){
	
    if(validField(strSearch))document.location='/'+lang+'/Search/pages/default.aspx?k='+strSearch+'&s='+qsParm['s'];
  }else{
  
    if(validField(strSearch))document.location='/'+lang+'/Search/pages/default.aspx?k='+strSearch+'&s='+scope;
  }    
}

function entsub(whatform) {
  if (window.event && window.event.keyCode == 13){
    doSearch();
    return false;
  }else{
    return true;
  }
}

//duplicate until now
function doSearchEx(){
  var strSearch = document.forms[0].searchfieldbottom.value;
  if(validField(strSearch))document.location='/'+lang+'/Search/pages/default.aspx?k='+strSearch+'&s='+qsParm['s'];
  //getCookie('lang');
}

function entsubex(whatform) {
  if (window.event && window.event.keyCode == 13){
    doSearchEx();
    return false;
  }else{
    return true;
  }
}

//cookie functions
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}












function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
  // the highlightStartTag and highlightEndTag parameters are optional
  if ((!highlightStartTag) || (!highlightEndTag)) {
    highlightStartTag = "<span class='highlite'>";
    highlightEndTag = "</span>";
  }

  // find all occurences of the search term in the given text,
  // and add some "highlight" tags to them (we're not using a
  // regular expression search, because we want to filter out
  // matches that occur within HTML tags and script blocks, so
  // we have to do a little extra validation)
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      // skip anything inside an HTML tag
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
        // skip anything inside a <script> block
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
          newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }
  
  return newText;
}


/*
 * This is sort of a wrapper function to the doHighlight function.
 * It takes the searchText that you pass, optionally splits it into
 * separate words, and transforms the text on the current web page.
 * Only the "searchText" parameter is required; all other parameters
 * are optional and can be omitted.
 */
 
 
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function highlightSearchTerms(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{

  // if the treatAsPhrase parameter is true, then we should search for 
  // the entire phrase that was entered; otherwise, we will split the
  // search string so that each word is searched for and highlighted
  // individually
  if (treatAsPhrase) {
    searchArray = [searchText];
  } else {
    searchArray = searchText.split(" ");
  }
	var div = document.getElementById('results');
	elements = getElementsByClass('highlight', div, 'dd');
	 for (var j = 0; j < elements.length; j++) {
			var bodyText = elements[j].innerHTML;
			for (var i = 0; i < searchArray.length; i++) {
				bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
			}
			elements[j].innerHTML = bodyText;
  }
 
  return true;
}


function SendSoap(postUrl, soapAction, env, clickUrl, pos, bestBet, cont, nonClickedXml)
{
    var req = (window.XMLHttpRequest) ? (new XMLHttpRequest())
            : (window.ActiveXObject) ? (new ActiveXObject('Msxml2.XMLHTTP')) : null;
    if (req)
    {
        req.open('POST', postUrl, true);
        req.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
        req.setRequestHeader('SOAPAction', soapAction);
        if (clickUrl) env = env.replace("</i>", '<c>' + XmlEscape(clickUrl) + '</c>' + "</i>");
        if (pos) env = env.replace('<r>0','<r>'+pos);
        if (cont) env = env.replace('<f>false','<f>true');
        if (bestBet) env = env.replace("</i>", '<y>' + XmlEscape(bestBet) + '</y>' + "</i>");
        if (nonClickedXml) env = env.replace("</i>", nonClickedXml + "</i>");
        req.send(env);
    }
}