/* site javascript file, not included in the CMS */

/* ####### Misc functions #######  */

function getObj(name) 
{
	var obj = document.getElementById(name);
	return obj;
}

function getTags(name)
{
	var obj = document.getElementsByTagName(name);
	return obj;
}

function newTag(name)
{
  obj = document.createElement(name);
  return obj;
}

function removeAllChildren(obj)
{
	if (obj.hasChildNodes())
	{
		while(obj.childNodes.length >= 1)
		{
			obj.removeChild(obj.firstChild);
		}
	}
}

function createEle(name)
{
	var ele = document.createElement(name);
	return ele;
}

function ie6classChange(classFrom, classTo, tag)
{
  if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(22, 23) <= 6) 
  {
    var elements = document.getElementsByTagName("div");
    for (var i = 0; i < elements.length; i++) 
    {
      if (elements[i].getAttribute("class") == classFrom || elements[i].className == classFrom) 
      {
        elements[i].className = classTo;
        elements[i].setAttribute("class", classTo);
      }
    }
  }
}


var slider_slideSpeed = 20;
var slider_timer = 5;
var objectIdToSlideDown = false;
var slider_activeId = false;
var slider_slideInProgress = false;
function showHideContent(e, inputId){
    if (slider_slideInProgress) 
        return;
    slider_slideInProgress = true;
    if (!inputId) 
        inputId = this.id;
    inputId = inputId + '';
    var numericId = inputId.replace(/[^0-9]/g, '');
    var answerDiv = document.getElementById('slider_a' + numericId);
    objectIdToSlideDown = false;
    if (!answerDiv.style.display || answerDiv.style.display == 'none') {
        if (slider_activeId && slider_activeId != numericId) {
            objectIdToSlideDown = numericId;
            slideContent(slider_activeId, (slider_slideSpeed * -1));
        }
        else {
            answerDiv.style.display = 'block';
            answerDiv.style.visibility = 'visible';
            slideContent(numericId, slider_slideSpeed);
        }
    }
    else {
        slideContent(numericId, (slider_slideSpeed * -1));
        slider_activeId = false;
    }
}



function applyTooltips(){
    var body_element = document.getElementsByTagName("body")[0];
    var toolTipWrapper = document.createElement('div');
    toolTipWrapper.setAttribute('id', 'tool_tip_wrapper');
    body_element.appendChild(toolTipWrapper);
    var elements = document.getElementsByTagName("span");
    for (var i = 0; i < elements.length; i++) {
        if (elements[i].getAttribute("class") == "apply_tooltip" || elements[i].className == "apply_tooltip") {
            var nbspace = document.createTextNode(' ');
            elements[i].appendChild(nbspace);
            var toolTipIcon = document.createElement('img');
            
        	var hrefItems = window.location.href.split("/");
        	item1 = hrefItems[3];    

            if (item1 == 'my-collection')
            {
            	toolTipIcon.setAttribute('src', '/images/tt_icon2.gif');
            } else
            {
            	toolTipIcon.setAttribute('src', '/images/tt_icon.gif');
            }
            toolTipIcon.setAttribute('class', 'tooltip_icon');
            toolTipIcon.setAttribute('border', '0');
            toolTipIcon.onmouseover = function(){
                toolTip(this);
                return false;
            }
            if (!toolTipIcon.getAttribute('onmouseover')) {
                toolTipIcon.setAttribute("onmouseover", "toolTip(this)");
            }
            toolTipIcon.onmouseout = function(){
                var wrapper = document.getElementById('tool_tip_wrapper');
                var element = document.getElementById('toolTip');
                wrapper.removeChild(element);
                return false;
            }
            elements[i].appendChild(toolTipIcon);
        }
    }
}

