﻿
function on_popup_ok(){
    window.location.href = 'Cart.aspx'; 
    return true;
}

function SetUniqueRadioButton(nameregex, current)
{
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
   current.checked = true;
}

function SetUniqueRadioButtonOnPanel(current, hiddenId)
{
    elemHidden =document.getElementById(hiddenId);
    if (elemHidden.value !="")
    {
        selPanel = document.getElementById(elemHidden.value );
        if (selPanel != null)
        {
            selPanel.className = "product_item_options_colorChoose_panel";
        }
    }
   //current.style.border="2px solid red";
   current.className = "product_item_options_colorChoose_panel_selected";
   elemHidden.value = current.id;
   //zapisac id do hidden
   //zerowac poprzedni border po tym id
}

function ensureNumeric(e){  
var key=e.keyCode!=0 ? e.keyCode:e.charCode;
  if ((key <48 || key >57) && key!=8){
        return false;
  }
}
function ensureNumericWithDecimal(e){
var key=e.keyCode!=0 ? e.keyCode:e.charCode;
  if ((key <48 || key >57) && key!=8 && key!=44 && key!=46 && key!=110 && key!=37 && key!=39 && key!=9){
        return false;
  }
}
function validateAmount(fld){
	if (fld.value == "" || fld.value == "0") {
		fld.value = "1";
	}
	var stripped = fld.value.replace(/,/, ".");	
	if (isNaN(stripped)) {
		alert("Nieprawidłowa ilość metrów! Proszę wpisać ponownie.");
		fldID = fld.id
		setTimeout("document.getElementById(fldID).focus();",1);
		setTimeout("document.getElementById(fldID).select();",1);
	} else {
		var temp = Number(stripped);
		stripped = temp.toFixed(1);
		temp = stripped.replace(/\.0/, "");
		if (Number(stripped) < 1) {
			fld.value = "1";
		} else {
			stripped = temp.replace(/\./, ",");
			fld.value = stripped;
		}
	}
}
function clearText(formfield){
if (formfield.defaultValue==formfield.value)
 formfield.value = ""
}

function defaultTextNewsletter(formfield){
if (formfield.value=="")
 formfield.value = "wpisz e-mail"
} 

function defaultTextSearch(formfield){
if (formfield.value=="")
 formfield.value = "Szukaj"
}

function validateEmail(emailfield, buttonField) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = emailfield.value;
   if (reg.test(address) == false) {
      alert('Niepoprawny adres e-mail');
      return false;
   }
   else{
        alert('Dziękujemy! Twój e-mail został wysłany.');
        buttonField.click();
   }
}

