//Start of date stamp code

function date() {

var days = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

var now = new Date();
var yy = now.getYear();
if(yy < 2000) yy +=1900;
var mm = now.getMonth();
mm = months[mm];
var dd = now.getDate();
var dy = now.getDay();
dy = days[dy];

var notation = "not_set";

if((dd == 1) || (dd == 21) || (dd == 31)) {
	notation = "st";
}

if((dd == 2) || (dd == 22)) {
	notation = "nd";
}

if((dd == 3) || (dd == 23)) {
	notation = "rd";
}

if(notation == "not_set") {
	notation = "th";
}


	

return(dd + notation +" " + mm + " " + yy ); 



}


//AJAX

// AJAX Framework Version 2.0
// Copyright 2005 Jason Graves (GodLikeMouse)
// This file is free to use and distribute under the GNU open source
// license so long as this header remains intact.
// For more information please visit http://www.godlikemouse.com
// To have changes incorporated into the AJAX Framework please contact godlikemouse@godlikemouse.com
// Supported Browsers: IE 6.0+, Opera 8+, Mozilla based browsers 

var GLM = {
    DOM:        Object,
    AJAX:       Object,
    Collection: Object
};

/************************************/
/* GLM.DOM                          */
/************************************/

/// <name>GLM.DOM.isInternetExplorer</name>
/// <summary>Boolean variable for determining if the client browser is Internet Explorer.</summary>
/// <returns>True if the client browser is Internet Explorer, otherwise false</returns>
/// <example>if(GLM.DOM.isInternetExplorer){
///     alert("You're using IE");
/// }</example>
GLM.DOM.isInternetExplorer = (navigator.userAgent.indexOf("MSIE") >= 0);

/// <name>GLM.DOM.isMozilla</name>
/// <summary>Boolean variable for determining if the client browser is Mozilla.</summary>
/// <returns>True if the client browser is Mozilla, otherwise false</returns>
/// <example>if(GLM.DOM.isMozilla){
///     alert("You're using Mozilla");
/// }</example>
GLM.DOM.isMozilla = (navigator.userAgent.indexOf("Gecko") >= 0);

/// <name>GLM.DOM.isOpera</name>
/// <summary>Boolean variable for determining if the client browser is Opera.</summary>
/// <returns>True if the client browser is Opera, otherwise false</returns>
/// <example>if(GLM.DOM.isOpera){
///     alert("You're using Opera");
/// }</example>
GLM.DOM.isOpera = (navigator.userAgent.indexOf("Opera") >= 0);


/************************************/
/* GLM.Collection                   */
/************************************/

