
//alert("js is loaded")
//**************************
/////Image window size//////
//**************************

function setWindowSize (images){
	
var imgWidth  = "0";
var imgHeight = "0";
	myImg=new Image(); 
	myImg.src = '../images/'+images+'a.jpg';
		while(myImg.complete){		
			window.status = "loading Image";
		break
		}
			var tempimgWidth = myImg.width;
			var tempimgHeight = myImg.height;
			imgWidth = tempimgWidth;
			imgHeight = tempimgHeight;
//alert("imgHeight "+imgHeight)
//alert("imgWidth "+imgWidth)
		launchWindowGallery('../includes/pop.htm?image='+images+'a.jpg&width='+imgWidth+'&height='+imgHeight,imgHeight+35,imgWidth+12);
}

//**************************
///END Image window size////
//**************************
//**************************
///// Launch Window   //////
//**************************
function launchWindowGallery(url,h,w) {
	var width=(w);
	var height=(h);
	var left = (screen.width/2 - width/2);
  	var top = (screen.height/2 - height/2);
 	var messWinStyle = 'width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top+',titlebar=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resize=0,copyhistory=1';
	window.open(url,'title',messWinStyle);
}
//**************************
///// Launch Window   //////
//**************************

function validate(formData,a){
var message = "------------------------------------------------------------------   \n*     Please check the following details and try again    *\n------------------------------------------------------------------   \n\n";
var message01 = "";	
	for (i=0;i<formData.length;i++) {
		temp = formData[i].name.split("-");
	if (temp[1] != 1){
		if ((temp[2] == 'date')&&(formData[i].value != '')&&(!Date.parse(formData[i].value))){
				message01 = message01 + ' - '+ temp[0] +' is not a valid date.\n\n';
		}else if ((temp[2] == 'num')&&(formData[i].value != '')&&(!parseInt(formData[i].value))){
				message01 = message01 + ' - '+ temp[0] +' is not a valid number.\n\n';
		}else if ((formData[i].type == 'textarea')&&(formData[i].value == '')){
				message01 = message01 + ' - '+ temp[0] +'.\n\n';	
		}else if ((formData[i].type == 'text')&&(formData[i].value == '')){
				message01 = message01 + ' - '+ temp[0] +'.\n\n';	
		}else if ((formData[i].type == 'password')&&(formData[i].value == '')){
				message01 = message01 + ' - '+ temp[0] +'.\n\n';	
		}else if ((formData[i].type == 'select-one')&&(formData[i].value == 0)){
				message01 = message01 + ' - '+ temp[0] +'.\n\n';
		}else if ((formData[i].type == 'text')&&(temp[0] == 'Email Address')&&(formData[i].value != '')){
					var tempArray;
					var check = 0
					tempArray = formData[i].value.split("@");
						if (tempArray.length < 2){
						}else{
							check = check + 1;
							if (tempArray[0].length < 3){
							}else{
								check = check + 1;
								at = tempArray[1].split(".");
								if (at.length < 2){
								}else{
									check = check + 1;
									if(at[0] < 3){
									}else{ 
										check = check + 1;
									}
								}
							}
						}
				if (check != 4){
				message01 = message01 + " - Email Address is not a valid Email Address. \n\n";   
				} 
			}
		}
	}
	//****** return the error message
	if (message01.length != 0){
		alert(message + message01);
		return false;
	}else{	
		return true;
	}
	//****** return the error message
}

