/** RUGS:HU v2.0 **/
$(function(){
   
   $("#breadcrumb a[rel=bc]").hover(function(e) {
       $("#msg").css({left : (e.screenX + 20), top : (($.browser.msie ? e.screenY - 80 : e.screenY - 140))}).show();   
   }, function() {
       $("#msg").hide();
   });
   
});

$(window).load(function () {    
    
    var oc_i = 1;
    var sl_start = 0;
    var max = 0;
   $(".onecarpet_index .pr_image").each(function() {
        
        if($(this).height() > max) {
            max = $(this).height() 
        }
         
        if(oc_i % 3 == 0 && oc_i != 0) {
            $(".onecarpet_index .pr_image").slice(sl_start, oc_i).height(max);
            sl_start = oc_i;
            max = 0;    
        }     
        oc_i++;
        
   });
   
   var oc_i = 1;
   var sl_start = 0;
   var max = 0;
   $(".onecarpet_index").each(function() {
       
        if($(this).height() > max) {
            max = $(this).height() 
        }
         
        if(oc_i % 3 == 0) {
            //console.log("range:"+sl_start+"-"+oc_i+" height: "+max);
            //console.log($(".onecarpet_index").slice(sl_start, oc_i));
            $(".onecarpet_index").slice(sl_start, oc_i).height(max);
            sl_start = oc_i;
            max = 0;    
        }     
        oc_i++;
        
   });
   
   $(".apro_bg").each(function() {
       
       var leftBox = $(this).find(".apro_box_bg");
       var rightBox = $(this).find(".apro_box_bg_wide");
       
       if(leftBox.height() > rightBox.height()) {
           rightBox.height(leftBox.height());
       } else if(leftBox.height() < rightBox.height()) {
           leftBox.height(rightBox.height());
       }    
       
   });
   
   fixHeight();
})

function fixHeight() {
    var max = 0;
    if($("#left_side").height() > max) {
        max = $("#left_side").height();
    }
    if($("#center").height() > max) {
        max = $("#center").height();
    }
    if($("#right_side").height() > max) {
        max = $("#right_side").height();
    }
    
    $("#left_side").height(max);
    $("#center").height(max + 8);
    $("#right_side").height(max);    
}


/** RUGS:HU V1.0 **/
function rExpPersonName(string)
{
	var rExpPattern = /([A-ZÉÁÛÕÚÖÜÓÍ][a-zéáûõúöüóí]+)\s([A-ZÉÁÛÕÚÖÜÓ][a-zéáûõúöüóí]+)$|([A-ZÉÁÛÕÚÖÜÓÍ][a-zéáûõúöüóí]+)\s([A-ZÉÁÛÕÚÖÜÓ][a-zéáûõúöüóí]+)\s([A-ZÉÁÛÕÚÖÜÓ][a-zéáûõúöüóí]+)$/;
	return rExpPattern.test(string);
}

function eqq(o)
{
  var bill = document.getElementById('bill');
  bill.style.display = ((o.checked)?'none':'block');
}
function place()
{
  //var reg = document.registration;
  var reg = document.pay_form;
  if ((reg.country.options[reg.country.selectedIndex].text == "Magyarország") || (reg.country.options[reg.country.selectedIndex].text == "Hungary"))
  {
    reg.zip.maxLength='4';
 //   reg.city.style.display = 'none';
//   document.getElementById('text').style.display = 'block';
  }
  else
  {
    reg.zip.maxLength='55';
//    reg.city.style.display = 'block';
//    document.getElementById('text').style.display = 'none';
  }
}

function billplace()
{
	var reg = document.pay_form;
  //var reg = document.registration;
  //alert(reg.billzip.value);
  if ((reg.billcountry.options[reg.billcountry.selectedIndex].text == "Magyarország") || (reg.billcountry.options[reg.country.selectedIndex].text == "Hungary"))
  {
    //reg.billzip.setAttribute('maxlength', '4');
    reg.billzip.maxLength="4";
//    reg.billcity.style.display = 'none';
    //document.getElementById('billtext').style.display = 'block';
  }
  else
  {
//    reg.billzip.value="0000";
    reg.billzip.maxLength="100";
//    alert("ok");
	//reg.billzip.setAttribute('maxlength', '99999');
//    reg.billcity.style.display = 'block';
    //document.getElementById('billtext').style.display = 'none';
  }
}
/*
function pic_popup(src)
{
  var w = window.open('', '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=400,height=400');
  w.document.writeln("<html><head><title>Kép a termékrõl</title></head><body style='margin:0px;padding:0px'><center>");
  w.document.writeln("<img src='" + src + "' alt='' style='margin-top:10px;' onclick='self.window.close();' />");
  w.document.writeln("<script type='text/javascript' src='js/jquery.js'>");
  w.document.writeln("<script type='text/javascript'>");
  w.document.writeln("$(function(){");
  w.document.writeln("  setTimeout(function(){");
  w.document.writeln("  // FF");
  w.document.writeln("  try { this.window.sizeToContent(); }");
  w.document.writeln("  // IE");
  w.document.writeln("  catch (e){");
  w.document.writeln("    var o = $('#pic');");
  w.document.writeln("    var frameW = 90;");
  w.document.writeln("    var frameH = 110;");
  w.document.writeln("    alert(o.width());");
  w.document.writeln("    this.window.resizeTo(o.width()+frameW, o.height()+frameH);");
  w.document.writeln("} }, 500); }");
  w.document.writeln("</" + "script>");
  w.document.writeln("</center></body></html>");
}
*/
function pic_popup(src)
{
  var w = window.open('sites/imgpopup.php?src=' + src, '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=400,height=400');
}
  
function open_palette(id)
{
  var w = window.open('sites/palette.php?id=' + id, '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=740,height=600');
}

function buy(pid, id, count)
{
  var o = document.getElementById('product_count')
  window.location='../index.php?pg=pay&payid=' + pid + '&count=' + (count?count:(o&&o.value?o.value:1)) + (id?"&palette=" + id:"");
}

function stepCart(step)
{
	$('#rugsCart').attr("action", "index.php?pg=pay&step="+step);
	$('#rugsCart').submit();
}

function goCart(step)
{
	window.location.href="index.php?pg=pay&step="+step;
}

function edit(count)
{
  document.pay_form.editid.value = count;
  document.pay_form.submit();
}

$(function()
{
$('#contentScroll').height($('#contentTd').height()-10);
});

