﻿function checkWindow() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  document.getElementById('main').style.height = myHeight + "px"; 
  
  // vaststellen van de gewenste hoogte container
  containerTop = parseInt(((myHeight - 670) / 2) - 20);
  if(containerTop < 0){containerTop = 10;}
  document.getElementById("container").style.paddingTop = containerTop + "px";
  
     
}


function checkForm(item){
	
	error = 0;
	
	for (i = 0; i < document.forms[0].elements.length; i++) 
		{
			if(document.forms[0].elements[i].type != "submit")
				{
					document.forms[0].elements[i].style.borderColor = "#000000";
				}
			
		}
	
	if(item.naam.value.length == 0)
		{
			item.naam.style.borderColor = "#ff0000";
			error += 1;
		}
		
	if(item.informatie.value.length == 0)
		{
			item.informatie.style.borderColor = "#ff0000";
			error += 1;
		}
		
	var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
	
	if(illegalChars.test(item.emailadres.value) || !emailFilter.test(item.emailadres.value))
		{
			item.emailadres.style.borderColor = "#ff0000";
			error += 1;
		}
	
}

// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
    //alert('About to submit: \n\n' + queryString); 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    if(error == 0)
		{
			return true;
		}
	
	else
		{
			return false;
		}
} 



// post-submit callback 
function showResponse(responseText, statusText)  { 
    // for normal html responses, the first argument to the success callback 
    // is the XMLHttpRequest object's responseText property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'xml' then the first argument to the success callback 
    // is the XMLHttpRequest object's responseXML property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'json' then the first argument to the success callback 
    // is the json data object returned by the server 
 
    //alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
    //    '\n\nThe output div should have already been updated with the responseText.'); 
	
	$.fn.colorbox({open:true, maxWidth: 400, inline:true, href:"#responseForm"});
} 

//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use

$(document).ready(function()
{

    var options = { 
        target:        '#responseForm',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse  // post-submit callback 
 
        // other available options: 
        //url:       url         // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 
 
    // bind form using 'ajaxForm' 
    $('#ajaxForm').ajaxForm(options);

    $("#contactBox").colorbox({width:"400px", inline:true, href:"#ajaxForm"});

    

    $("a.gocolorboxparam").colorbox({width:"600px", inline:true, href:function(){
        var elementID = '#box-' + $(this).attr('id');
        return elementID;
    }});

    $("#menuContainer ul li").hover(
        function () {
            $(this).addClass("hover");
        },
        function () {
            $(this).removeClass("hover");
        }
    );

    
    
    checkWindow();

    $(".required").append("<img src='assets/templates/codeplaza.com/images/bullet_star.png' />");

      $("#desSlideshow").desSlideshow({
            autoplay: 'enable',//option:enable,disable
            slideshow_width: '680',//slideshow window width
            slideshow_height: '266',//slideshow window height
            thumbnail_width: '200',//thumbnail width
            time_Interval: '4000',//Milliseconds
            directory: 'assets/templates/codeplaza.com/images/'// flash-on.gif and flashtext-bg.jpg and loading.gif directory
        });
    
    $("a.gocolorbox").colorbox({width:"800px"});

    $(".switchBigPic a").colorbox({width:"80%", height:"80%",iframe:true});
	
});
