/* Ide jonnek majd a szukseges script hivasok */
searchStr = 'velux-tp-2010/';
offset = document.location.href.indexOf(searchStr);
if(offset > 0) {
    offset += searchStr.length;
    path = document.location.href.substr(offset, document.location.href.length -offset);
    // detect directory depth by counting the parts in the url (separeted by /)
    a = path.split('/'); 
    dirDepth = a.length-1; // last part is the filename
    document.pathToRoot = './';
    for(i=0;i<dirDepth;i++) document.pathToRoot += '../';
} else {
    // mozilla schema: we get the first 11 char 'file:///X:/'
    if(document.location.href.indexOf('file:///') == 0) document.pathToRoot = document.location.href.substr(0,11);
    // opera schema
    else if(document.location.href.indexOf('file://localhost/') == 0) document.pathToRoot = document.location.href.substr(0,20);
    //use absolute address
    else document.pathToRoot = '/';
}


document.write(
'<scr' + 'ipt type="text/javascript" src="' + document.pathToRoot + 'includes/mootools-1.2.4-core-nc.js">'+
'</scr' + 'ipt>' + "\n"
);
document.write(
'<scr' + 'ipt type="text/javascript" src="' + document.pathToRoot + 'includes/SqueezeBox.js">'+
'</scr' + 'ipt>' + "\n"
);
document.write(
'<link rel=stylesheet type="text/css" href="' + document.pathToRoot + 'includes/SqueezeBox.css">' + "\n"
);

/*
document.write(
'<scr' + 'ipt type="text/javascript" src="includes/search.js">'+
'</scr' + 'ipt>'
);
*/
// we can't use mootools onload mechanism since mootools is not initiated yet
window.onload = function() {

    $$('div.headerSearch').setStyle('display', 'block');
    $$('div.headerSearch form').addEvent('submit', function() {
        startSearch();
        return false;
    });
    $$('div.headerSearch a').addEvent('click', function() {
        startSearch();
        return false;
    });


    s = $$('div.headerSearch input[type="text"]')
    s.addEvent('focus', function() {
        this.set('value', '');
        this.setStyle('color', '');
    });
    s.addEvent('blur', function() {
        if(!this.get('value')) {
            this.set('value', 'Keresés');
            this.setStyle('color', '#999');
        }
    });
    s.set('value', 'Keresés');
    s.setStyle('color', '#999');

}


function startSearch() {
    keyword = new String($$('div.headerSearch input').get('value'));
//    mycookie = Cookie.write('VeluxCD2010Search', keyword, {duration: 0.5});
	SqueezeBox.initialize();
	SqueezeBox.open(document.pathToRoot+'search.html?cat=0&keys='+keyword.replace(' ', '+'), {
		handler: 'iframe',
		size: {x: 520, y: 370}
	});
}