function toolTip(obj){
    var eleID = obj.parentNode.id;
    var find_pos = findPos(obj);
    var windowWidth = document.body.clientWidth;
    var windowHeight = document.body.clientHeight;
    var offset_left = find_pos[0];
    var offset_top = find_pos[1];
    if (eleID != null) {
        var eleInformation = getInformation(eleID);
        var theDescription = document.createElement('p');
        var theHeading = document.createElement('strong');
        var theBR = document.createElement('br');
        var theBR2 = document.createElement('br');
        theDescription.setAttribute('title', document.createTextNode(eleInformation[1]));
        var textArr = eleInformation[2].split("##br##");
        var textDescription = document.createElement("span");
        for (var x = 0; x < textArr.length; x++) {
            textDescription.appendChild(document.createTextNode(textArr[x]));
            textDescription.appendChild(document.createElement("br"));
        }
        var textHeading = document.createTextNode(eleInformation[1]);
        theHeading.appendChild(textHeading);
        theHeading.appendChild(theBR);
        theHeading.appendChild(theBR2);
        theDescription.appendChild(theHeading);
        theDescription.appendChild(textDescription);
        var toolTipDiv = document.createElement('div');
        toolTipDiv.setAttribute('id', 'toolTip');
        document.getElementById('tool_tip_wrapper').appendChild(toolTipDiv);
        document.getElementById('toolTip').appendChild(theDescription);
        if (offset_left + 350 > windowWidth) {
            offset_left = offset_left - 350;
        }
        var ttHeight = document.getElementById('toolTip').clientHeight;
        if (offset_top + ttHeight > windowHeight) {
            offset_top = offset_top - ttHeight - 25;
        }
        offset_left = offset_left + 5;
        offset_top = offset_top + 20;
        document.getElementById('toolTip').style.left = offset_left + 'px';
        document.getElementById('toolTip').style.top = offset_top + 'px';
    }
}

function findPos(obj){
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }
    return [curleft, curtop];
}


function getInformation(eleTitle){
    var info = new Array();
    info.push(new Array("tt_search_query","Search Query Field","Please search by typing information about the record in this field. This can be song title, EP title or LP title, record label, catalogue number, year or format."));
    info.push(new Array("tt_search_artist","Search Artist Field","If you want to search for records by a specific artist please type their name in here and select from the list of options that appear.##br####br## This can also be used to filter the results you get from the general search field on the right"));
    
    info.push(new Array("tt_my_collection_query","Search Query Field","Please search by typing information about the record in this field. This can be song title, EP title or LP title, record label, cataologue number, year or format."));
    info.push(new Array("tt_my_collection_artist","Search Artist Field","If you want to search for records by a specific artist please type their name in here and select from the list of options that appear.##br####br## This can also be used to filter the results you get from the general search field on the right"));
    info.push(new Array("tt_my_collection_price","Filtering by Price","Please select one of the predefined price options to limit your results to all records within that range"));
    info.push(new Array("tt_my_collection_format","Filtering by Format","Please select one of the predefined format options to limit your results to all records with that format"));
    info.push(new Array("tt_my_collection_decade","Filtering by Decade","Please select one of the predefined decades to limit your results to all records that we're produced in that decade"));        
    
    
    info.push(new Array("tt_sample", "This is a sample tool-tip", "These tool-tips provide helpful hints and information"));
    for (var i = 0; i < info.length; i++) {
        if (info[i][0] == eleTitle) {
            var retArray = new Array(info[i][0], info[i][1], info[i][2]);
            return retArray;
        }
    }
    var notFoundArray = new Array("tt_not_found", "Tooltip Unavailable", "Unfortunately this tool tip cannot be displayed. Please contact the application developer if you see this notification")
    if (!retArray) {
        return notFoundArray;
    }
}






