var URL = 'http://www.2kolory.pl/';

function changeColors(id,type){
			var where = document.getElementById(id);
			
			if(type=='on'){
        where.style.backgroundColor='#FDCAC8'; 
        where.firstChild.style.color='#602929';
			}
      else {
        where.style.backgroundColor='#602929'; 
				where.firstChild.style.color='#FDCAC8';
      }
	
		}
		
function changeMenuItemStyle(id){
      var where = document.getElementById(id);
      where.onmouseover = new changeColors(id,'on');
      where.onmouseout = new changeColors(id,'on');
      changeColors(id,'on');
}

function onClickEvent(id){
  var where = document.getElementById(id);
  location.assign(where.firstChild.href);
}

function changeGalleryItemStyle(id){
  document.getElementById(id).style.textDecoration='underline';
}

  
function orderValidator(){
  if(document.getElementById('fname').value=='' || 
     document.getElementById('lname').value=='' || 
     document.getElementById('phone').value=='' || 
     document.getElementById('o_fname').value=='' || 
     document.getElementById('o_lname').value=='' || 
     document.getElementById('o_street').value=='' || 
     document.getElementById('o_city').value=='' || 
     document.getElementById('delivery_date').value=='' || 
     document.getElementById('obrazek').value=='')
      {
      alert('Wypełnij wymagane pola!');
      return false;
   }
   else {
      if(document.getElementById('accept').checked==false) { 
        alert('Aby złożyć zamówienie musisz zapoznać się z regulaminem!');
        return false;
       }
       else send_form();
   }
}

function send_form(){

advAJAX.submit(document.getElementById("send_form"), {
    onSuccess : function(obj) { alert(obj.responseText);location.assign(URL);},
    onError : function(obj) { alert("Error: " + obj.status); }
});

}


function show_photo(folder,img,typ,idgal){
  var big = document.getElementById('load_photo');
  var html = '<table cellpadding="0" cellspacing="0" style="margin-left: auto;margin-right: auto;"><tr><td style="padding: 5px; background-color: #FFFFFF; border: 1px solid;"><div style="margin-bottom: 5px;text-align: right; font-size: 15px; font-weight: bold;cursor: pointer;" onclick="javascript: close_photo();">x</div>';  
       html += '<img src="gallery/'+folder+'/'+img+'.'+typ+'" alt="" onClick="javascript: close_photo()" /><div style="font-size: 10px;width: 100%;text-align: center;">'+img+'</div>';
       /*if(idgal!='')
          html += '<div class="order" style="font-weight: bold;"><a class="order" href="'+idgal+'/zamow_'+img+'.html">..:: zamów ::..</a></div>';*/
       html +=  '</td></tr></table>';
  big.innerHTML = html;
  document.getElementById('load_photo').style.display = 'block';

}

function show_ref(img){
  var big = document.getElementById('load_photo');
  var html = '<table cellpadding="0" cellspacing="0" style="margin-left: auto;margin-right: auto;"><tr><td style="padding: 5px; background-color: #FFFFFF; border: 1px solid;"><div style="margin-bottom: 5px;text-align: right; font-size: 15px; font-weight: bold;cursor: pointer;" onclick="javascript: close_photo();">x</div>';  
       html += '<img src="references/'+img+'" alt="" onClick="javascript: close_photo()" /><div style="font-size: 10px;width: 100%;text-align: center;"></div>';
       html +=  '</td></tr></table>';
  big.innerHTML = html;
  document.getElementById('load_photo').style.top = '25px';
  document.getElementById('load_photo').style.display = 'block';
    

}

function close_photo(){
  var big = document.getElementById('load_photo');
  big.style.display = 'none';

}