// preloader 
var menu='';
var registerArray = new Array();
orderArray=[0,0,0,0];
function preLoader()
{
	$('content').innerHTML='';
new Insertion.Top('content','<div id="animate" style="display:block; padding-top:50px;" align="center"><img src="images/load.gif" /></div>');	
}
////////////////////////////////////
var productWindow;

function showDetail(idPort)
{
if(productWindow != null){
productWindow.destroy();
}

if (idPort=='cvDetail')
{
productWindow = new Window({width:580,resizable: false,draggable:true,className:"alphacube",height:340});
//productWindow.setAjaxContent('agents/window.php',{parameters:{},method:"post"});
productWindow.setContent(idPort);
productWindow.setLocation(50,260);
productWindow.setZIndex(1000);
productWindow.show();

}
else
{
productWindow = new Window({width:460,resizable: false,draggable:true,className:"alphacube",height:568});
//productWindow.setAjaxContent('agents/window.php',{parameters:{},method:"post"});
productWindow.setContent(idPort);
productWindow.setLocation(50,260);
productWindow.setZIndex(1000);
productWindow.show();
}}


function changeTopImage()
{
$('topImage').src='images/onas_tyt.gif';	
}


function getContent(what,par,picture)
{
	orderArray=[0,0,0,0];
if (what==menu && par==0)
{
return false;
}
else
{

changeTopImage();
if (menu=='')
{
menu='index';
}
if (what=='index')
{
$('topImage').src='images/t_center.gif';	
}

if(what!='frames' && what!='noframes'){
$(menu).removeClassName(menu+'Hov');
$(what).addClassName(what+'Hov');
menu=what;
}
else
{
$(menu).removeClassName(menu+'Hov');
menu='index';

}
Effect.Fade('contentIn');
stopper('contentIn',what,par,picture);
orderArray=[0,0,0,0];

}}
///////// inicjalizacja scrola po zaladowaniu zawartosci

function scrollInit(contener,page)
{
	
if (!$(contener).visible()){
setTimeout(function(){scrollInit(contener,page)},100);
}
else
{

if (page==0){
ScrollLoad ('scrollholder', 'scroll', false);
ScrollLoad ('scrollholder1', 'scroll1', false);
	}
	if (page==1){
ScrollLoad ('scrollholder2', 'scroll2', false);
	}
}
}

//////////////////////////////////////////////////////
function stopper(contener,x,par,xpicture)
{

if ($(contener).visible()){
setTimeout(function(){stopper(contener,x,par,xpicture)},1000);
}
else
{
	if(par==0){
		var pars='';
		}
		else
		{
	var pars='authorId='+par+'&picture='+xpicture;	
		}

var url = 'agents/'+x+'.php5';
new Ajax.Updater('content', url, {method: 'post', parameters: pars});
$('content').hide();
Effect.Appear('content');
if (x=='artist'){scrollInit('contentIn',0);

}
if (x=='frames' || x=='noframes'){scrollInit('contentIn',1);}
}
}



/////////////////////////////////////////////////////
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	
}

function order(id,picture,author,catalog,title,size1,price1,size2,price2,size3,price3,size4,price4,material,what)
{
if(productWindow != null){
productWindow.destroy();
}
productWindow = new Window({width:450,resizable: false,draggable:true,className:"alphacube",height:630});
if (what=='frames')
{
var pars ='id='+id+'&picture='+picture+'&author='+author+'&title='+title+'&size='+size1+'&price='+price1+'&material='+material+'&what='+what;

}
else
{
	
var pars ='id='+id+'&picture='+picture+'&author='+author+'&catalog='+catalog+'&title='+title+'&size1='+size1+'&price1='+price1+'&size2='+size2+'&price2='+price2+'&size3='+size3+'&price3='+price3+'&size4='+size4+'&price4='+price4+'&what='+what;
}

productWindow.setAjaxContent('agents/orderP.php5',{parameters:pars,method:"post"});

//productWindow.setContent('orderWin');
productWindow.setLocation(50,260);
productWindow.setZIndex(1000);
productWindow.show();
	}
	
function formatPrice(format)
{
	if (format==0)
	{
	$('orderPPrice').value=format;
	}
	else
	{
	$('orderPPrice').value=format;
	}
}



function checkOrder(form)
{
var email=$F('orderPEmail');
var orderPLname=$F('orderPLname');
var orderPPhone=$F('orderPPhone');
var orderPFormat=$F('orderPFormat');
var validEmail= /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;

		if ((email=="") && (orderArray[0]==0)){
	
		orderArray[0]=1;
		$('orderPEmail').addClassName('input_err');
		}
		else if ((!validEmail.test(email)) && (orderArray[0]==0)){
		orderArray[0]=1;
		
		$('orderPEmail').addClassName('input_err');
		}
		else if((email!="") && (orderArray[0]==1) && (validEmail.test(email)) ){
		orderArray[0]=0;	
		$('orderPEmail').removeClassName('input_err');
		}
		if ((orderPLname=="") && (orderArray[1]==0)){
		orderArray[1]=1;
		$('orderPLname').addClassName('input_err');
			Effect.Pulsate('orderPLname',{duration:2,from:0.4,pulses:3});
		}
		else if ((orderPLname!="") && (orderArray[1]==1)){
		orderArray[1]=0;
		$('orderPLname').removeClassName('input_err');
		
		}
		if ((orderPPhone=="") && (orderArray[2]==0)){
		orderArray[2]=1;
		$('orderPPhone').addClassName('input_err');
			Effect.Pulsate('orderPPhone',{duration:2,from:0.4,pulses:3});
		}
		else if ((orderPPhone!="") && (orderArray[2]==1)){
		orderArray[2]=0;
		$('orderPPhone').removeClassName('input_err');
		}
		if ((orderPFormat=="") && (orderArray[3]==0)){
		orderArray[3]=1;
		$('orderPFormat').addClassName('input_err');
		Effect.Pulsate('orderPFormat',{duration:2,from:0.4,pulses:3});
		
		}
		else if ((orderPFormat!="") && (orderArray[3]==1)){
		orderArray[3]=0;
		$('orderPFormat').removeClassName('input_err');
		}

if(orderArray.indexOf(1)!=-1){
}
else
{
//productWindow.destroy();
var pars = $(form).serialize()+'&what='+form;
if(productWindow != null){
productWindow.destroy();
}
productWindow = new Window({width:460,resizable: false,draggable:true,className:"alphacube",height:200});
productWindow.setAjaxContent('agents/email.php5',{parameters:pars,method:"post"});

productWindow.setLocation(50,260);
productWindow.setZIndex(1000);
productWindow.show();

}}
function addTip(id,autor,title)
{
new Tip(id,autor,{className:'darktip',offset: {x:20, y:20},title:title});
}