function slideContent(inputId, direction){
    var obj = document.getElementById('slider_a' + inputId);
    var contentObj = document.getElementById('slider_ac' + inputId);
    height = obj.clientHeight;
    if (height == 0) 
        height = obj.offsetHeight;
    height = height + direction;
    rerunFunction = true;
    if (height > contentObj.offsetHeight) {
        height = contentObj.offsetHeight;
        rerunFunction = false;
    }
    if (height <= 1) {
        height = 1;
        rerunFunction = false;
    }
    obj.style.height = height + 'px';
    var topPos = height - contentObj.offsetHeight;
    if (topPos > 0) 
        topPos = 0;
    contentObj.style.top = topPos + 'px';
    if (rerunFunction) {
        setTimeout('slideContent(' + inputId + ',' + direction + ')', slider_timer);
    }
    else {
        if (height <= 1) {
            obj.style.display = 'none';
            if (objectIdToSlideDown && objectIdToSlideDown != inputId) {
                document.getElementById('slider_a' + objectIdToSlideDown).style.display = 'block';
                document.getElementById('slider_a' + objectIdToSlideDown).style.visibility = 'visible';
                slideContent(objectIdToSlideDown, slider_slideSpeed);
            }
            else {
                slider_slideInProgress = false;
            }
        }
        else {
            slider_activeId = inputId;
            slider_slideInProgress = false;
        }
    }
}



function initShowHideDivs()
{
	$j = jQuery.noConflict();
	$j("#top_menu_wrapper a").hover(function() {
		var currHeight = $j(this).css('background-position').split(' ');
		var max_height = currHeight[1].replace('px', '');
		var id = $j(this).attr('id');
		for (var x = max_height; x >= 0; x--)
		{
			$j(this).css('background-position', '0px ' + x + 'px');
		}
	},
	function() {
		var height = $j(this).css('height');
		// alert(height);
		for (var x = 0; x <= 26; x++)
		{
			$j(this).css('background-position', '0px ' + x + 'px');
		}
	}	
	);	
}


function createXMLHttpRequest() 
{
		if (typeof XMLHttpRequest != "undefined") 
		{
        return new XMLHttpRequest();
    } else if (typeof ActiveXObject != "undefined") 
		{
        return new ActiveXObject("Microsoft.XMLHTTP");
    } else 
		{
        throw new Error("XMLHttpRequest not supported");
    }
}


function highlightMenu()
{
  var aEles = getTags("a");
  for (var x = 0; x < aEles.length; x++)
  {
    var hrefElements = aEles[x].href.split('.');
    if (aEles[x].className == "menu_link" && window.location.href.indexOf("."+hrefElements[1]) != -1)
    {
      aEles[x].style.color = '#2874B4';
      aEles[x].style.fontWeight = 'bold';

      var ids = aEles[x].parentNode.parentNode.id.split("list_");
      showHideContent(false, ids[1]);
      
      var wrapper = getObj("item_"+ids[1])
      wrapper.style.backgroundImage = "url(/images/menu_bg5.gif)";
    }
  }
}


function initFilteringSubmit()
{
  // site_select_filtering_small, site_select_filtering
  var elements = document.getElementsByTagName("select");
  for (var i = 0; i < elements.length; i++) 
  {
    if (elements[i].getAttribute("class") == "site_select_filtering_small" || elements[i].className == "site_select_filtering_small" || elements[i].getAttribute("class") == "site_select_filtering" || elements[i].className == "site_select_filtering") 
    {
      elements[i].onchange = function() 
      {
        getObj('search-records').submit();
      }
    }
  }
}


function searchShowHide(obj)
{
  // scroller_content_search
  var searchEle = getObj('search_content_box');
  if (searchEle.style.display == 'none' || searchEle.style.display == '')
  {
    searchEle.style.display = "block";
  } else
  {
    searchEle.style.display = "none";  
  }
}

function openExternalWindow(object){
    window.open(object.href, '', 'scrollbars=yes,menubar=yes,height=700,width=900,resizable=yes,toolbar=yes,location=yes,status=yes');
}


