"use strict";if(!this.JSON){this.JSON={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());




function concise(){var o=document.getElementsByTagName("object");for(var i=0;i<o.length;i++){o[i].outerHTML=o[i].outerHTML;}}
concise.g=function(i){if(document.getElementById(i)){return document.getElementById(i);}else{return false}}
concise.GetXmlHttpObject=function(){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;}

concise.CurrencyFormatted=function(amount){
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}


concise.changePrice=function(i,a,b,c,w,d){
	var selectedIndeks=concise.g("size"+i).options[concise.g("size"+i).selectedIndex].value;
	var price=(a[selectedIndeks]);
	var specialPrice=(b[selectedIndeks]);
	var wspecialPrice=String(c[selectedIndeks]);
	var code=d[selectedIndeks];
	if(specialPrice!=0){
		concise.g("wprice"+i).className="specialprice";
		concise.g("price"+i).className="specialprice";
		concise.g("price"+i).innerHTML=concise.CurrencyFormatted(specialPrice);
		concise.g("oprice"+i).innerHTML=w+": "+concise.CurrencyFormatted(price);
		concise.g("hprice"+i).value=concise.CurrencyFormatted(specialPrice);
		concise.g("hcode"+i).value=code;
	}else{
		concise.g("wprice"+i).className="normalprice";
		concise.g("price"+i).className="normalprice";
		concise.g("wprice"+i).innerHTML=w+": ";
		concise.g("price"+i).innerHTML=concise.CurrencyFormatted(price);
		concise.g("oprice"+i).innerHTML="";
		concise.g("hprice"+i).value=concise.CurrencyFormatted(price);
		concise.g("hcode"+i).value=code;
	}
}
concise.addChart=function(u,i,a){
	//concise.g("chartId"+i).style.display='none';
	//concise.g("loading"+i).style.display='block';
	var xmlHttp=concise.GetXmlHttpObject();
	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
	}else{
		var amount=concise.g("amount"+i).value;
		if(concise.g("size"+i)){
			var size=concise.g("size"+i).value;
		}else{
			var size=0;
		}
		var price=(concise.g("hprice"+i).value);
		var code=concise.g("hcode"+i).value;
		
		
		if(parseInt(amount)>0&&parseInt(i)>0){
			var url=u+"&basket_id="+i+"&amount="+amount+"&size="+size+"&price="+price+"&code="+code+"&"+Math.random()+"/";
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=function(){
				if(xmlHttp.readyState!=4) return;
				if(xmlHttp.status!=200) return;
				var r=JSON.parse(xmlHttp.responseText);
		    concise.g("basketMsg").innerHTML=""+r['result'];
		    //concise.g("chartId"+i).style.display='block';
		    //concise.g("loading"+i).style.display='none';
		    /*if(r['status']!='1'){concise.addChart(u,i,a);}*/
			}
			xmlHttp.send(null);
			
		}else{
			alert(a);
			//concise.g("chartId"+i).style.display='block';
			//concise.g("loading"+i).style.display='none';
		}
	}
}
this.concise();



jQuery.noConflict();
	jQuery(document).ready(function(){
     jQuery(".chartBtn").click(function(){
			var productIDVal=(this.id).substring(6);
			var productX=jQuery("#productImageWrapID_" + productIDVal).offset().left;
			var productY=jQuery("#productImageWrapID_" + productIDVal).offset().top;
			
			var basketX=jQuery("#basketMsg").offset().left;
			var basketY=jQuery("#basketMsg").offset().top;
			
			var gotoX 			= basketX - productX;
		var gotoY 			= basketY - productY;
		
		var newImageWidth 	= jQuery("#productImageWrapID_" + productIDVal).width() / 3;
		var newImageHeight	= jQuery("#productImageWrapID_" + productIDVal).height() / 3;
		
		jQuery("#productImageWrapID_" + productIDVal + " img")
		.clone()
		.prependTo("#productImageWrapID_" + productIDVal)
		.css({'position' : 'absolute'})
		.animate({opacity: 0.8}, 100 )
		.animate({opacity: 0.8, marginLeft: gotoX, marginTop: gotoY, width: newImageWidth, height: newImageHeight}, 1200, function() {
		
$(this).remove();
});
																																																																										  			
																																																																										  			
	
			
			
	});
});








function printPage(){
	if (window.print)
  	window.print()
  else
		alert("Your browser probably does't support Javascript");
}
var windowNote;
function showPic(title, pic, colorBack, wid, hei, idee){
	var idee = idee|| "default";
	windowNote = window.open('','Note'+ idee,'top=5, left=5, toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=' + wid + ',height='+ hei);
	image = '<a href="javascript:window.close()"><img src="'+ pic +'" width="'+ wid +'" height="'+ hei +'" border="0" alt="X"></a>';
	text = "<html><head><META HTTP-EQUIV=\"imagetoolbar\" CONTENT=\"no\"><title>"+ title + "</title></head><body bgcolor=\"#" + colorBack +"\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">" + image + "</body></html>";
	windowNote.document.write(text);
	windowNote.focus();
	windowNote.document.close();
	return false;
}
var type = "IE";
BrowserSniffer();
function BrowserSniffer(){
	if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";	//Opera
	else if (document.all) type="IE";							//Internet Explorer e.g. IE4 upwards
	else if (document.layers) type="NN";							//Netscape Communicator 4
	else if (!document.all && document.getElementById) type="MO";				//Mozila e.g. Netscape 6 upwards
	else type = "IE";									//I assume it will not get here
}
function hide_div(div_name)
{
	if (type=="IE") eval("document.all."+div_name+".style.display='none'");
	if (type=="NN") eval("document."+div_name+".display='none'");
	if (type=="MO" || type=="OP") eval("document.getElementById(div_name).style.display='none'");
}
function showhide_div(div_name){
	if (type=="IE"){
		if(eval("document.all."+div_name+".style.display")!='none'){
			eval("document.all."+div_name+".style.display='none'");
		}else{
			eval("document.all."+div_name+".style.display='block'");
		}
	}
	if (type=="NN"){
		if(eval("document."+div_name+".display")!='none'){
			eval("document."+div_name+".display='none'");
		}else{
			eval("document."+div_name+".display='block'");
		}
	}
	if (type=="MO" || type=="OP"){
		if(eval("document.getElementById('"+div_name+"').style.display")!='none'){
			eval("document.getElementById('"+div_name+"').style.display='none'");
		}else{
			eval("document.getElementById('"+div_name+"').style.display='block'");
		}
	}
}
function submit_form(){
	document.getElementById('vorm').submit();
}
function reset_form(){
	document.getElementById('vorm').reset();
}
function change_picture(id){
	document.getElementById('mainpic').src=id;
}
