// JavaScript Document
var xmlHttp
var xmlHttp2
var xmlHttp3
function zmien_nazwe(fotka,katalog){
var newfotka = document.getElementById("nazwa"+fotka).value;
//alert('ddddddffffffff');return;
		xmlHttp2=GetXmlHttpObject2();
		if (xmlHttp2==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="gall_manag.php?oper=rename&katalog="+katalog+"&fotka="+fotka+"&newfotka="+newfotka;
//alert(url);return;
url=url+"&sid="+Math.random();
xmlHttp2.onreadystatechange=function(){stateChangedkal_elast(fotka);};
xmlHttp2.open("GET",url,true);
xmlHttp2.send(null);


//var t =setTimeout(function(){java_wykaz_odbitek(fotka, '',klient,'');},1000);
}
//====================================
function usun_fote(fotka,katalog){
	var d = new Date();
var mies = d.getMonth();
	var name=prompt("Please enter your password to delete","Harry Potter");
if (name!=null && name!="" && name==mies+1)
  {
  } else {
	  alert("złe hasło!!!");
	return;  
  }

//alert('ddddddffffffff');return;
		xmlHttp2=GetXmlHttpObject2();
		if (xmlHttp2==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="gall_manag.php?oper=usun&katalog="+katalog+"&fotka="+fotka;
//alert(url);return;
url=url+"&sid="+Math.random();
xmlHttp2.onreadystatechange=function(){stateChangedkal_elast(fotka);};
xmlHttp2.open("GET",url,true);
xmlHttp2.send(null);


//var t =setTimeout(function(){java_wykaz_odbitek(fotka, '',klient,'');},1000);
}
//==========================================================================
function wybranie_odbitki(idkomorki, pCSSname,klient,oper){
//document.getElementById(idkomorki).bordercolor="#FF0000";
//alert (document.getElementById(idkomorki).bordercolor);
var ilosc = document.getElementById("sztuki"+idkomorki).value;
var rozmiar = document.getElementById("combo"+idkomorki).value;
if((parseInt(ilosc)>0) && (ilosc.toString().indexOf('.')==-1) && (ilosc.toString().indexOf(',')==-1)){
	var ok =1; 
	} else{
		
		alert("podaj wlasciwą ilość!!!");
		return;
	}

xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="odbitki_w.php?oper="+oper+"&klient="+klient+"&fotka="+idkomorki+"&ilosc="+ilosc+"&rozmiar="+rozmiar;
//alert(url);

url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChangedkal;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

var pElem = document.getElementById(idkomorki);
    pElem.className = pCSSname ;  //having a proper class defined in css
	
var t =setTimeout(function(){java_wykaz_odbitek(idkomorki, pCSSname,klient,oper);},1000);
//wykaz jakie sa	
/*
xmlHttp2=GetXmlHttpObject2();
var url="odbitki_w.php?wykaz=1&oper="+oper+"&klient="+klient+"&fotka="+idkomorki+"&ilosc="+ilosc+"&rozmiar="+rozmiar;
//alert(url);
url=url+"&sid="+Math.random();
xmlHttp2.onreadystatechange=function(){stateChangedkalwykaz(idkomorki);};
xmlHttp2.open("GET",url,true);
xmlHttp2.send(null);
*/

}
function java_wykaz_odbitek(idkomorki, pCSSname,klient,oper){
	/*
	var ilosc = document.getElementById("sztuki"+idkomorki).value;
var rozmiar = document.getElementById("combo"+idkomorki).value;
*/
xmlHttp3=null;
	xmlHttp3=GetXmlHttpObject3();
var url="odbitki_w.php?wykaz=1&klient="+klient+"&fotka="+idkomorki;
//alert(url);
document.getElementById("div"+idkomorki).innerHTML = "pobiera dane...";
url=url+"&sid="+Math.random();
xmlHttp3.onreadystatechange=function(){stateChangedkalwykaz(idkomorki,'wykaz',klient);};
xmlHttp3.open("GET",url,true);
xmlHttp3.send(null);
}

function usun_odbitke(klient,fotka,rozmiar,sztuki,idodbitki){

	//alert('ddddddffffffff');
		xmlHttp2=GetXmlHttpObject2();
		if (xmlHttp2==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="odbitki_w.php?oper=usun&klient="+klient+"&fotka="+fotka+"&ilosc="+sztuki+"&rozmiar="+rozmiar+"&idodbitki="+idodbitki;
//alert(url);
url=url+"&sid="+Math.random();
xmlHttp2.onreadystatechange=function(){stateChangedkalwykaz_usun(fotka,'usuwanie');};
xmlHttp2.open("GET",url,true);
xmlHttp2.send(null);


var t =setTimeout(function(){java_wykaz_odbitek(fotka, '',klient,'');},1000);
}

<!----------------------------------------------------------->
function wybranie(idkomorki, pCSSname,klient,oper){
//document.getElementById(idkomorki).bordercolor="#FF0000";
//alert(idkomorki);
//alert (document.getElementById(idkomorki).bordercolor);
xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="fotoksiazka_w.php?oper="+oper+"&klient="+klient+"&fotka="+idkomorki;

url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChangedkal;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

var pElem = document.getElementById(idkomorki);
    pElem.className = pCSSname ;  //having a proper class defined in css
}

function opozniacz(){

window.location.reload();
}
<!----------------------------------------------------------->
function stateChangedkalwykaz(zdjecie,operacja,klient) 

{ 
//alert(xmlHttp3.readyState);
if (xmlHttp3.readyState==4)

{ 

//document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
	var typdiv = "div"+zdjecie;
if (operacja=='usuwanie'){typdiv='ile_wybr';}
if (operacja=='wykaz'){typdiv="div"+zdjecie;}
var odpowiedz= xmlHttp3.responseText;
document.getElementById(typdiv).innerHTML = odpowiedz;



	if (((odpowiedz.length)>2) && (odpowiedz.indexOf('x',1))){//gdy sa jakies zdj to caly tekst jest przeciez no i dla bezp ma miec x bo np10x15
	var pElem = document.getElementById(zdjecie);
    pElem.className = 'redborder' ;  //having a proper class defined in css
	} else{
	var pElem = document.getElementById(zdjecie);
    pElem.className = '' ;  //having a proper class defined in css
	}
	
}
}
<!----------------------------------------------------------->
<!----------------------------------------------------------->
function stateChangedkalwykaz_usun(zdjecie,operacja) 

{ 
if (xmlHttp2.readyState==4)
{ 
//document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
var typdiv = "div"+zdjecie;

if (operacja=='usuwanie'){typdiv='ile_wybr';}
if (operacja=='wykaz'){typdiv="div"+zdjecie;}

var odpowiedz= xmlHttp2.responseText;
document.getElementById(typdiv).innerHTML = odpowiedz;
/*
alert(typdiv);
alert(odpowiedz);
*/
/*
	if (((odpowiedz.length)>2) && (odpowiedz.indexOf('x',1))){//gdy sa jakies zdj to caly tekst jest przeciez no i dla bezp ma miec x bo np10x15
	var pElem = document.getElementById(zdjecie);
    pElem.className = 'redborder' ;  //having a proper class defined in css
	} else{
	var pElem = document.getElementById(zdjecie);
    pElem.className = '' ;  //having a proper class defined in css
	}
	*/
}
}
<!----------------------------------------------------------->
function stateChangedkal_elast(fotka) 
{ 

if (xmlHttp2.readyState==4)
{ 
//document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
document.getElementById("div"+fotka).innerHTML = xmlHttp2.responseText;
} else {
//	alert('niegotowoy');
}
}
<!----------------------------------------------------------->
<!----------------------------------------------------------->
function stateChangedkal() 
{ 

if (xmlHttp.readyState==4)
{ 
//document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
document.getElementById("ile_wybr").innerHTML = xmlHttp.responseText;
} else {
//	alert('niegotowoy');
}
}
<!----------------------------------------------------------->
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
<!----------------------------------------------------------->
<!----------------------------------------------------------->
function GetXmlHttpObject2()
{
var xmlHttp2=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp2=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp2;
}
<!----------------------------------------------------------->
<!----------------------------------------------------------->
function GetXmlHttpObject3()
{
var xmlHttp3=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp3=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp3=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp3=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp3;
}
<!----------------------------------------------------------->
function spr_wypelnieniem(){

var te = document.getElementById("user").value;
if (te==''){
alert('wpisz w polu haslo!!');
return false;
}

//document.getElementById('idwyslanie').disabled=true;
return true;

}

function spr_wypelnienie(){

var te = document.getElementById("textw").value;
if (te==''){
alert('wpisz w polu wiadomosc!!');
return false;
}

var email = document.getElementById("email").value;
if (email==''){
alert('wpisz w polu email!!');
return false;
}
//document.getElementById('idwyslanie').disabled=true;
return true;

}


//=================
function newwin(url){
	/*
var spec = "'_blank','toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400'";
*/
var spec = "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width=1100, height=500,left=0, top=0";

/*
 if (window.o && !window.o.closed) {
		//	alert("sss");
		}
 */  
		
o = window.open(url,"PictureWindow",spec);
o.focus();
}


function relode(url){
//	alert("fdfd");
//	window.opener.location.href =url+'?dodal=tak';
if (url.indexOf('?')>0){
window.opener.location.href =url//+'&dodal='+ Math.random();
} else {
window.opener.location.href =url//+'?dodal='+ Math.random();
}
	window.close();
	
}

//======================================
//======================================modyfikacja stylow

// ugly workaround for missing support for selectorText in Netscape6/Mozilla
// call onLoad() or before you need to do anything you would have otherwise used
// selectorText for.
var ugly_selectorText_workaround_flag = false;
var allStyleRules;
// code developed using the following workaround (CVS v1.15) as an example.
// http://lxr.mozilla.org/seamonkey/source/extensions/xmlterm/ui/content/XMLTermCommands.js
function ugly_selectorText_workaround() {
	if((navigator.userAgent.indexOf("Gecko") == -1) ||
	   (ugly_selectorText_workaround_flag)) {
		return; // we've already been here or shouldn't be here
	}
	var styleElements = document.getElementsByTagName("style");
	
	for(var i = 0; i < styleElements.length; i++) {
		var styleText = styleElements[i].firstChild.data;
		// this should be using match(/\b[\w-.]+(?=\s*\{)/g but ?= causes an
		// error in IE5, so we include the open brace and then strip it
		allStyleRules = styleText.match(/\b[\w-.]+(\s*\{)/g);
	}

	for(var i = 0; i < allStyleRules.length; i++) {
		// probably insufficient for people who like random gobs of 
		// whitespace in their styles
		allStyleRules[i] = allStyleRules[i].substr(0, (allStyleRules[i].length - 2));
	}
	ugly_selectorText_workaround_flag = true;
}


// setStyleById: given an element id, style property and 
// value, apply the style.
// args:
//  i - element id
//  p - property
//  v - value
//
function setStyleById(i, p, v) {
	var n = document.getElementById(i);
	n.style[p] = v;
}

// getStyleById: given an element ID and style property
// return the current setting for that property, or null.
// args:
//  i - element id
//  p - property
function getStyleById(i, p) {
	var n = document.getElementById(i);
	var s = eval("n.style." + p);

	// try inline
	if((s != "") && (s != null)) {
		return s;
	}

	// try currentStyle
	if(n.currentStyle) {
		var s = eval("n.currentStyle." + p);
		if((s != "") && (s != null)) {
			return s;
		}
	}
	
	// try styleSheets
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[y] == i) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) ||
						   (rules[y].selectorText == i)) {
							return z[p];
						}
					}
				}
			}
		}
	}
	return null;
}