/// <name>GLM.Collection.Map</name>
/// <summary>Map class for holding key value pairs.</summary>
/// <returns>The new GLM.Collection.Map object.</returns>
/// <example>var m = new GLM.Collection.Map();
/// m.add("name1","value1");
/// m.add("name2","value2");
/// alert( m.get("name1") ); //alerts "value1"</example>
GLM.Collection.Map = function(){
    var len = 0;
    var keys = new Array();
    var values = new Array();

    /// <name type="function">GLM.Collection.Map.get</name>
    /// <summary>Method for returning the value associated with a key.</summary>
    /// <param name="key">The key to return the associated value of.</param>
    /// <returns>The value associated with the key.</returns>
    /// <example>var m = new GLM.Collection.Map();
    /// m.add("name1","value1");
    /// m.add("name2","value2");
    /// alert( m.get("name1") ); //alerts "value1"</example>
    this.get = function(key){
        var val = null;
        for(var i=0; i<len; i++){
            if(keys[i] == key){
                val = values[i];
                break;
            }//end if
        }//end for

        return val;
    }//end get()

    /// <name type="function">GLM.Collection.Map.put</name>
    /// <summary>Method for storing an associated key value.</summary>
    /// <param name="key">The key to associate with the value.</param>
    /// <param name="value">The value associated with the key.</param>
    /// <example>var m = new GLM.Collection.Map();
    /// m.add("name1","value1");
    /// m.add("name2","value2");
    /// alert( m.get("name1") ); //alerts "value1"</example>
    this.put = function(key, value){
        keys[len] = key;
        values[len++] = value;
    }//end put()

    /// <name type="function">GLM.Collection.Map.length</name>
    /// <summary>Method for returning the count of items in the map.</summary>
    /// <returns>The count of items in the map.</returns>
    /// <example>var m = new GLM.Collection.Map();
    /// m.add("name1","value1");
    /// m.add("name2","value2");
    /// alert( m.length ); //alerts 2</example>
    this.length = function(){
        return len;
    }//end length()

    /// <name type="function">GLM.Collection.Map.contains</name>
    /// <summary>Method for determining if the map contains a specific key.</summary>
    /// <param name="key">The key to search for.</param>
    /// <returns>True if the map contains the key, otherwise false.</returns>
    /// <example>var m = new GLM.Collection.Map();
    /// m.add("name1","value1");
    /// m.add("name2","value2");
    /// alert( m.contains("name1") ); //alerts true</example>
    this.contains = function(key){
	var con = false;
        for(var i=0; i<len; i++){
            if(keys[i] == key){
                con = true;
                break;
            }//end if
        }//end for

	return con;
    }//end contains()

    /// <name type="function">GLM.Collection.Map.remove</name>
    /// <summary>Method for removing a key value pair by key name.</summary>
    /// <param name="key">The key to search for.</param>
    /// <example>var m = new GLM.Collection.Map();
    /// m.add("name1","value1");
    /// m.add("name2","value2");
    /// m.remove("name1");
    /// alert( m.contains("name1") ); //alerts false</example>
    this.remove = function(key){
        var keyArr = new Array();
        var valArr = new Array();
        var l = 0;
        for(var i=0; i<len; i++){
            if(keys[i] != key){
                keyArr[l] = keys[i];
                valArr[l++] = values[i];
            }//end if
        }//end for

        keys = keyArr;
        values = valArr;
	len = l;
    }//end remove()        
    
}//end GLM.Collection.Map

/************************************/
/* GLM.AJAX                         */
/************************************/