function loadFlashOnAboutPage()
{
if (document.getElementById("loader_jaxon_swf")!=null)
        {
  document.getElementById("loader_jaxon_swf").innerHTML = '<embed width="950" height="540" allowfullscreen="false" flashvars="&amp;xmlLocation=/app_themes/jaxon/flash/datastart.xml&amp;frontThumbNumber=0" quality="high" bgcolor="#fff" name="sotester" id="sotester" src="/app_themes/jaxon/flash/CarouselDesignerV3.swf" type="application/x-shockwave-flash">';
  }
  if (document.getElementById("loader_jaxon_swf_wedziska")!=null)
        {
  document.getElementById("loader_jaxon_swf_wedziska").innerHTML = '<embed width="217" height="114" wmode="transparent" quality="high" bgcolor="#000" name="sotester1" id="sotester1" src="/app_themes/jaxon/flash/wedziska.swf" type="application/x-shockwave-flash">';
  }
  if (document.getElementById("loader_jaxon_swf_zylki")!=null)
        {
  document.getElementById("loader_jaxon_swf_zylki").innerHTML = '<embed width="217" height="114" wmode="transparent" quality="high" bgcolor="#000" name="sotester1" id="sotester1" src="/app_themes/jaxon/flash/zylki.swf" type="application/x-shockwave-flash">';
  }
  if (document.getElementById("loader_jaxon_swf_kolowrotki")!=null)
        {
  document.getElementById("loader_jaxon_swf_kolowrotki").innerHTML = '<embed width="217" height="114" wmode="transparent" quality="high" bgcolor="#000" name="sotester1" id="sotester1" src="/app_themes/jaxon/flash/kolowrotki.swf" type="application/x-shockwave-flash">';
  }
  if (document.getElementById("loader_jaxon_swf_przynety")!=null)
        {
  document.getElementById("loader_jaxon_swf_przynety").innerHTML = '<embed width="217" height="114" wmode="transparent" quality="high" bgcolor="#000" name="sotester1" id="sotester1" src="/app_themes/jaxon/flash/przynety.swf" type="application/x-shockwave-flash">';
  }
  
  if (document.getElementById("loader_bialezeby_swf")!=null)
        {
  document.getElementById("loader_bialezeby_swf").innerHTML = '<embed width="900" height="400" wmode="transparent" allowfullscreen="false" flashvars="&amp;xmlLocation=/app_themes/bialezeby/flash/datastart.xml&amp;frontThumbNumber=0" quality="high" bgcolor="#fff" name="sotester" id="sotester" src="/app_themes/bialezeby/flash/CarouselDesignerV3.swf" type="application/x-shockwave-flash">';
  }
  if (document.getElementById("loader_thinkart_swf")!=null)
        {
  document.getElementById("loader_thinkart_swf").innerHTML = '<embed width="900" height="400" wmode="transparent" allowfullscreen="false" flashvars="&amp;xmlLocation=/app_themes/thinkart/flash/datastart.xml&amp;frontThumbNumber=0" quality="high" bgcolor="#fff" name="sotester" id="sotester" src="/app_themes/thinkart/flash/CarouselDesignerV3.swf" type="application/x-shockwave-flash">';
  }
  if (document.getElementById("loader_vitberg_mapa_swf")!=null)
        {
  document.getElementById("loader_vitberg_mapa_swf").innerHTML = '<embed width="360" height="360" flashvars="xmlPath=/App_Themes/vitberg/flash/data.xml&amp;yfix=10" wmode="transparent" quality="high" bgcolor="#336699" name="mapMovie" id="mapMovie" src="/App_Themes/vitberg/flash/spmap.swf" type="application/x-shockwave-flash">';
  }
  if (document.getElementById("loader_rest_sushi_swf")!=null)
        {
  document.getElementById("loader_rest_sushi_swf").innerHTML = '<embed width="732" height="400" wmode="transparent" quality="high" bgcolor="#fff" name="spacer" id="spacer" src="/App_Themes/sushisekai/flash/rest_SD_new.swf" type="application/x-shockwave-flash">';
  }
  if (document.getElementById("loader_bar_sushi_swf")!=null)
        {
  document.getElementById("loader_bar_sushi_swf").innerHTML = '<embed width="732" height="400" wmode="transparent" quality="high" bgcolor="#fff" name="spacer" id="spacer" src="/App_Themes/sushisekai/flash/bar_SD_new.swf" type="application/x-shockwave-flash">';
  }
}

function drukuj(){
 // sprawd moliwoci przegldarki
   if (!window.print){
      alert("Twoja przeglądarka nie drukuje!")
   return 0;
   }
 window.print(); // jeli wszystko ok &#8211; drukuj
}


function overPic(smallLayerName, bigLayerName, picNr, allPic)
{
    // ukrywamy wszystkie obrazki
    hideAllBigImg(smallLayerName,bigLayerName,allPic);
    var smalPic = new getObj(smallLayerName+ picNr);
    if(smalPic !=null && smalPic.obj!=null)
    {
        smalPic.obj.className = 'small_image selected';
    } 
    var bigLayer = new getObj(bigLayerName +picNr );
    if(bigLayer!=null && bigLayer.style!=null)
    {
        bigLayer.style.display = 'block';
        
    }

}
function hideAllBigImg(smallLayerName,bigLayerName, picCount)
{
    for(var i=0;i<picCount;i++)
    {
        var imgLayer = new getObj(bigLayerName+i);
        if(imgLayer !=null)
        {
            imgLayer.style.display ='none';
        }
        var imgLayers = new getObj(smallLayerName+i);
        if(imgLayers !=null && imgLayers.obj!=null)
        {
            imgLayers.obj.className ='small_image';
        }
    }
}

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
  	if(this.obj != null){
	    this.style = document.getElementById(name).style;
	}
	//alert('getObj('+name+') 1');
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
	//alert('getObj('+name+') 2');
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
   //	alert('getObj('+name+') 3');
  }
  else
  {
   // alert('null');
  }
  
}

function openNewWindow (url, width, height)
{
window.open(url, '', "menubar=no, titlebar=no, scrollbars=yes, location=no, toolbar=no, status=no, resizable=yes, width=" + width +"px, height=" + height + "px");
}
function openContactForm(title,email)
{
openNewWindow ("/contact.aspx?title=" + title + "&email=" + email, 600, 600)
}