// setStyleByClass: given an element type and a class selector,
// style property and value, apply the style.
// args:
//  t - type of tag to check for (e.g., SPAN)
//  c - class name
//  p - CSS property
//  v - value
var ie = (document.all) ? true : false;

function setStyleByClass(t,c,p,v){
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					eval('node.style.' + p + " = '" +v + "'");
				}
			}
		}
	}
}

// getStyleByClass: given an element type, a class selector and a property,
// return the value of the property for that element type.
// args:
//  t - element type
//  c - class identifier
//  p - CSS property
function getStyleByClass(t, c, p) {
	// first loop over elements, because if they've been modified they
	// will contain style data more recent than that in the stylesheet
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					var theStyle = eval('node.style.' + p);
					if((theStyle != "") && (theStyle != null)) {
						return theStyle;
					}
				}
			}
		}		
	}
	// if we got here it's because we didn't find anything
	// try styleSheets
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if((allStyleRules[y] == c) ||
						   (allStyleRules[y] == (t + "." + c))) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) &&
						   ((rules[y].selectorText == c) ||
						    (rules[y].selectorText == (t + "." + c)))) {
							return z[p];
						}
					}
				}
			}
		}
	}

	return null;
}

// setStyleByTag: given an element type, style property and 
// value, and whether the property should override inline styles or
// just global stylesheet preferences, apply the style.
// args:
//  e - element type or id
//  p - property
//  v - value
//  g - boolean 0: modify global only; 1: modify all elements in document
function setStyleByTag(e, p, v, g) {
	if(g) {
		var elements = document.getElementsByTagName(e);
		for(var i = 0; i < elements.length; i++) {
			elements.item(i).style[p] = v;
		}
	} else {
		var sheets = document.styleSheets;
		if(sheets.length > 0) {
			for(var i = 0; i < sheets.length; i++) {
				var rules = sheets[i].cssRules;
				if(rules.length > 0) {
					for(var j = 0; j < rules.length; j++) {
						var s = rules[j].style;
						// selectorText broken in NS 6/Mozilla: see
						// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
						ugly_selectorText_workaround();
						if(allStyleRules) {
							if(allStyleRules[j] == e) {
								s[p] = v;
							}			
						} else {
							// use the native selectorText and style stuff
							if(((s[p] != "") && (s[p] != null)) &&
							   (rules[j].selectorText == e)) {
								s[p] = v;
							}
						}

					}
				}
			}
		}
	}
}

// getStyleByTag: given an element type and style property, return
// the property's value
// args:
//  e - element type
//  p - property
function getStyleByTag(e, p) {
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		for(var i = 0; i < sheets.length; i++) {
			var rules = sheets[i].cssRules;
			if(rules.length > 0) {
				for(var j = 0; j < rules.length; j++) {
					var s = rules[j].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[j] == e) {
							return s[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((s[p] != "") && (s[p] != null)) &&
						   (rules[j].selectorText == e)) {
							return s[p];
						}
					}

				}
			}
		}
	}

	// if we don't find any style sheets, return the value for the first
	// element of this type we encounter without a CLASS or STYLE attribute
	var elements = document.getElementsByTagName(e);
	var sawClassOrStyleAttribute = false;
	for(var i = 0; i < elements.length; i++) {
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if((node.attributes.item(j).nodeName == 'class') ||
			   (node.attributes.item(j).nodeName == 'style')){
			   sawClassOrStyleAttribute = true;
			}
		}
		if(! sawClassOrStyleAttribute) {
			return elements.item(i).style[p];
		}
	}
}
//======================================
//======================================koniec modyfikacja stylow

