/* $Id: general.js 2374 2009-05-13 10:22:39Z madams $ */

// here was a few FZ functions CR 1532


// function to do what? where?

function switcher(which,whichLevel)
{
	var form = document.getElementById(which);
	var level = document.getElementById(whichLevel);
	if(level.className == 'show') {
		form.className = form.className.replace('off','');
		level.className = 'hide';
	} else {
		form.className += ' off';
		level.className = 'show';
	}
	return false;
}

// function to enlarge images added by dlynch 11/09/06
  function popUp(URL,width,height) {
  window.open(URL, 'popup', 'toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left = 50,top = 50');
return false;
}

// function Opens a new window with all menus, scroll bars etc. Added by Mark OG 29/9/2006
function openWindow(URL,width,height) 
{
  window.open(URL, '_blank', 'toolbar=1,scrollbars=1,location=1,status=1,menubar=1,resizable=1,width=' + width + ',height=' + height + ',left = 50,top = 50');
return false;
}

// function Opens a new window with all menus, scroll bars etc. Added by Mark OG 29/9/2006
function openExternal(URL,width,height) {
alert("Please note: T-Mobile Accessories Shop is powered by Kondor therefore all transactions function through an independent basket." + '\n\n' + "Current site: www.t-mobile.co.uk" + '\n' + "Destination site: www.t-mobileaccessories.co.uk");
  window.open(URL, '_blank', 'toolbar=1,scrollbars=1,location=1,status=1,menubar=1,resizable=1,width=' + width + ',height=' + height + ',left = 50,top = 50');

}

//function for select menus change url added by dlynch 14/09/06
function loadPage(pageURL){
    location.href = pageURL.options[pageURL.selectedIndex].value
    }

// function prints window
function printWindow() {
    if (window.print) {
        window.print();
    } else {
        alert('Sorry, your browser doesn\'t support this feature. Please use the browsers print option.');
    }
}    

function faqShow(which) {		
	if (document.getElementById && document.createTextNode) {			
		m = document.getElementById("faq-menu");			
		trig = m.getElementsByTagName("div").item(which).style.display;			
			if (trig=="block") trig="none";			
			else if (trig=="" || trig=="none") trig="block";			
			m.getElementsByTagName("div").item(which).style.display = trig;		
					}
}
// for eshop price plan pages
function planExpanded(id, which){		
	if (document.getElementById && document.createTextNode) {			
		m = document.getElementById(id);			
		trig = m.getElementsByTagName("div").item(which).style.display;			
			if (trig=="block") trig="none";			
			else if (trig=="" || trig=="none") trig="block";			
			m.getElementsByTagName("div").item(which).style.display = trig;		
					}
}

// expandable terms and conditions like faq-menu

function termsToggle(which){		
	if (document.getElementById && document.createTextNode) {			
		m = document.getElementById("terms");			
		trig = m.getElementsByTagName("p").item(which).style.display;			
			if (trig=="block") trig="none";			
			else if (trig=="" || trig=="none") trig="block";			
			m.getElementsByTagName("p").item(which).style.display = trig;		
					}
}

function getElementsByClass(searchClass, node, tag){
		if (document.getElementById && document.createTextNode){
	var i,j;
	var s=[];
	var objlist=[];
	if (!node) node = document;
	
	if (!tag){
if(document.all){
//If IE
var els=node.all;
}else{
//If Not IE
var els=node.getElementsByTagName('*');
}
}else{
var els=node.getElementsByTagName(tag);	
}
	
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');		
	for(i=0, j=0;i<els.length;i++){
		if ( pattern.test(els[i].className) ) {
			
			objlist[j]=els[i];
			j++;
		}
	}
	return(objlist);
		}
}
function showBlock(styleClass, id){
    var block = document.getElementById(id);
    if(block != undefined)
        block.className = block.className.replace(styleClass + ' hide-block' ,styleClass + ' show-block');
}
function hideBlock(styleClass, id){
    var block = document.getElementById(id);
    if(block != undefined)
        block.className = block.className.replace(styleClass + ' show-block', styleClass + ' hide-block');
}