function retadpuxaja(divjaxaid, jaxaurl) 
{
  new Ajax.Updater(divjaxaid, jaxaurl, {asynchronous:true, evalScripts:true});; return false;
}

function show_products(input, manu)
{
	firstmenuimg = document.getElementById('first_menu_img');
	firstmenutext = document.getElementById('first_menu_text');
	mlist = document.getElementById('manufacturer_list');
	plist = document.getElementById('product_list_'+manu);
	if (plist.style.display=="none") {
		plist.style.display="block";
		input.style.borderBottom='none';
		firstmenuimg.style.marginTop='14px';
		firstmenutext.style.marginTop='14px';
	}
	else {
		plist.style.display="none";
		input.style.borderBottom='1px solid #7F9DB9';
		firstmenuimg.style.marginTop='13px';
		firstmenutext.style.marginTop='13px';
	}
	mlist.style.display="none";
}

function getElementsByClass(node,searchClass,tag) {
	var classElements = new Array();
	var els = node.getElementsByTagName(tag); // use "*" for all elements
	var elsLen = els.length;
	var pattern = new RegExp("\\b"+searchClass+"\\b");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function hideLists() {
	var el = getElementsByClass(document.getElementById('right_menu'),'product_list','ul');
	//alert(el.length);
	for (i=0;i<el.length;i++) {
		el[i].style.display='none';
	}
}

function show_manufacturers(input)
{
	firstmenuimg = document.getElementById('first_menu_img');
	firstmenutext = document.getElementById('first_menu_text');
	mlist = document.getElementById('manufacturer_list');
	plist = document.getElementById('product_list');
	if (mlist.style.display=="none") {
		mlist.style.display="block";
		input.style.borderBottom='none';
		firstmenuimg.style.marginTop='14px';
		firstmenutext.style.marginTop='14px';
	}
	else {
		mlist.style.display="none";
		input.style.borderBottom='1px solid #7F9DB9';
		firstmenuimg.style.marginTop='13px';
		firstmenutext.style.marginTop='13px';
	}
	hideLists();
	//plist.style.display="none";
}


function ups_selector_load()
{
	var pre = document.getElementById('ups_selector_pre');
	var container = document.getElementById('ups_selector');
	var oIframe = document.getElementById('selector_frame');
  var oDoc = oIframe.contentWindow || oIframe.contentDocument;
  //if (oDoc.document) {
  //    oDoc = oDoc.document;
  //}
  //container.innerHTML = oDoc.body.innerHTML;

	//oIframe.src='http://www.google.com';
	//pre.style.display = 'none';
	container.innerHTML = oDoc.document.body.innerHTML;

  return false;
}

function search_reseller(countyid, manufacturerlink)
{
	new Ajax.Updater('search_reseller_result', '/'+manufacturerlink+'/search_result/'+countyid, {asynchronous:true, evalScripts:true});; return false;
}

function tabup(logo)
{
	
}

function tabdown(logo)
{
	
}

function slideSwitch() {
    var active = $('#slideshow DIV.active');

    if ( active.length == 0 ) active = $('#slideshow DIV:last');

    // use this to pull the images in the order they appear in the markup
    var next =  active.next().length ? active.next()
        : $('#slideshow DIV:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var next  = $( $sibs[ rndNum ] );


    active.addClass('last-active');

    next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            active.removeClass('active last-active');
        });
}

var win=null;
function printIt(printThis)
{
  win = window.open();
  self.focus();
  win.document.open();
  win.document.write('<'+'html'+'><'+'head'+'><'+'style'+'>');
  win.document.write('body, td { font:13px/1.22 arial,helvetica,clean,sans-serif; }');
  win.document.write('<'+'/'+'style'+'><link href="/css/main.css" media="screen" type="text/css" rel="stylesheet"><'+'/'+'head'+'><'+'body'+'>');
  win.document.write(printThis);
  win.document.write('<'+'/'+'body'+'><'+'/'+'html'+'>');
  win.document.close();
  win.print();
  win.close();
}

function printpage() 
{
window.print();
}
function sendemail() 
{ 
var recp = "office@bps.hu"; 
var subj = "BPS Weboldal";
var btxt = "";
var docTitle = "";//document.title;

var windowLocation = "";//window.location;

window.location = "mailto:"+recp+"?subject="+subj;//+"&body="+btxt+"%0D%0A%0D%0A"+docTitle+"%0D%0A%0D%0A"+ escape(windowLocation);
}

function popUp(URL,width,height)
{
	day = new Date();
	id = day.getTime();

	//available_width = screen.availWidth;
	//available_height = screen.availHeight;

	var position_left = (screen.availWidth - width)/2;
	var position_top = (screen.availHeight - height)/2;


	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ",top=" + position_top + ",left=" + position_left + "');");
}