/// <name>GLM.AJAX</name>
/// <summary>Class for performing AJAX.<br/>
/// Developer Note: .NET WebService Methods must be tagged with [SoapRpcMethod, WebMethod] for parameters to be passed using Mozilla based browsers.</summary>
/// <returns>The new GLM.AJAX object.</returns>
/// <example>var ajax = new GLM.AJAX();
/// 
/// function ajaxCallback(content){
///     alert(content); //displays the contents of the page.
/// }
///
/// ajax.callPage("myPage.html", ajaxCallback); //call myPage.html and pass the contents to ajaxCallback.</example>
GLM.AJAX = function(){

    var nameSpace = "http://tempuri.org/";
    var map = new GLM.Collection.Map();
    
    //private method for returning an ajax enabled
    //object specific to a browser
    var ajaxObject = function(){
        try{return new XMLHttpRequest();}catch(ex){};
        try{return new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){};
        try{return new SOAPCall();}catch(ex){};
    }//end ajaxObject()
    
    /// <name type="function">GLM.AJAX.onError</name>
    /// <summary>Method for handling ajax errors.</summary>
    /// <example>var ajax = new GLM.AJAX();
    /// 
    /// function ajaxCallback(content){
    ///         alert(content); //displays the contents of the page
    /// }
    ///
    /// function ajaxError(error){
    ///         alert(error); //alert the error
    /// }
    ///
    /// ajax.onErrror = ajaxError; //assign error handler
    /// ajax.callPage("myPage.html", ajaxCallback); //call myPage.html and pass the contents to ajaxCallback</example>
    this.onError = function(error){
        alert(error);
    }//end onError()

    /// <name type="function">GLM.AJAX.callPage</name>
    /// <summary>Method for calling a page using AJAX.</summary>
    /// <param name="url">The url of the page to call.</param>
    /// <param name="callbackFunction">The function to call when the AJAX call succeeds.</param>
    /// <example>var ajax = new GLM.AJAX();
    /// 
    /// function ajaxCallback(content){
    ///         alert(content); //displays the contents of the page.
    /// }
    ///
    /// ajax.callPage("myPage.html", ajaxCallback); //call myPage.html and pass the contents to ajaxCallback.</example>
    this.callPage = function(url, callbackFunction){        
        try{
            var ao = ajaxObject();
            ao.onreadystatechange = function(){
                if(ao.readyState==4 || ao.readyState=="complete"){
                    callbackFunction(ao.responseText);
                }
            };
            
            ao.open("GET", url, true);
            ao.send(null);
        }
        catch(ex){
            this.onError(ex);
        }//end tc
    }//end callPage()
	

    /// <name type="function">GLM.AJAX.callService</name>
    /// <summary>Method for calling a webservice using AJAX.</summary>
    /// <param name="serviceUrl">The url of the service to call.</param>
    /// <param name="soapMethod">The method of the service to call.</param>
    /// <param name="callbackFunction">The function to call when the AJAX call succeeds.</param>
    /// <param name="param1, param2 ... paramN">Optional parameters passed to the webservice.  Parameters must be in the 
    /// form of "name=value".</param>
    /// <example>var ajax = new GLM.AJAX();
    /// 
    /// function ajaxCallback(content){
    ///         alert(content); //displays the contents of the page.
    /// }
    ///
    /// ajax.callPage("myService.asmx", "myMethod", ajaxCallback); //call myService.asmx and pass the contents to ajaxCallback.</example>
    this.callService = function(serviceUrl, soapMethod, callbackFunction /*, unlimited params */){
        
        var callServiceError = this.onError;
        
        var ao = ajaxObject();
        
        if(GLM.DOM.isInternetExplorer){
            if(serviceUrl.indexOf("http://") < 0)
                serviceUrl = "http://" + serviceUrl;
            serviceUrl += "?WSDL";
            
            var soapEnvelope = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
            soapEnvelope += "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
            soapEnvelope += "<soap:Body>";
            soapEnvelope += "<" + soapMethod + " xmlns=\"" + nameSpace + "\">";
            
            if(arguments.length > 3){
                for (var i = 3; i < arguments.length; i++)
                {
                    var params = arguments[i].split("=");
                    soapEnvelope += "<" + params[0] + ">";
                    soapEnvelope += params[1];
                    soapEnvelope += "</" + params[0] + ">";
                }//end for
            }//end if
			
            soapEnvelope += "</" + soapMethod + ">";
            soapEnvelope += "</soap:Body>";
            soapEnvelope += "</soap:Envelope>";
			
            
            
            ao.onreadystatechange = function(){
                
                if(ao.readyState == 4){
                    
                    if(GLM.DOM.IsOpera){
                        //opera
                        var response = ao.responseXML.getElementsByTagName(soapMethod + "Result")[0];
                        if(!response)
                            response = ao.responseXML.getElementsByTagName(soapMethod + "Response")[0];
                        if(!response){
                            callServiceError("WebService does not contain a Result/Response node");
                            return;
                        }//end if
                        
                        ao.callbackFunction(ao.responseXML.getElementsByTagName(soapMethod + "Result")[0].innerHTML);
                    }
                    else if(GLM.DOM.isInternetExplorer){
                        //IE
                        var responseXml = new ActiveXObject('Microsoft.XMLDOM');
                        responseXml.loadXML(ao.responseText);
                            
                        var responseNode = responseXml.selectSingleNode("//" + soapMethod + "Response");
                        if(!responseNode)
                            responseNode = responseXml.selectSingleNode("//" + soapMethod + "Result");
                        if(!responseNode)
                            callServiceError("Response/Result node not found.\n\nResponse:\n" + ao.responseText);
                            
                        var resultNode = responseNode.firstChild;
                        if (resultNode != null){
                            try{
                                callbackFunction(resultNode.text);
                            }
                            catch(ex){
                                callServiceError(ex);
                            }//end tc
                        }
                        else{
                            try{
                                callbackFunction();
                            }
                            catch(ex){
                                callServiceError(ex);
                            }//end tc
                        }//end if
                    }//end if
                }//end if
            };
            
            ao.open("POST", serviceUrl, true);			
            ao.setRequestHeader("Content-Type", "text/xml");
            ao.setRequestHeader("SOAPAction", nameSpace + soapMethod);
            try{
                ao.send(soapEnvelope);
            }
            catch(ex){
                serviceCallError(ex);
            }//end tc
        }
        else{
            var soapParams = new Array();
            var headers = new Array();
            var soapVersion = 0;
            var object = nameSpace;
            
            if(serviceUrl.indexOf("http://") < 0)
                serviceUrl = document.location + serviceUrl;
            
            ao.transportURI = serviceUrl;
            ao.actionURI = nameSpace + soapMethod;
            
            for(var i=3; i<arguments.length; i++){
                var params = arguments[i].split("=");
                soapParams.push( new SOAPParameter(params[1],params[0]) );
            }//end for
            
            try{
                ao.encode(soapVersion, soapMethod, object, headers.length, headers, soapParams.length, soapParams);
            }
            catch(ex){
                serviceCallError(ex);
            }//end tc
		
            try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
            } 
            catch(ex){
                return false;
            }//end tc
            
            try{
                ao.asyncInvoke(
                    function(resp,call,status){

                    if(resp.fault)
                        return callServiceError(resp.fault);
                    if(!resp.body){
                        callServiceError("Service " + call.transportURI + " not found.");
                    }
                    else{
                        try{
                            callbackFunction(resp.body.firstChild.firstChild.firstChild.data);
                        }
                        catch(ex){
                            callServiceError(ex);
                        }//end tc
                    }//end if
                }
                );
            }
            catch(ex){
                serviceCallError(ex);
            }//end tc
                        
        }//end if
		
    }//end callService()
	
    /// <name type="function">GLM.AJAX.setNameSpace</name>
    /// <summary>Method for setting the name space of the service call.</summary>
    /// <param name="ns">The service name space.</param>
    /// <example>var ajax = new GLM.AJAX();
    /// 
    /// function ajaxCallback(content){
    /// alert(content); //displays the contents of the page.
    /// }
    ///
    /// ajax.setNameSpace("mynamespace");
    /// ajax.callPage("myService.asmx", "myMethod", ajaxCallback); //call myService.asmx and pass the contents to ajaxCallback</example>
    this.setNameSpace = function(ns){
        nameSpace = ns;
    }//end setNameSpace()
	
    /// <name type="function">GLM.AJAX.getNameSpace</name>
    /// <summary>Method for returning the name space of the service call.</summary>
    /// <returns>The namespace of the service call.</returns>
    /// <example>var ajax = new GLM.AJAX();
    /// 
    /// function ajaxCallback(content){
    /// alert(content); //displays the contents of the page.
    /// }
    ///
    /// var ns = ajax.getNameSpace(); //returns the name space
    /// ajax.callPage("myService.asmx", ajaxCallback); //call myService.asmx and pass the contents to ajaxCallback</example>
    this.getNameSpace = function(){
        return ns;
    }//end getNameSpace()
	
}//end GLM.AJAX()