function decadeChange(obj)
{
    var year_wrapper = getObj('year_wrapper');

    if (year_wrapper != null)
    {
    	year_wrapper.style.display="block";
    }
    
    qs = parseQueryString();
    
    var pre_selected_year = qs['filtering_year'];

    var select_wrapper = getObj('year_select_wrapper');    
	var select = newTag('select');
	select.setAttribute('name', 'filtering_year');
	select.setAttribute('id', 'exact_year');
	option = newTag('option');
	option.value = '';
	var text = document.createTextNode(' - any - ');
	option.appendChild(text);
	select.appendChild(option);    
	
    var decade = parseInt(obj.value);
    for (var x = decade; x < (decade+10); x++)
    {
    	option = newTag('option');
    	option.value = x;
    	if (x == pre_selected_year)
    	{
    		option.setAttribute('selected', 'selected');
    	}
    	var text = document.createTextNode(x);
    	option.appendChild(text);
    	select.appendChild(option);
    }
    
    if (select_wrapper != null)
    {
    	removeAllChildren(select_wrapper);
    	select_wrapper.appendChild(select);
    }
    
    if (obj.value == '')
    {
    	year_wrapper.style.display="none";    	
    }

    
    
// year_select_wrapper
// year_wrapper
	
}

function initDecadeSelect()
{
	var decadeSelect = getObj('set_decade_select');
	
	
	if (decadeSelect != null)
	{
		decadeSelect.onchange = function() {
			decadeChange(this);
		}
		
		if (decadeSelect.value != '')
		{
			decadeChange(decadeSelect);
		}		
	}

}


function setSelectListToValue(value, selectId){
	var i=0;
	while ( (document.selectId.countries.options[i].value != value) && (i < document.f1.countries.options.length))
	{i++;}
	if (i < document.f1.countries.options.length)
	{document.f1.countries.selectedIndex = i;}
	
}


function parseQueryString() {
	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);
			qsParm[key] = val;
		}
	}
	
	return qsParm;
} 
	


function initAddCollectionListener()
{
	// add_to_collection
  var elements = document.getElementsByTagName("a");
  for (var i = 0; i < elements.length; i++) 
  {
    if (elements[i].getAttribute("class") == "add_to_collection" || elements[i].className == "add_to_collection") 
    {
      elements[i].onclick = function()
      {
        addToCollection(this);
        return false;
      }
    }
  }	
}


function addToCollection (aObj)
{
	aObj.childNodes[0].src = '/images/loading.gif';
	var dateObj = new Date();
	var timestamp = dateObj.getTime();
	var xmlHttp = createXMLHttpRequest();
	var params = "time="+timestamp;
	var url_pieces = aObj.href.split("/");
	var url = url_pieces[3]+"/"+url_pieces[4]+"/"+url_pieces[5];
	xmlHttp.open("POST", "/ajax/" + url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{
			if (xmlHttp.responseText == "true")
			{
				if (aObj.childNodes[0].nodeType == '1')
				{
					// its our image element
					aObj.childNodes[0].src = '/images/add_to_collection_in.gif';
				}
			}
	    }
	}
	xmlHttp.send(params);
}



function initDeleteCollectionListener()
{
	// add_to_collection
  var elements = document.getElementsByTagName("a");
  for (var i = 0; i < elements.length; i++) 
  {
    if (elements[i].getAttribute("class") == "delete_from_collection" || elements[i].className == "delete_from_collection") 
    {
      elements[i].onclick = function()
      {
        deleteFromCollection(this);
        return false;
      }
    }
  }	
}

function deleteFromCollection (aObj)
{
	aObj.childNodes[0].src = '/images/delete_button_conf.gif';
	aObj.childNodes[0].removeAttribute('onmouseover');
	aObj.childNodes[0].removeAttribute('onmouseout');
	aObj.onclick = function()
    {
      confirmedDeleteFromCollection(this);
      return false; 
    }	
}


