function showLargeImage(num){
	for(var i=1;i<9;i++){
			$('.largediv' + i).hide();
		}
		$('.largediv' + num).show();
}	
function checkterms(){
	if(!document.getElementById('terms').checked){			
		alert("Please agree to our terms and conditions");
		return false;
	}else {
		if($('#aboutus').val()!=0){ 
			var aboutus='';
			if($('#aboutus').val()!='other'){
				aboutus=$('#aboutus').val();
			}else{
				aboutus=$('#otheraboutus').val();
			}
			$.get('/courses/storeaboutus.php', {aboutus:aboutus});
		}
		return true;
	}
}
function CopyShippingToBilling(){
	var billing= document.getElementById("billingaddress");
	var shipping= document.getElementById("shippingaddress");
	var billingcode= document.getElementById("billingpostcode");
	var shippingcode= document.getElementById("shippingpostcode");
	shipping.value=billing.value;
	shippingcode.value=billingcode.value;
}
function productInfoSetup(){	
	$('.productlargeimage').show();
	for(var i=2;i<9;i++){
		$('.largediv' + i).hide();
	}	
	for(var i=1;i<5;i++){
		$('.print' + i).hide();
	}	
}
function archiverequest(id){
	document.location='/support/sendtoarchive.php?id=' + id;
}
function clearsearch(){
	$('#searchbox').val('');
	$('#searchbox').css('color','black');
}
function addpost(){
	$('#forumpost').show();
	return false;
}
function checkcountry(){
	var countryarray=['Austria', 'Belgium', 'Bulgaria', 'Czech Republic', 'Denmark', 'Estonia', 'Finland', 'France', 'Germany', 'Greece', 'Hungary', 'Italy', 'Latvia', 'Lithuania', 'Luxembourg', 'Netherlands', 'Poland', 'Portugal', 'Romania', 'Slovakia', 'Slovenia', 'Spain', 'Sweden'];
	if($('#countrylist').val()=='United Kingdom'){
		document.location='changedelivery.php?id=1&c='+$('#countrylist').val();
	}else if($('#countrylist').val()=='Ireland'){
		document.location='changedelivery.php?id=2&c='+$('#countrylist').val();
	}else if(in_array($('#countrylist').val(),countryarray)){
		document.location='changedelivery.php?id=3&c='+$('#countrylist').val();
	}else{
		document.location='changedelivery.php?id=4&c='+$('#countrylist').val();
	}
}
function in_array (needle, haystack, argStrict) {
    // Checks if the given value exists in the array  
    // 
    // version: 1009.2513
    // discuss at: http://phpjs.org/functions/in_array    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: vlado houba
    // +   input by: Billy
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);    // *     returns 1: true
    // *     example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'});
    // *     returns 2: false
    // *     example 3: in_array(1, ['1', '2', '3']);
    // *     returns 3: true    // *     example 3: in_array(1, ['1', '2', '3'], false);
    // *     returns 3: true
    // *     example 4: in_array(1, ['1', '2', '3'], true);
    // *     returns 4: false
    var key = '', strict = !!argStrict; 
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {                return true;
            }
        }
    }
     return false;
}
function vidlinkhover(thisorder,mainorder,courseid){
	$('.vids').css('background', 'white');
	$('#vid'+mainorder).css('background', '#EC008B');
	$('#vid'+thisorder).css('background', '#F9B3DC');	
}
function vidlinkhoverout(thisorder,mainorder,courseid){	
	$('#vid'+thisorder).css('background', 'white');	
	$('#vid'+mainorder).css('background', '#EC008B');
}
function updatevideo(id,videonum){
	var loc='videodisplay.php?id='+id+'&videonum='+videonum;
	document.location=loc;
}
function updatevideoprev(id,videonum){
	var loc='how_ecourses_work1.php?id='+id+'&videonum='+videonum;
	document.location=loc;
}
function displaygalleryimage(id,type,desc){
	$('#mainimage').attr('src', '/galleryimages/'+id+'_1_l.'+type);
	$('#maindesc').html(desc);
	return false;
}
function drawgallery(id,start, newid){ 
	newid=parseInt(newid);
	if(newid>0){ 
		$.get('drawgallery2.php', { id:id, start:start, newid:newid },function(data){
			$('#gallerycontent').html(data);		
			return false;
		});
	}else{ 
		$.get('drawgallery2.php', { id:id, start:start },function(data){
			$('#gallerycontent').html(data);
			return false;
		});
	}
}
function drawlargegallery(id,start){ 
	$.get('drawgallery1.php', { id:id, start:start },function(data){
		$('#gallerycontent').html(data); 
		return false;
	});
}
$(document).ready(function(){		
	$('.lightgallery a').lightBox(); 
	//throbFade();
});
