// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

PositionX = 10;
PositionY = 10;

defaultWidth = 50;
defaultHeight = 50;

var AutoClose = false;

if (parseInt(navigator.appVersion.charAt(0))>=4){
 var isNN=(navigator.appName=="Netscape")?1:0;
 var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
 var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
 var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
 function popImage(imageURL,imageTitle, text){

 if (isNN){imgWin=window.open('about:blank','',optNN);}
 else if (isIE){imgWin=window.open('about:blank','',optIE);}
 else {imgWin=window.open('about:blank','',optNN);}
 with (imgWin.document){
	 writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
	 writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');
		writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN=(navigator.appName=="Netscape")?1:0;');
			writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');
				writeln('if (isIE){');
					writeln('window.resizeTo(300,300);');
					writeln('width=300-(document.body.clientWidth-document.images[0].width);');
					writeln('height=320-(document.body.clientHeight-document.images[0].height);');
					writeln('window.resizeTo(width,height);}');
				writeln('if (isNN){');
					writeln('window.innerWidth=document.images["Vissauto"].width;');
					writeln('window.innerHeight=document.images["Vissauto"].height+20;}');
				writeln('else {');
					writeln('window.resizeTo(300,300);');
					writeln('width=300-(document.body.clientWidth-document.images[0].width);');
					writeln('height=320-(document.body.clientHeight-document.images[0].height);');
					writeln('window.resizeTo(width,height);}');

				writeln('}');
			writeln('function doTitle(){document.title="'+imageTitle+'";}');
	 writeln('</sc'+'ript>');
 if(!AutoClose) 
	writeln('</head><body bgcolor="FFFFFF" scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
 else writeln('</head><body bgcolor="FFFFFF" scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');

	writeln('<center><a href="javascript:;" OnClick="window.close()" style="color:black; text-decoration: none">\n\
                    <img name="Vissauto" src="'+imageURL+'" style="border:0; display:block">'+text+'</a></center>\n\
                </body></html>');
 close();
}}

// end CodeLifter.com
/*
function popupWindow(url) {
				window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=5,left=5')
			}
	*/		
/*
$(document).ready(function() { 
//	$("a.lightbox").lightBox();

	$("img.pop").css('cursor', 'pointer').click(function(){ 

		img_url = $(this).attr('src');
		img_title = $(this).attr('title');
		popImage(img_url, img_title);

    }); 
//	img_url = $("a.lightbox").attr('src');
//	img_title = $("a.lightbox").attr('title');
//	popImage(img_url, img_title);
}); 
*/

function submit_form(theform) {		
	 sr = eval("document."+theform);
   	 sr.submit();
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=300,height=300,screenX=150,screenY=150,top=150,left=150');
}			



function AnySelected() {



for (i = 1; i < document.forms['selecta'].elements.length; i++)

		if(document.forms['selecta'].elements[i].type == "checkbox") {
			if(document.forms['selecta'].chbx.checked==true) 
				document.forms['selecta'].elements[i].checked=true;
			else 
				document.forms['selecta'].elements[i].checked=false;
		}
		
}



function toggleVisibility(me) {
	if (me.style.visibility=="hidden") {
		me.style.visibility="visible";
	} else {
		me.style.visibility="hidden";
	}
}

function blocking(nr)
{
	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}


// dlja subgroup 4to b menjalasj
function change_subgroup(url,div) {
	
	// sbrosi divov
	if(div=="engine"||div=="years"||div=="models") {
	   $("#engine").html("");      
	   $("#body").html("");
	}
	
	if(div=="years"||div=="models") {
	   $("#years").html("");   
	}
	
	if(div=="models") {
	   $("#models").html("");
	}



	$.getJSON(url,
              {
               make: $("#make").val(),
               models: $("#models").val(),
               years: $("#years").val(),			   
               engine: $("#engine").val(),			   			   

			   type: div
              }, function (j) {
				   var options = '';
 	 			   for(var i = 0; i < j.length; i++) 
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
				   $("#"+div).html(options);
                 	
				 }

    );
}

function form_valid(form,hidd,err_name,err_surname,err_phone) {		
		 if (validate(form,err_name,err_surname,err_phone)) {
			 way=eval("form."+hidd);
			 way.value='ok';
			 form.submit();
		 }
	}


function validate(selff,err_name,err_surname,err_phone){
		var err = [];
			if(selff==document.order_form) {
					if(selff.name.value == '' ) 
						err[err.length] = err_name;

					if(selff.surname.value == '' )
						err[err.length] = err_surname;

					if(selff.phone.value == '' )
						err[err.length] = err_phone;
					
			}

		return error(err);
	}


	
function isValidEmail(email){
	return email.match(/^([-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+)@([-0-9A-Z]+\.)+([0-9A-Z]{2,4})$/i);
}


	
function error(err){
	if(err.length > 0){
		alert(err.join("\n\n"));
		return false;
	} else return true;
}


function submit_form(theform) {		
	 sr = eval("document."+theform);
   	 sr.submit();
}

function filter_ajax(url, last_url, selbox) {
//	sel = eval("#"+selbox);
/*
alert(last_url);
	alert(selbox);
	alert($('#'+selbox).val());
	*/
/*
	$.getJSON(url,
              {
               column: selbox,
               value: $('#'+selbox).val(),
               categ: last_url,			   
              }, function (j) {
				   var options = '';
 	 			   for(var i = 0; i < j.length; i++) 
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
				   $("#"+div).html(options);
                 	
				 }

    );
	*/
}
