var toOpenUrl;

function onMouseMoveEvent()
{
	if (toOpenUrl)
	{
		var url = toOpenUrl;
		
		toOpenUrl = null;
		
		var winfeatures="scrollbars=1,resizable=1,toolbar=0,location=0,menubar=0,status=0,directories=0"

		var popunder = window.open(url, "", winfeatures);
		
		if (popunder)
		{
			
			popunder.blur();
			window.focus();	
		}
	}
}


function openItem(url)
{
	var item_window = window.open(url, "_blank");
	
	if (item_window)
		return false;
}

function openProduct(url)
{
	document.location.href = url;
}


function init()
{
	showAds();
}


function showAds()
{
	// Function provided by Google Inc.
	// for Wegner-ITS
	var options = {
        'colorText' : '#333333',
        'colorTitleLink' : '#0033CC',
        'colorDomainLink' : '#0033CC',
        'colorBackground' : '#FEFBCB',
        'colorBorder' : '#FEFBCB',
        'hl' : 'de',
        'gl' : 'de',
        'pubId' : 'pub-9296537736967866',
        'query' : query,
        'container' : 'wits_ads1',
        'format' : 'wide',
        'number' : 2 };
 	var dynamicAd = new google.ads.search.Ad(options);
	
	var options = {
        'colorText' : '#333333',
        'colorTitleLink' : '#0033CC',
        'colorDomainLink' : '#0033CC',
        'colorBackground' : '#FFFFFF',
        'colorBorder' : '#FFFFFF',
        'hl' : 'de',
        'gl' : 'de',
        'pubId' : 'pub-9296537736967866',
        'query' : query,
        'container' : 'wits_ads2',
        'format' : 'wide',
        'number' : 5 };
 	var dynamicAd = new google.ads.search.Ad(options);
	
	
}



function openProductUnder(url)
{
	toOpenUrl = url;
	

}



function GoSearch(searchText) {
        if(!searchText || searchText.length<1 || Trim(searchText).length<1) {
                alert('Please type the word or words you want to search for in the search box.');
                return false;
        }

        return true;
}

function Trim(source) {
  source = source.replace( /^\s+/g, "" );
  return source.replace( /\s+$/g, "" );
}

function validate_count( which ) {
  var i=0;
  var count=0;
  for(i=0; i<document.CompareProducts.elements.length; i++)
  {
    if (document.CompareProducts.elements[i].checked == true){count++;}
    if (count > 10) {
       alert('A maximum of 10 products can be compared at one time.');
       document.CompareProducts[which].checked = false;
       break;
    }
  }
  if (which == 'Form') {
     if (count <= 1) {
         if(count==0&&document.CompareProducts.addKeywords.value!="")
         alert('Choose at least two products.');
         return false;
     } else {
         return true;
     }
  }
}

function toggle(section) {
    var elem = document.getElementById(section);
    if (elem) {
        elem.style.display = (elem.style.display != '') ? '' : 'none';
    }
    var img  = document.getElementById('img_'+section);
    if (img && img.src == plus.src) {
        img.src = minus.src;
        img.alt = minus.alt;
    } else if (img) {
        img.src = plus.src;
        img.alt = plus.alt;
    }
}

var minus = new Image(12,12);
var plus  = new Image(12,12);
minus.src = 'http://static.dusparst.com/images/Skin2/minus1.gif';
minus.alt = 'Click here to collapse this section';
plus.src  = 'http://static.dusparst.com/images/Skin2/plus1.gif';
plus.alt  = 'Click here to expand this section';

function toggle2(divId) {
  if(document.getElementById(divId).style.display == 'none') {
      document.getElementById(divId).style.display = 'block';
  } else {
      document.getElementById(divId).style.display = 'none';
  }
  return true;
}


linkName2Index=new Object();
function gotoclick(t,s){
   var d=document;
   if(linkName2Index[s]>=0){
      t.href=d.links[linkName2Index[s]];
      return true;
   }

   for(i=d.links.length-1;i>=0;i--){
      if(typeof d.links[i].name!="undefined"){
         if(d.links[i].name==s){
            linkName2Index[d.links[i].name]=i;
            t.href=d.links[i];
            return true;
         }
      }
   }
   return null;
}
