
$(function(){
        $('.slide-out-div').tabSlideOut({
            tabHandle: '.handle',                     //class of the element that will become your tab
            pathToTabImage: 'images/contact_tab.gif', //path to the image for the tab //Optionally can be set using css
            imageHeight: '329px',                     //height of tab image           //Optionally can be set using css
            imageWidth: '40px',                       //width of tab image            //Optionally can be set using css
            tabLocation: 'right',                      //side of screen where tab lives, top, right, bottom, or left
            speed: 300,                               //speed of animation
            action: 'click',                          //options: 'click' or 'hover', action to trigger animation
            topPos: '140px',                          //position from the top/ use if tabLocation is left or right
            leftPos: '20px',                          //position from left/ use if tabLocation is bottom or top
            fixedPosition: true                      //options: true makes it stick(fixed position) on scroll
        });

    });

	
//form submit
function validate(formData, jqForm, options) { 
var form = jqForm[0]; 
if (!form.myFormInfo.value || !form.myFormText.value)
	{
	alert('Annathan sähköpostiosoitteesi taikka puhelinnumerosi!'); 
	return false; 
	}
$('#formpiilota').css("display", "none");

}

function showResponse(responseText, statusText, xhr, $form)  { 

 alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
        '\n\nThe output div should have already been updated with the responseText.'); 
} 

// wait for the DOM to be loaded 
$(document).ready(function() { 
	//document.getElementById('slideout').style.display='block';
	
	
	var options = { 
        target:        '#output2',   
        beforeSubmit:  validate 
        //success:       showResponse  
		};
		
//bind
$('#myForm').submit(function() { 
        $(this).ajaxSubmit(options); 
		//google analytics ajaxtracking - vinyylitalo
		_gaq.push(['_trackEvent', 'klikkaukset', 'reunapalauteklikkaus', 'submitnappi']);		
        return false; 
    }); 


//colorbox	
$("a[rel='lightbox']").colorbox();	
$("a[rel='colorbox']").colorbox();
$(".tubevideo").colorbox({iframe:true, innerWidth:640, innerHeight:390});


if(slideoutnakyvissa) //php asettaa kielen perusteella
	{
	$('#slideout').css("display", "block");
	}
	

	
//$('#paneelivari').keypress(paneelivari);
//$('#paneelivari').change(paneelivari);
$('#paneelivari').click(paneelivari);
$('#paneelivari').focusin(paneelivari);

//$('#paneelimalli').keypress(paneelimalli);
//$('#paneelimalli').change(paneelimalli);
$('#paneelimalli').click(paneelimalli);
$('#paneelimalli').focusin(paneelimalli);


//bind
$('#naytetilausform').submit(function() { 
        
		
	var formval = $('[name=paneelimalli]').val();
	
	if (formval == '')
		{
		alert('Paneelin malli täytyy valita'); 
		return false; 
		}

	formval = $('[name=paneelivari]').val();
	if (formval == '')
		{
		alert('Paneelin väri täytyy valita'); 
		return false; 
		}
	
	formval = $('[name=realname]').val();
	var formval1 = $('[name=lahiosoite]').val();
	var formval2 = $('[name=postinumero]').val();
	var formval3 = $('[name=paikkakunta]').val();
	
	if (formval == '' || formval1 == '' || formval2 == '' || formval3 == '')
		{
		alert('Näytepaketin toimittamista varten tarvitsemme yhteystietosi'); 
		return false; 
		}
	
	formval = $('[name=email]').val();
	if (formval == '')
		{
		alert('Sähköpostiosoite vaaditaan'); 
		return false; 
		}
		
	if (!validate_email(formval)) return false;

		
		
        return true; 
    }); 


	
}); 
/* DOCUMEN READY LOPPU */



var piiloaika;
piiloaika=1;


function asetaaika(){
piiloaika=1;
}

function validate_email(address)
{
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/; 
var valresult;
if(address.length <1)
	{
	//ei emailia, jatkuu
	return -1;
	}
valresult=emailPattern.test(address);
if(valresult != 1)
	{
	alert('Tarkistathan sähköpostiosoitteen oikeellisuuden');
	return false;
	}
else return true;
}

/*Gallerian popuppi */
function galleriapop(sPicURL) { 
			gkuvapop=window.open("galleriapop.php?file="+sPicURL, "galleriapopname","resizable=1 toolbar=no, resizable=yes, scrollbars=yes, height=420,width=400, screenX=160,screenY=100,top=100,left=160");
			setTimeout("gkuvapop.focus()",1);
			
			return false;

			}
		
function popp() { 
			window.open("popup.php","title","resizable=1 toolbar=no, resizable=yes, scrollbars=yes, height=420,width=400, screenX=160,screenY=100,top=100,left=160");
			}





function toggle_visibility(id) {
       var e = document.getElementById(id);
	   if(piiloaika)
	   {
	   piiloaika=0;
       if(e.style.display == 'block' || e.style.display =='')
          e.style.display = 'none';
       else
          e.style.display = 'block';
	   
	   setTimeout("asetaaika()",250);
	   }
    return false;
	}



function sendText(e, text) 
{ 
  e.value = text 
}

function putsaamaili(e,alue)
{
var arvo = document.getElementById(e).innerHTML;
arvo=arvo.replace(/\s/g,'');
arvo=arvo.replace('[at]','@');
document.getElementById(e).innerHTML=arvo;
document.getElementById(alue).onmousedown = null;
}

function paneelivari()
{
if($('#paneelivarikuvat').attr('display') !='block')
	{
	$('#paneelivarikuvat').show();
	$('#paneelimallikuvat').hide();
	}
	

}

function paneelimalli()
{
if($('#paneelimallikuvat').attr('display') !='block')
	{
	$('#paneelimallikuvat').show();
	$('#paneelivarikuvat').hide();
	}
	

}