function confirmedDeleteFromCollection (aObj)
{
	aObj.childNodes[0].src = '/images/loading.gif';
	var dateObj = new Date();
	var timestamp = dateObj.getTime();
	var xmlHttp = createXMLHttpRequest();
	var params = "time="+timestamp;
	var url_pieces = aObj.href.split("/");
	var url = url_pieces[3]+"/"+url_pieces[4]+"/"+url_pieces[5];
	xmlHttp.open("POST", "/ajax/" + url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{
			if (xmlHttp.responseText == "true")
			{
				if (aObj.childNodes[0].nodeType == '1')
				{
					// pull in the cost
					var costSpan = getObj('itemcost_' + url_pieces[5]);
					if (costSpan != null)
					{
						// reduce the counter by one
						getObj('collection_item_count').innerHTML = ' '+(parseInt(getObj('collection_item_count').innerHTML) - 1);
						
						// collect the item cost
						var itemCost = parseInt(costSpan.innerHTML);
						
						// apply update to collection cost
						var valueObj = getObj('collection_item_value');
						var totalCost = valueObj.innerHTML.replace(',', '').match(/\d+/);
						var newCost = addCommas((totalCost - itemCost));
						valueObj.innerHTML = valueObj.innerHTML.replace(addCommas(totalCost), newCost);
						
						// apply update to page total cost
						var valueObj = getObj('collection_page_value_count');
						var totalCost = valueObj.innerHTML.replace(',', '').match(/\d+/);
						var newCost = addCommas((totalCost - itemCost));
						valueObj.innerHTML = valueObj.innerHTML.replace(addCommas(totalCost), newCost);				
						
					}
					
					// get rid of the whole row
					var rowEle = aObj.parentNode.parentNode.parentNode;
					rowEle.parentNode.removeChild(rowEle);
					
				}
			} else
			{
				aObj.childNodes[0].src = '/images/delete_button_conf.gif';
			}
	    }
	}
	xmlHttp.send(params);
}


function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}



function styleSpamImage()
{
	var ddEles = getTags('dd');

	for (var i = 0; i < ddEles.length; i++) 
	{
		if (ddEles[i].id == '' && ddEles[i].lastChild.className == 'hint')
		{
			ddEles[i].lastChild.style.left = '16em';
		}
	}	
}

function refreshSpamImage(aObj)
{	
	var ddEles = getTags('dd');

	for (var i = 0; i < ddEles.length; i++) 
	{
		if (ddEles[i].id == '' && ddEles[i].lastChild.className == 'hint')
		{
			for (var j = 0; j < ddEles[i].childNodes.length; j++)
			{
				if (ddEles[i].childNodes[j].nodeType == 1)
				{
					if (ddEles[i].childNodes[j].src != null && ddEles[i].childNodes[j].src != '')
					{
						var imgObj = ddEles[i].childNodes[j];
					}
				}
				
			}
			var inputObj = getObj('captcha-id');
		}
	}
	
	if (inputObj != null && imgObj != null)
	{
		var dateObj = new Date();
		var timestamp = dateObj.getTime();
		var xmlHttp = createXMLHttpRequest();
		var params = "time="+timestamp;
		xmlHttp.open("POST", "ajax/refresh-spam-image", true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4)
			{	
				var parts = xmlHttp.responseText.split("/images/captcha/");
				imgObj.src = "/images/captcha/" + parts[1].split(".png")[0] + '.png';
				inputObj.value = parts[1].split(".png")[0];
			}
		}
		xmlHttp.send(params);	
	}
}



function initAddSearchDropDownListener()
{
	var aTag = getObj('search_drop_down_click');
	if (aTag != null)
	{
		aTag.onclick = function()
		{
			showHideAdvancedSearch();
			return false;
		}
		aTag.onfocus = function()
		{
			this.blur();
		}
	}
}


function showHideAdvancedSearch()
{
	var advancedBox = getObj('search_drop_down_box');
	if (advancedBox != null)
	{	
	  if (advancedBox.style.display == 'none' || advancedBox.style.display == '')
	  {
	    advancedBox.style.display = "block";
	  } else
	  {
	    advancedBox.style.display = "none";  
	  }			
	}
}


function initDisableRightClick()
{
	var wrapper = getObj('public_search_wrapper');
	if (wrapper != null)
	{
	    if (document.all)
	    {	// IE	
	    	wrapper.onmousedown = disableRightClick;
	    } else
	    {   // throw it on mouse up for FF (changes focus)
	    	wrapper.onmouseup = disableRightClick;	    	
	    }
	}
}

