function checkForm()
{
	contactform=document.contactForm;
	at=contactform.email.value.indexOf("@")
	dots = contactform.email.value.indexOf(".")
	if (at == -1 || dots<1){
		alert("Please enter a valid E-mail Address")
		return false
		}
	if (contactform.contactName.value <=0){
		alert("please enter your name " );
		return false
		}	
	if (contactform.enquiry.value.length<1){
		alert("Have you entered a message?" );
		return false
		}	
}




function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function pageInit(){
	if(typeof current_images!='undefined'){
		/* select either gallery or sinle image mode*/ 
		if(current_images.length>1){
			
		doGallery();
		}else if(current_images.length ==1 ){
			
		doImage();
		}
	}
}

////////////////////////////////////////////
//     Image functions                 ////
////////////////////////////////////////////

function doGallery(){// this code makes the gallery thumbs

	if (typeof gal == 'undefined'){
	//if the page has just loaded
	var request= window.location.href;
		if ( request.indexOf("&")>0){// check the url for an image string
		
		
			/************* map the prodid array across the currentimages for bookmarking *********/
			var pMap =new Array;
			for(var i=0; i< current_images.length;i++ ){
			pMap[i]=current_images[i].prodcode;
			}
			//alert(pMap)
			/*******************************/

			var request= request.split('p=');
			var request = request[1];
			request = pMap.indexOf(request);
			showImage(request);
			}else{showImage(0);// nothing requested? so show image [0]
			}
		}
	
	gal='<div id="thumblock">';
	if (typeof prodgal !='undefined'){gal+="<div id='prodstylebar'>Select a Style</div>"}
	  for(i=0;i<current_images.length;i++){
		var imgname =imgfolder + current_images[i].path + '/thumbs/thum_'+ current_images[i].file;
		//file,path,credits,comment
		var title = current_images[i].title; 
		
		
		if (typeof prodgal !='undefined'){
			gal+='<div class="prodthumb"><a href="javascript:showImage('+i+')" class="imgwrap">';
			
			if (imgname.indexOf('jpg') <1 || imgname.length <4 ){
				gal+=current_images[i].prodcode;
				}else{
				gal+='<img src="'+ imgname +'" alt="'+ current_images[i].prodcode+'" border="0">';
				}
			
			
			gal+='</a><p>'+ current_images[i].title +' '+ current_images[i].pdesign +'</p></div>';
			
			
		}else{
			gal+='<div class="thumb floatleft"><a href="javascript:showImage('+i+')"><img src="'+ imgname +'" alt="'+ current_images[i].caption+'" border="0"></a></div>';}
		
	}	
	gal+=('<div class="clearall"><br></div></div>');
	update('thumbs',gal);
}

function doImage(){ /* a single image */

var imgname =imgfolder+ current_images[0].path +'/'+ current_images[0].file;
var bigimage = imgfolder+ current_images[0].path +'/full/full_'+ current_images[0].file;


	if (typeof current_images[0].comment !='undefined'){
	var comment = current_images[0].comment;
	}else{comment=''} 

var data='<a href="'+bigimage+'" target="_blank"><img src="'+imgname+'" id="currentimage" alt="'+comment+'"></a>';
	data +='<p class="img_caption">'+comment+'</p>';
update('bigImage',data);
}

/************  show the chosen picture  ***********/
function showImage(imgval){
	arraypos=imgval;
	//alert (imgval);
	if (arraypos <0){arraypos= current_images.length-1; showImage(arraypos)};
	if (arraypos >=current_images.length){arraypos=0;showImage(arraypos)};

	if (typeof current_images[imgval].comment !='undefined' && typeof prodgal =='undefined' ){
	var comment = current_images[imgval].comment;
	}else{comment=''}	

/*bookmark code*/
/*if (typeof current_images[imgval].prodcode != 'undefined'){
	if(window.location.href.indexOf('p=')>0){
		var request= window.location.href.split('p=');
	window.location = request[0] +'p='+current_images[imgval].prodcode;
		}
	}*/
/**/
	var imgname =imgfolder+ current_images[arraypos].path +'/'+ current_images[arraypos].file;
	var bigimage = imgfolder+ current_images[arraypos].path +'/full/full_'+ current_images[arraypos].file;
	var title = current_images[arraypos].title;
var data='';
data+='<a href="'+bigimage+'" target="_blank" id="zoom"></a>';

// next&back 
if (typeof prodgal !='undefined'){
	data += '<div align="center" id="showImageText">';
	data += '<a href="javascript:showImage(arraypos-1);">Previous</a>';
	data +=' | '+(arraypos +1) + ' of '+ current_images.length + ' | ';
	data += '<a href="javascript:showImage(arraypos+1);">Next</a><br></div>';
	}
	
	data += '<a href="'+bigimage+'" target="_blank"><img src="'+imgname+'" id="currentimage" alt="'+comment+'"></a><div  class="img_caption"><p>'+comment+'</p></div>';
	

	
	update('bigImage',data);
	
	if (typeof prodgal !='undefined'){
		/* do the product info panel*/
		
		data= '<h3>'+current_images[arraypos].title+'</h3>';
		data+= '<p>Design : '+current_images[arraypos].pdesign + '</p>';
		data+= '<p>Product Code : '+current_images[arraypos].prodcode + '</p><br>';
		data+=current_images[arraypos].comment;
		update('imageinfo',data);
		}
	
}

function popwin(url,num){
	newwindow=window.open(url,'Davida','height=400,width=600, scrollbars=1');
	if (window.focus) {newwindow.focus()}
	document.num=num;
}



function update(target,data) { 
var ie4=Boolean(document.all && !document.getElementById);
var target=(ie4)?document.all[target]:document.getElementById(target);
target.innerHTML=data;
}

 $(document).ready(function(){// this is the new jQuery menu code
    $("ul.dropdown li").hover(function(){  
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    }, function(){
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    });
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");

});


/*
function evilBrowsers(){
	if (!navigator.appName.indexOf('Microsoft'))
	alert('god damn '+ navigator.appName);
	}
*/