// xp_progressbar
// Copyright 2004 Brian Gosselin of ScriptAsylum.com
//
// v1.0 - Initial release
// v1.1 - Added ability to pause the scrolling action (requires you to assign
//        the bar to a unique arbitrary variable).
//      - Added ability to specify an action to perform after a x amount of
//      - bar scrolls. This requires two added arguments.
// v1.2 - Added ability to hide/show each bar (requires you to assign the bar
//        to a unique arbitrary variable).

// var xyz = createBar(
// total_width,
// total_height,
// background_color,
// border_width,
// border_color,
// block_color,
// scroll_speed,
// block_count,
// scroll_count,
// action_to_perform_after_scrolled_n_times
// )

var w3c=(document.getElementById)?true:false;
var ie=(document.all)?true:false;
var N=-1;

function createBar(w,h,bgc,brdW,brdC,blkC,speed,blocks,count,action){
if(ie||w3c){
var t='<div id="_xpbar'+(++N)+'" style="visibility:visible; position:relative; overflow:hidden; width:'+w+'px; height:'+h+'px; background-color:'+bgc+'; border-color:'+brdC+'; border-width:'+brdW+'px; border-style:solid; font-size:1px;">';
t+='<span id="blocks'+N+'" style="left:-'+(h*2+1)+'px; position:absolute; font-size:1px">';
for(i=0;i<blocks;i++){
t+='<span style="background-color:'+blkC+'; left:-'+((h*i)+i)+'px; font-size:1px; position:absolute; width:'+h+'px; height:'+h+'px; '
t+=(ie)?'filter:alpha(opacity='+(100-i*(100/blocks))+')':'-Moz-opacity:'+((100-i*(100/blocks))/100);
t+='"></span>';
}
t+='</span></div>';
document.write(t);
var bA=(ie)?document.all['blocks'+N]:document.getElementById('blocks'+N);
bA.bar=(ie)?document.all['_xpbar'+N]:document.getElementById('_xpbar'+N);
bA.blocks=blocks;
bA.N=N;
bA.w=w;
bA.h=h;
bA.speed=speed;
bA.ctr=0;
bA.count=count;
bA.action=action;
bA.togglePause=togglePause;
bA.showBar=function(){
this.bar.style.visibility="visible";
}
bA.hideBar=function(){
this.bar.style.visibility="hidden";
}
bA.tid=setInterval('startBar('+N+')',speed);
return bA;
}}

