<!--
Event.observe(window,'load', check_jpg, false);

var tim;
var tim_halt;
var inter;			// holds the timer for the from\nt poage imager
var search_key;		// the contents of the search box are saved here and 
					// tested every poll to determine whether to fire
					// another db request
function check_jpg(){
clear_select();
if( $('productimage') )
	{
	if ( $('productimage').getWidth() >= $('productimage').getHeight() )
		{ 
			if ( $('productimage').getWidth() > 442 )
			{
				$('productimage').addClassName('toowide');		
				//alert( $('productimage').className );
			}
		}
		else
		{
			if ( $('productimage').getHeight() > 442 )
			{
				$('productimage').addClassName('tootall');
				//alert( $('productimage').className );
			}
		}
	}
}

function init(){
clearInterval( tim );
clearInterval( inter );
clearTimeout( tim_halt );
tim = setInterval('checkcode()', 10 );
}

function halt(){
	var stopper = clearInterval( tim );
	search_key = "";
	tim_halt = setTimeout('clear_select();', 2500);
}

function clear_select(){
	var ajax = new Ajax.Updater( {success: 'selcodes'}, 'null.asp', { method: 'get', parameters: ''} );
}

// new function to populate select object
function checkcode() {
if($F('code') == search_key ) return;
search_key = $F('code');


if($F('code').length < 2){ clear_select(); }
	
if($F('code').length >= 2) {
	var url = 'sp_search.aspx';
	var ajax = new Ajax.Updater(
		{success: 'selcodes'},
		url, {
				method: 'get', parameters:  $('frmsearch').serialize(true)});
		}
}


function testlog(){
	alert( "validating..." );
}


function ajax_submit()
{
var ajax = new Ajax.Updater(
	{success: 'selcart'},
	'addtocart.asp', {
			method: 'post', parameters: $('frmcart').serialize(true) 
			});

}



function showitem( id )
{
	var params = 'id=' + id;
	var ajax = new Ajax.Updater(
	
	{success: 'content'},
	'item.asp', {
			method: 'post', parameters: params
			});
	
}


// function for large cart windoww
function delete_viewitem( code ){
	var params = 'gpicode=' + code;
	var ajax = new Ajax.Updater( {success: 'selcart'}, 'delete_viewcartitem.asp', { method: 'post', parameters: params} );
}
//
function change_viewcartitem( code, obj ){
	var params = "";
	params = 'gpicode=' + code;
	params = params + '&amount=' + $(obj).value;
	var ajax = new Ajax.Updater( {success: 'selcart'}, 'change_viewcartitem.asp', { method: 'get', parameters: params} );
}





function delete_item( code ){
	var params = 'gpicode=' + code;
	var ajax = new Ajax.Updater( {success: 'selcart'}, 'delete_cartitem.asp', { method: 'post', parameters: params} );
}


function delete_cart(){
	var ajax = new Ajax.Updater( {success: 'selcart'}, 'clear_cart.asp', { method: 'post', parameters: ''} );
}

function change_cartitem( code, obj ){
	var params = "";
	params = 'gpicode=' + code;
	params = params + '&amount=' + $(obj).value;
	var ajax = new Ajax.Updater( {success: 'selcart'}, 'change_cartitem.asp', { method: 'get', parameters: params} );
}


function showcart( ){
	wcarter.close();
	var ajax = new Ajax.Updater( {success: 'selcart'}, 'update_cart.asp', { method: 'get', parameters: ''} );
}

function show_login()
{
	var ajax = new Ajax.Updater( 
								{success: 'logger'}, 
								'login.asp', 
								{ method: 'post', parameters: ''} );
}

function update_showitem( ){

	//if( $F('match') == 'no_match' )
	//{
	//	alert( "Login & Password don't match...");
	//}
	//else
	//{
		//
		var ajax = new Ajax.Updater( {success: 'content'}, 'update_showitem.asp', { } );
	//}
}
function update_unshowitem( ){
	
	alert( "YOU HAVE LOGGED OUT.");
	var ajax = new Ajax.Updater( {success: 'content'}, 'update_unshowitem.asp', { } );

}

function logout(){
	var ajax = new Ajax.Updater( {success: 'logger'}, 
								'logout.asp', 
								{	method: 'post', 
									onSuccess: function() { update_unshowitem();} 
								} );
}

//

function submitME(){ 
	var ajax = new Ajax.Updater( {success: 'logger'}, 
								'testlogin.asp', 
								{ 
								method: 'post', 
								parameters: $('frmlogin').serialize(true),
								onSuccess: function() { update_showitem();}
								} );
}




var wcarter; // variable to hold the address of our popup window.
function viewcart(){
	var sx = screen.width;
	var sy = screen.height;
	var	left = (sx-710)/2;
	var	top = (sy-530)/2;
wcarter = window.open( 'viewcart.asp', 'wcarter', 'width=710,height=530,left='+left+',top='+top+',scrollbars=yes,resizable=yes,menubar=no,url=no');
}


var helper; // variable to hold the address of our popup window.

function showhelp(){
	var sx = screen.width;
	var sy = screen.height;
	var	left = (sx-710)/2;
	var	top = (sy-530)/2;
helper = window.open( 'help.asp', 'helper', 'width=710,height=530,left='+left+',top='+top+',scrollbars=yes,resizable=yes,menubar=no,url=no');
}



//submits the finalise form after basic validation
function submitter()
{
// first validate inputs
var test = false;

	if ( $F('contact') == "" ){
		alert( "Contact needs to be entered. " );
		test = true;
		$('contact').activate();
	}else{
		if( $F('email')  == "" ){
			alert( "Email address needs to be entered. " );
			test = true;
			$('email').activate();
		}
	}
	
	if ( test == false )
	{
		
		var ajax = new Ajax.Updater( 
			{success: 'submitted'}, 
			'checkingout.asp', 
			{ method: 'post', parameters: $('frmcheckout').serialize(true), 
			onSuccess: function() { update_showitem_fake();} 
			} );		
		
	} else {
		$('submitted').innerHtml = "Sorry, one or more fields are missing!";
	}
}

function update_showitem_fake(){
	$('desc').innerHTML = "<p><h1>Your order has been submitted and your shopping cart has been emptied.</h1></p><br /><br /><br />";
}


function swallow(){ return false; } // null function
-->
