//Change images
function change_preview_image(file_name) {
	document.images['preview'].src = file_name;
}

function unselect_thumbs() {
	var elms = document.getElementsByTagName('*'); // * = all tagNames 
	
	for(var k=0;k<elms.length;k++) {
		if (elms[k].id.indexOf('THUMB_') >= 0) {
			elms[k].className = 'thumb-notselected';
		}
	}
}

function select_thumb(theid) {
	if (document.getElementById) {
		var switch_id = document.getElementById(theid);
		switch_id.className = 'thumb-selected';
	}
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=1,resizable=0,width=350,height=250');");
}

function popUpBB(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=1,resizable=0,width=350,height=350');");
}

function popUpWin(URL, width, height) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=1,resizable=0,width=" + width + ",height=" + height + "');");
}

function changePage(newLoc) {
	nextPage = newLoc.options[newLoc.selectedIndex].value
	
	if (nextPage != "") {
		document.location.href = nextPage
	}
}

var basicfunc ={
	'a.confirm' : function(element){
		element.onclick = function(){
			if (!confirm('Are you sure you want to delete this?')) return false; 
			// It's always a good idea to give people a second chance to undo a destroying action
		}
	}
}

Behaviour.register(basicfunc);


var finito = true; // our fuse variable
 
function beforeStartCallMe(obj) { // this gives you the div object obj.
        finito = false; // we started an Effect.
}
 
function afterFinishCallMe(obj) {
        finito = true; // the effect is finished.
        if($('checkMeToSeHiddenFields').checked == false) { // if checked.
                if($('shippinginfo').visible() == true) { // and div not visible
                        Effect.Appear('shippinginfo', {beforeStart: beforeStartCallMe, afterFinish: afterFinishCallMe, duration: 0});
						Effect.Fade('shippinginfomsg', {duration: 0});
                }
        } else {
                if($('shippinginfo').visible()) { // if visible div but not checked checkbox
                        Effect.Fade('shippinginfo', {beforeStart:beforeStartCallMe, afterFinish: afterFinishCallMe, duration: 0});
						Effect.Appear('shippinginfomsg', {duration: 0});
                }
        }
}
 
function toggleSomeEffect() {
        if($('checkMeToSeHiddenFields').checked == false) {           
                if($('shippinginfo').visible()) {
                } else {
                        if(finito) {
                                Effect.Appear('shippinginfo', {beforeStart: beforeStartCallMe, afterFinish: afterFinishCallMe, duration: 0});
								Effect.Fade('shippinginfomsg', {duration: 0});
                        }
                }
        } else {
                if($('shippinginfo').visible() && finito) {
                        Effect.Fade('shippinginfo', {beforeStart: beforeStartCallMe, afterFinish: afterFinishCallMe, duration: 0});
						Effect.Appear('shippinginfomsg', {duration: 0});
                }
        }
}