function startBar(bn){
var t=(ie)?document.all['blocks'+bn]:document.getElementById('blocks'+bn);

if(t)
{

	if(parseInt(t.style.left)+t.h+1-(t.blocks*t.h+t.blocks)>t.w){
	t.style.left=-(t.h*2+1)+'px';
	t.ctr++;
	if(t.ctr>=t.count){
	eval(t.action);
	t.ctr=0;
	}}else t.style.left=(parseInt(t.style.left)+t.h+1)+'px';
}
}

function togglePause(){
if(this.tid==0){
this.tid=setInterval('startBar('+this.N+')',this.speed);
}else{
clearInterval(this.tid);
this.tid=0;
}}

function togglePause(){
if(this.tid==0){
this.tid=setInterval('startBar('+this.N+')',this.speed);
}else{
clearInterval(this.tid);
this.tid=0;
}}

function buildCart()
{
	//document.getElementById('shopping_cart_loading').style.display = 'block';
	//document.getElementById('shopping_cart_holder').style.display = 'none';
	//var ajax = new GLM.AJAX();
	//ajax.callPage("/shopping_cart.php?", deliverCart);
}

tim = 0;
count = 0;
resp = '';

function deliverCart(response)
{
	if(response != "" && response	) resp = response;
	if(count == 1)
	{
		document.getElementById('shopping_cart_loading').style.display = 'none';
		document.getElementById('shopping_cart_holder').style.display = 'block';
		document.getElementById('shopping_cart_holder').innerHTML = resp;
		
		window.clearTimeout(tim);
		count = 0;
		
	}else{
		count = count + 1;
		tim = window.setTimeout('deliverCart();', 750);
	}
}

var active;
var contacts_active;

