t_browser=false
t_browserver=0
IE4=!!document.all
W3C=DOM=!!document.getElementById
NS4=!!document.layers
Mac=(navigator.appVersion.indexOf("Mac")!=-1)
if((i=navigator.userAgent.indexOf('Opera'))!=-1){
	t_browser='opera'
	t_browserver=parseFloat(navigator.userAgent.substr(i + 6, 3))
}else if((i=navigator.userAgent.indexOf('MSIE'))!=-1){
	t_browser='msie'
	t_browserver=parseFloat(navigator.userAgent.substr(i + 5, 3))
}else if((i=navigator.userAgent.indexOf('Gecko'))!=-1){
	t_browser='gecko'
	t_browserver=navigator.userAgent.substr(i + 6, 8)
}else if(NS4){
	t_browser='ns4'
}else if(navigator.userAgent.indexOf('Konqueror')!=-1){
	t_browser='konqueror'
}

m_xPos = new Array(421,321,690,550);
m_yPos = (NS4)?108:108;
m_ok=true
t_frys=false
t_luktimer=null
t_aaben=1
topZ=0
t_antal=2
t_contentW=780


function t_getelement(id){
	return W3C?document.getElementById(id):
		IE4?document.all[id]:
		NS4?document[id]:false;
}

function show(layernavn) {
var el = t_getelement(layernavn);
if(el)
	el.style.visibility="visible";
else
	document.layers[layernavn].visibility = "show";		
}

function hide(layernavn) {
var el = t_getelement(layernavn);
if(el)
	el.style.visibility="hidden";
else
	document.layers[layernavn].visibility = "hide";
}


function iknoget(){}

function t_offset(){
	var t_winW
	if(t_browser=='gecko')
		t_winW=document.body.offsetWidth
	else if(window.innerWidth)
		t_winW=window.innerWidth-(NS4&&!Mac?16:0)
	else if(document.body&&document.body.clientWidth)
		t_winW=document.body.clientWidth
	else
		t_winW=100
	
	return(t_winW<t_contentW)?0:Math.floor((t_winW-t_contentW)/2)
}


function t_over(){clearTimeout(t_luktimer)}

function t_ud(){
	if(!t_frys) {
		t_luktimer=setTimeout("t_luk("+t_aaben+")",500)
	}
}

function t_luk(id){
	clearTimeout(t_luktimer)
	t_flickmenu(id,false)
}

function t_flickmenu(id,vis){
	var t_offsetW=t_offset()
	var m=t_getelement("m"+id)
	if(NS4){
		m.moveTo(m_xPos[id-1]+t_offsetW,m_yPos)
		m.visibility=vis?"show":"hide"
	}else{
		m.style.left=m_xPos[id-1]+t_offsetW
		m.style.top=m_yPos
		m.style.visibility=vis?"visible":"hidden"
		m.style.zIndex=10000
	}
}

function t_popop(id){
	clearTimeout(t_luktimer)
	for(i=1;i<=t_antal;i++)
		t_flickmenu(i,i==id)
	t_aaben=id
	t_frys=false
}


opendir = '';


function main_selected(main_category) {
	var form = document.forms[0];

	var l = subcategories[main_category].length;

	form.sub_category.options.length = l;
	form.sub_category.selectedIndex = 0;
	if(l == 0) {
		form.sub_category.options[0] = new Option('Unfortunately no sub categories', 0);
	} else {
		for (i = 0; i < l; i++) {
			form.sub_category.options[0] = new Option('Please choose category', 0);
			var information = subcategories[main_category][i].split(":");
			var category_id = information[0];
			var category = information[1];
			form.sub_category.options[i + 1] = new Option(category, category_id);
		}
	}
	form.sub_category.selectedIndex = 0;
}


function sub_selected(sub_category) {
	var form = document.forms[0];
	for(i = 0 ; i < form.sub_category.options.length ; i++) {
		if(form.sub_category.options[i].value == sub_category) {
			form.sub_category.selectedIndex = i;
		}
	}
}


function winopen(windowURL,windowname,w,h){
popup = window.open(windowURL,windowname,"width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes");
popup.focus();
}


function validEmail(email) {
invalidChars = " /:,;"
if (email == "") {
    return false
}

for (i=0; i<invalidChars.length; i++) {
    badChar = invalidChars.charAt(i)
    if (email.indexOf (badChar,0) != -1) {
        return false
    }
}  // for (i=o.. 

atPos = email.indexOf ("@",1)

if (atPos == -1) {
    return false
}

if ( email.indexOf ("@", atPos+1) != -1) {
    return false
}
periodPos = email.indexOf (".", atPos)

if ( periodPos == -1) {
    return false
}

if ( periodPos+3 > email.length)    {
    return false
}
return true
}  // validEmail 


function CurrencyPopup(QueryString) {
    CurrencyWindow = window.open ('', 'CurrencyWindow', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=170,width=600')
    CurrencyWindow.focus()
    CurrencyWindow.location.href = 'http://www.xe.net/ecc/input.cgi?Template=sw&'+QueryString
}

function popImage(img) {
	titre='Jewelry and Gems';
	w=open('','image','width=535,height=335,toolbar=no,scrollbars=no,resizable=yes');	
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+12,document.images[0].height+30); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+img+"' border=0>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
}


function check4ciffers(tal) {
	if(Math.floor(tal) > 999 && Math.floor(tal) < 10000) {
		return true;
	} else {
		return false;
	}
}

function checkForm() {
	formen = document.checkout;
	message = '';
	if(formen.company.value == '') {
		message += "Name is compulsory\n";
	}
	if(formen.address.value == '') {
		message += "Address is compulsory\n";
	}
	if(formen.zipcode.value == '') {
		message += "Zipcode is compulsory\n";
	}
	if(formen.country.value == '') {
		message += "Country is compulsory\n";
	}
	if(formen.phone.value == '') {
		message += "Phone is compulsory\n";
	}
	if(formen.fax.value == '') {
		message += "Fax is compulsory\n";
	}
	if(formen.email.value == '') {
		message += "Email is compulsory\n";
	}

	

	if(message == '') {
		return true;
	} else {
		alert(message);
		return false;
	}
}

function changeTotal(val) {
	formen = document.checkout;
	formen.total.value = val;


}

function visa(opt) {
	if(opt == 1) {
		hide('switch');
		show('visa');
	} else {
		hide('visa');
		show('switch');
	}
}

function t_flickcredit(id,vis){
	var c=t_getelement("c"+id)
	if(NS4){
		m.visibility=vis?"show":"hide"
	} else {
		m.style.visibility=vis?"visible":"hidden"
	}
}

function t_closecredit(vis){
	for(i=1;i<=8;i++)
		t_flickcredit(i,vis)
	hide('visa');
	hide('switch');
}