function onKeyDown() 
{  
	//alert('keydown');
	// current pressed key  
	var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();   
	if (event.ctrlKey && (pressedKey == "c" || pressedKey == "v")) 
	{    
		// disable key press porcessing    
		event.returnValue = false;  
	} 
}

function disableRightClick(e)
{
	var body = getTags('body')[0];
	var message="This content is copyrighted and cannot be copied.";

    if (document.all)
    {
      if (event.button==2||event.button==3)
      {
        alert(message);
        return false;
      }
    } else
    {
    	//alert(e.button);
      if (e.button==2||e.button==3)
      {
        e.preventDefault();
        e.stopPropagation();
        alert(message);
        body.focus();
        return false;
      }
    }	
    return true;
}


function initSearchButtonHover()
{
	var searchButton = getObj('search_button');
	if (searchButton != null)
	{	
		searchButton.onmouseover = function()
		{
			searchButton.src= '/images/search_go_button2.gif';
		}
		searchButton.onmouseout = function()
		{
			searchButton.src= '/images/search_go_button.gif';
		}	  
	}	
}


function initHomePageButtonsHover()
{
	var elements = document.getElementsByTagName("img");
	for (var i = 0; i < elements.length; i++) 
	{
		if (elements[i].getAttribute("class") == "home_page_button" || elements[i].className == "home_page_button") 
		{
			elements[i].onmouseover = function()
			{
				homeButtonHover(this);
				return false;
			}
			
			elements[i].onmouseout = function()
			{
				homeButton(this);
				return false;
			}
		}
	}	
}

function homeButton(obj)
{
	obj.src = obj.src.replace('_hover.gif', '.gif');
}

function homeButtonHover(obj)
{
	obj.src = obj.src.replace('.gif', '_hover.gif');
}


function preloadAdvanceDropDown()
{
	
	if (getObj('filtering_format').value != '' || getObj('set_decade_select').value != '' || getObj('filtering_price').value != '')
	{
		// we have populated filtering values, we need to trigger the pop-down
		var advancedBox = getObj('search_drop_down_box');
		if (advancedBox != null)
		{	
		  if (advancedBox.style.display == 'none' || advancedBox.style.display == '')
		  {
			  showHideAdvancedSearch();
		  }
		}		
	}
		
}

function resetAdvancedFilters()
{
	var resetIds = new Array('set_decade_select', 'filtering_format', 'exact_year', 'filtering_price');
	var x;
	for (x in resetIds)
	{
		var SelElement = getObj(resetIds[x]);
		if (SelElement != null)
		{
			for (var j = 0; j < SelElement.childNodes.length; j++)
			{
				if (SelElement.childNodes[j].nodeType == '1')
				{
					SelElement.childNodes[j].selected=true;
					break;
				}
			}
		}
	}
}

/* ####### DOM alterations, performed after window load ####### */

function applyDOMAlterations() 
{
	var hrefItems = window.location.href.split("/");
	item1 = hrefItems[3];
	item2 = hrefItems[4];
	item3 = hrefItems[5];

  ie6classChange('scroller_title_bar', 'title_bar', 'div');  
  
	// initSearchShowHideDivs();
  // highlightMenu();
  
  
  // red menu item, show / hide
  // initShowHideDivs();
  
  if (item1 == 'search' || item1 == 'my-collection' )
  {
	initDecadeSelect();
	//initAddCollectionListener();   now done after ajax loader
	initAddSearchDropDownListener();
	initDisableRightClick();	  	
  }
  
  if (item1 == 'my-collection')
  {
	initDeleteCollectionListener();
  }
  
  if (item1 == 'search')
  {
	  initSearchButtonHover();
	  preloadAdvanceDropDown();
  }
  
  if (item1 == 'home')
  {
	  initHomePageButtonsHover();
  } 

  if (item1 == 'subscribe')
  {
	  styleSpamImage();
  }
   // initFilteringSubmit();  
  
  applyTooltips();
  
}

window.onload = applyDOMAlterations;	