function addToCart(item_id,contacts)
{
	var lense_option;
	var colour_choice;
	var select_size;
	var number;
	
	if(!contacts)
	{
		lense_option = document.getElementById('select_lense_options').value;
		
		colour_index = document.getElementById('colour_choice').selectedIndex;
		
		
		colour_choice = document.getElementById('colour_choice').options[colour_index].text;
		select_size = document.getElementById('select_size').value;
	}else{
		number = document.getElementById('number').value;
	}
	
	alert_message = "";
	if(!contacts)
	{
		if(lense_option == "") alert_message += "Please select a lense type\n";
		if(colour_choice == "") alert_message += "Please select a colour\n";
		if(select_size == "") alert_message += "Please select a size\n";
		
		if(alert_message != "")
		{
			alert('You have not selected all options:\n\n' + alert_message);
			return;
		}
	}
	
	contacts_send = 0;
	
	if(contacts) contacts_send = 1;
	
	contacts_active = false;
	
	if(contacts) contacts_active = true;
	
	
	active = item_id;
	var ajax = new GLM.AJAX();
	ajax.callPage("/cart_process.php?mode=add&id=" + item_id + "&lense_option=" + lense_option + "&colour_choice=" + colour_choice + "&size=" + select_size + "&contacts=" + contacts_send + "&number=" + number, completeAddition);
	
	//document.getElementById('basketFloat').style.display = 'block';
}

function removeFromCart(item_id)
{
	if(confirm('Are you sure you wish to remove this item from your shopping cart?'))
	{
		active = item_id;
		var ajax = new GLM.AJAX();
		ajax.callPage("/cart_process.php?mode=remove&id=" + item_id, completeAddition);
		
		//document.getElementById('basketFloat').style.display = 'block';
	}
}

function completeAddition(response)
{
	element = document.getElementById(active);
	
	if(element)
	{
		switch(response)
		{
			case 'add':
				element.innerHTML = '<a href="javascript: removeFromCart('+ active +');">Remove from basket</a>';
			break;
			
			case 'remove':
				if(!contacts_active)
				{
					element.innerHTML = '<a href="javascript: addToCart('+ active +', false);">Add to basket</a>';
				}else{
					element.innerHTML = '<a href="javascript: addToCart('+ active +', true);">Add to basket</a>';
				}
			break;
			
			default:
				alert('An error occured and we were unable to process your request');
			break;
		}
	}
	active = false;
	
	buildCart();
}

function login()
{
	var user_name = document.getElementById('user_name').value;
	var password = document.getElementById('password').value;

	if(user_name == "" || password == "") 
	{
		alert('Please provide a user name and password to login!'); 
		return false;
	}
	document.getElementById('login_loading_bar').style.display = 'block';
	var ajax = new GLM.AJAX();
	ajax.callPage("/login.php?user_name=" + user_name + "&password=" + password, completeLogin);

}


function completeLogin(response)
{
	if(document.getElementById('login_loading_bar'))
	{
		document.getElementById('login_loading_bar').style.display = 'none';
	}
	if(response == "error")
	{
		alert('Your username or password was incorrect');
	}else{
		if(response == "" || response == "valid")
		{
			var ajax = new GLM.AJAX();
			ajax.callPage("/build_admin.php", buildAdmin);
		}
	}
}

admin_on = false;

function buildAdmin(response)
{
	if(document.getElementById('login_panel') && response != "error")
	{
		document.getElementById('login_panel').innerHTML = response;
		buildShop();
		admin_on = true;
	}
}

var active_edit;

