addEvent(window,'load',Initialize)
addEvent(document,'keydown',checkKeycode)

function Initialize() {
	var showMenu=false
	if(get('wrapGL')) {
		var brands=getByTag('wrapGL','a')
		for(i=0;i<brands.length;i++) {
			if(brands[i].getAttribute('rel') && brands[i].getAttribute('rel').indexOf('models')!=-1) {
				if(brands[i].getAttribute('type') && brands[i].getAttribute('type')=='current') setStyle(get('model'+brands[i].getAttribute('rel').replace('models:','')),'display','block')
				brands[i].onclick=function() {
					if(get('model'+this.getAttribute('rel').replace('models:',''))) {
						target=get('model'+this.getAttribute('rel').replace('models:',''))
						if(typeof target == 'object') {
							setStyle(target,'display',target.style.display != 'block' ? 'block' : 'none')
							return false
						}
					} else return false
				}
			}		
		}
	}
	var links=getByTag('main','a')
	for(i=0;i<links.length;i++) {
		if(links[i].getAttribute('rel') && links[i].getAttribute('rel').indexOf('show')!=-1) {
			var targetM=get(links[i].getAttribute('rel').replace('show:',''))
			
			targetM.onmouseover=function() {
				showMenu=true
				handleMenu()
			}
			targetM.onmouseout=function() {
				showMenu=false
				handleMenu()
			}
			
			pos=getPosition(links[i])
			
			setStyles(targetM,{
				'top':pos[1]+links[i].offsetHeight,
				'left':pos[0]
			})
			links[i].onmouseover=function() {
				showMenu=true
				handleMenu()				
			}
			links[i].onmouseout=function() {
				showMenu=false
				handleMenu()
			}
		}		
	}
	function handleMenu() {
		if(showMenu==false) state='none'
		else state='block'
		setStyle(targetM,'display',state)
	}
	preparePhotoEffects()
	if(IE6) iePNGFix()
}
