<!--

// -------
// Slys Site Builder 0.1
// Global JS File
// (c) 2005 Slys.co.uk
//
// http://www.slys.co.uk
// -------

//==========================================
// Set up
//==========================================

 var cookie_id      = "";
 var cookie_Domain = ".thevista.co.uk";
 var cookie_path   = "/";


// Get cookie

function GetCookie( name )
{
	cname = cookie_id + name + '=';
	cpos  = document.cookie.indexOf( cname );
	
	if ( cpos != -1 )
	{
		cstart = cpos + cname.length;
		cend   = document.cookie.indexOf(";", cstart);
		
		if (cend == -1)
		{
			cend = document.cookie.length;
		}
		
		return unescape( document.cookie.substring(cstart, cend) );
	}
	
	return null;
}

// Set cookie

function SetCookie( name, value, LongTerm )
{
	Expiry = "";
	Domain = "";
	Path   = "/";
	
	if ( LongTerm )
	{
		Expiry = "; expires=Wed, 1 Jan 2020 00:00:00 GMT";
	}
	
	if ( cookie_Domain != "" )
	{
		Domain = '; domain=' + cookie_Domain;
	}
	
	if ( cookie_path != "" )
	{
		Path = cookie_path;
	}
	
	document.cookie = cookie_id + name + "=" + value + "; path=" + Path + Expiry + Domain + ';';
}

// Get element by id

function getbyid(id)
{
	var item = '';
	
	if (document.getElementById)
	{
		item = document.getElementById(id);
	}
	else if (document.all)
	{
		item = document.all[id];
	}
	else if (document.layers)
	{
		item = document.layers[id];
	}
	
	return item;
}

// Set DIV ID to hide

function hide_div(item)
{
	if ( ! item ) return;
	
	item.style.display = "none";
}

// Set DIV ID to show

function show_div(item)
{
	if ( ! item ) return;
	item.style.display = "";
}

// Toggle show/hide

function toggle_item( Page_Item_id, Add )
{
	saved = new Array();
	clean = new Array();

	// Get cookie
		
	if ( temp = GetCookie('showhide') )
	{
		saved = temp.split(",");
	}
	
	// Remove bit if exists	already
		
	for( i = 0 ; i < saved.length; i++ )
	{
		if ( saved[i] != Page_Item_id && saved[i] != "" )
		{
			clean[clean.length] = saved[i];
		}
	}
	
	// Add item to cookie
		
	if ( Add )
	{
		clean[ clean.length ] = Page_Item_id;
		show_div( getbyid( 'closed_' + Page_Item_id ) );
		hide_div( getbyid( 'open_' + Page_Item_id ) );
	}
	else
	{
		show_div( getbyid( 'open_' + Page_Item_id ) );
		hide_div( getbyid( 'closed_' + Page_Item_id ) );
	}
	SetCookie( 'showhide', clean.join(','), 1 );
}

function SetFromCookie() {
	saved = new Array();
	if ( temp = GetCookie('showhide') )
	{
		saved = temp.split(",");
	}

    for (i=0; i < saved.length; i++ ) {
		show_div( getbyid( 'closed_' + saved[i] ) );
		hide_div( getbyid( 'open_' + saved[i] ) );
    }
}

var moz = (navigator.appName == 'Netscape' && navigator.product == 'Gecko') ? 1 : 0;

function onblurfocus() {
	if (moz){
		return self.close();
	} else {
	    return self.focus(); 
	}
}

function PopUp(url, name, width,height,center,resize,scroll,posleft,postop) {
    if (posleft != 0) { x = posleft }
    if (postop  != 0) { y = postop  }

    if (!scroll) { scroll = 1 }
    if (!resize) { resize = 1 }

    if ((parseInt (navigator.appVersion) >= 4 ) && (center)) {
      X = (screen.width  - width ) / 2;
      Y = (screen.height - height) / 2;
    }
    if (scroll != 0) { scroll = 1 }

    var Win = window.open( url, name, 'width='+width+',height='+height+',top='+Y+',left='+X+',resizable='+resize+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no');
}

function PopUp_img(url, name, width,height,center,resize,scroll,posleft,postop) {
    if (posleft != 0) { x = posleft }
    if (postop  != 0) { y = postop  }

    if (!scroll) { scroll = 1 }
    if (!resize) { resize = 1 }

    if ((parseInt (navigator.appVersion) >= 4 ) && (center)) {
      X = (screen.width  - width ) / 2;
      Y = (screen.height - height) / 2;
    }
    if (scroll != 0) { scroll = 1 }

    var Win = window.open( "<img src='"+url+"' width="+width+" height="+height+">", name, 'width='+width+',height='+height+',top='+Y+',left='+X+',resizable='+resize+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no');
}

function openWinVar (imageName,imageWidth,imageHeight,alt) {
	newWindow = window.open ("","newWindow","width="+imageWidth+",height="+imageHeight);
	newWindow.document.open ( );
	newWindow.document.write ('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close( )">');
	newWindow.document.write ('<img src='+imageName+'  width='+imageWidth+' height='+imageHeight+' alt='+alt+'>');
	newWindow.document.write ('</body></html>');
	newWindow.document.close ( );
	newWindow.focus ( );
}
function TurnOn(imgName)
 {
   if (document.images)
    {
      imgOn=eval(imgName + "on.src");
      document[imgName].src= imgOn;
    }
 }
/*
function TurnOff(imgName)
 {
   if (document.images)
    {
      imgOff=eval(imgName + "off.src");
      document[imgName].src= imgOff;
    }
 }

  if (document.images)
   {
     prevon= new Image(76,19);
     prevon.src="images/laundry/prev_b_on.gif";  

     prevoff= new Image(76,19);
     prevoff.src="images/laundry/prev_b.gif";

     next_on= new Image(76,19);
     next_on.src="images/laundry/prev_b_on.gif";  

     next_off= new Image(76,19);
     next_off.src="images/laundry/prev_b.gif";
   }
*/
//-->