function updateText(id, x, mode)
{
	active_edit = x;
	
	document.getElementById('message_' + active_edit).innerHTML = "";
	
	var send_title = document.getElementById('name_' + x).value;
	var send_text = document.getElementById('desc_' + x).value;
	var send_price = document.getElementById('price_' + x).value;
	
	if(document.getElementById('no_lenses_' + x))
	{
		var send_no_lenses = document.getElementById('no_lenses_' + x).checked;
		
		if(send_no_lenses == true)
		{
			send_no_lenses = 1;
		}else{
			send_no_lenses = 0;
		}
	}
	
	if(document.getElementById('make_' + x))
	{
		var send_make = document.getElementById('make_' + x).value;
	}
	
	alert_string = "";
	
	if(send_title == "") alert_string += "Please provide a TITLE\n";
	if(send_text == "") alert_string += "Please provide a DESCRIPTION\n";
	if(send_price == "") alert_string += "Please provide a PRICE\n";
	
	if(alert_string != "")
	{
		alert('Your form is not you complete\n\n' + alert_string);
		return false;
	}else{
		if(document.getElementById('loading_'+ x))
		{
			document.getElementById('loading_'+ x).style.display = 'block';
		}
		
		
		var ajax = new GLM.AJAX();
		ajax.callPage("update_item.php?mode=" + mode + "&id=" + id + "&name=" + send_title + "&desc=" + send_text + "&price=" + send_price + "&make=" + send_make + '&no_lenses=' + send_no_lenses, finishUpdate);
	}
}

function finishUpdate(response)
{
	if(document.getElementById('loading_'+ active_edit))
	{
		document.getElementById('loading_'+ active_edit).style.display = 'none';
	}
	
	
	if(response == "success")
	{
		document.getElementById('message_' + active_edit).innerHTML = "Updated Successfully";
		admin_on = false;
		buildShop('1');
	}else{
		alert('An error occured, please try again' + response);
	}
	
	active_edit = null;
}

function buildShop(admin)
{
	var addition = "";
	if(admin)
	{
		addition = "?admin=true";
	}
	
	if(!admin_on)
	{
	
		var ajax = new GLM.AJAX();
		ajax.callPage("shop_contents.php" + addition, writeShop);
			
	}
}

function writeShop(response)
{
	document.getElementById('buy_online_content').innerHTML = response;
	completeLogin('valid');

}

function logout()
{
	var ajax = new GLM.AJAX();
	admin_on = false;
	ajax.callPage("logout.php", buildShop);
}

function uploadImage(id, x)
{

window.open('upload_image.php?id=' + id + "&x=" + x, 'test', 'height=200,width=400,scrollbars=yes');
}


function changePrices(id, x)
{

window.open('change_prices.php?id=' + id + "&x=" + x, 'test', 'height=200,width=400,scrollbars=yes');
}

function sizingHelp()
{
	window.open('/images/sizing_help.jpg', 'test', 'height=250,width=380,scrollbars=yes');
}

function changeSizes(id, x)
{

window.open('change_sizes.php?id=' + id + "&x=" + x, 'test', 'height=500,width=400,scrollbars=yes');
}

function newItem()
{
	document.getElementById('shop_item_new').style.display = 'block';
}

function cancelItem()
{
	document.getElementById('shop_item_new').style.display = 'none';
}

function deleteItem(id)
{
	if(confirm('Are you sure you wish to delete this item?  This action is ireverisble'))
	{
		var ajax = new GLM.AJAX();
		ajax.callPage("delete.php?id=" + id, completeDelete);
	}
}

function completeDelete(response)
{
	if(response != "")
	{
		alert(response);
	}
	admin_on = false;
	buildShop('1');
}

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function showBasket()
{
	current = document.getElementById('basketFloat').style.display;
	
	//document.getElementById('basketFloat').style.left = (document.body.offsetWidth / 2 ) - document.getElementById('basketFloat').style.width + "px";
	
	if(current == "block")
	{
		document.getElementById('basketFloat').style.display = 'none';
	}else{
		document.getElementById('basketFloat').style.display = 'block';
	}
}

function showPreview(id)
{
	document.location.href = "preview.php?id=" + id;
}

function backup()
{
	window.open('/backup.php', 'backup', 'width=500, height=250');
}
