var curSel="0";
var catSel="0";
var speed=3;
var sorty='price';
var imgsize='big';
var catid ='smashers';
var prodperpage = '10';
var product=0;
var pgnumber = '1';
var showy='all';
var timeout;
var inter;
var slidepos=0;
var going=1;
var filtertypeid=0;
var categshow='normal';
var prodshow='all';
var tempX = 0;
var tempY = 0;
var bannerid = 1;
var banner_moving=0;
var banner="";
var banner_cycle=1;
var prevbanner=0;
var submenu_name = "";
var submenu_direction = "down";
var submenu_moving = 0;
var submenu_cycle = 1;
var submenu_height=0;
var isSafari=false;
var brand_scrollstartpos=0;
var brand_scrollendpos=0;
var brand_scrolldirection="";
var brand_scrollmoving=0;
var brand_scrollcycle=1;
var brand_scrollpulse=150;
var brand_pageno = 1;
var fade = 0;
var fade_cycle = 1;
var fade_name = 1;
var vendor = navigator.vendor || "";
var auctionrefresh=0;

bannertime = setTimeout('setInter()',500);			
clearTimeout(bannertime);

if (vendor.indexOf("Apple Computer, Inc.") > -1) {
	isSafari = true;
}

var IE = document.all?true:false
	
function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  return true;
}
	
Event.observe(window, 'load', function() {
	document.onmousemove = getMouseXY;
	setInterval('autoslide()', 50);
	setInterval('fadeNews()' ,4500);
	submenu_direction = "start";
	submenu_moving = 1;
	changetitle();
	
	var twitter_JSON = document.createElement("script");
 	twitter_JSON.type="text/javascript"
 	twitter_JSON.src="http://twitter.com/statuses/user_timeline/klikk_Store.json?callback=twitter_callback&count=5"
 	document.getElementsByTagName("head")[0].appendChild(twitter_JSON);
	//google analytics
});

iens6=document.all||document.getElementById;
ns4=document.layers;		

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	// Return top position
	return oTop
}

function Refresh(){
	var myAjax = new Ajax.Updater('ProductListing','index.php', {method: 'get', parameters:'sort='+sorty+'&imgsize='+imgsize+'&catid='+catid+'&prodperpage='+prodperpage+'&pgnumber='+pgnumber+'&show='+showy});
}

function resize_topban(){
	var found=0;
	document.getElementById('ProductListing').style.height="auto";
	topban = document.getElementById('ProductListing').offsetHeight+5;
	if (topban>1150){	
		document.getElementById('closure').style.top=topban+"px";
		document.getElementById('left').style.height = (topban+450)+"px"; 
		document.getElementById('right').style.height = (topban+450)+"px"; 
	}	
	
	if (document.getElementById('filtermain')){
		for(x=1;x<6;x++){
			if (document.getElementById('filterbox'+x)){
				found=found+1;
			}
		}
	
		if (found==1) {
			startpt=240;
		}else if(found==2){
			startpt=180;
		}else if(found==3){
			startpt=120;
		}else if(found==4){
			startpt=60;
		}else{
			startpt=0;
		}
		
		for (x=1;x<found+1;x++){
			document.getElementById('filterbox'+x).style.left=startpt+"px";
			if(document.getElementById('filterresult'+x)){
				document.getElementById('filterresult'+x).style.left=startpt+"px";	
			}
			startpt=startpt+120;
		}
	}
	document.getElementById('hidebox').style.visibility="hidden";
	document.getElementById('WaitMessage').style.visibility="hidden";
}

function goback_search(searchstr,pgnum){
	pgnumber=pgnum;
	sndReq(searchstr);
}

function goback(catname, backfilter){
	if(isSafari==true){
		window.location.href = "/index.php";
	}else{
		history.back();
	}
}

function homeClick(){
	window.location.href = "/index.php";
}

function Open(objectId){
	var openedDiv = ReturnOpenedDiv();
	var object = document.getElementById(objectId);
	if(openedDiv == objectId){
		object.style.display = "none";								
	}
	else{
		CloseDivs();
		object.style.display = "block";
	}
}

function ReturnOpenedDiv(){
	var allDivs = new Array("mc", "rl", "bp", "dr", "os","pp","dy");
	var openedDiv = null;
	for(var i = 0; i < allDivs.length; i++){
		if(document.getElementById(allDivs[i]).style.display == "block"){
			openedDiv = allDivs[i];
		}
	}
	return openedDiv;
}

function CloseDivs(){
	var allDivs = new Array("mc", "rl", "bp", "dr", "os","pp","dy");
	for(var i = 0; i < allDivs.length; i++){
		document.getElementById(allDivs[i]).style.display = "none";
	}
}

function supportClick(type){
	if(type=='contact'){
		window.location.href = "mailto:support@klikk.com.mt";
	}else{
		window.location.href = "http://www.klikk.com.mt/support_technical.php";
	}
}

function aboutClick(type){
	if (type=="location" || type=="hours"){
		window.location.href = "http://www.klikk.com.mt/support_location.php";
	}else if(type=='online'){
		window.location.href = "http://www.klikk.com.mt/support_onlineorder.php";
	}else{
		window.location.href = "http://www.klikk.com.mt/support_onlinepickup.php";
	}
}

