function ratingChecked(form){

	if(form.optiondropbox.value==0){
		alert("Please select an option from the dropbox before submitting your rating");
		return;
	}else{
		form.submit();
	}

}



function submitUserDetails(form){

	var OK = false;
	var nameOK = false;
	var emailOK = false;
	
	var nameValidatorStr = /^\w+([\.-]?\w+)/;	
	var emailValidatorStr = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; 
	var emailUserStr = form.emailAddr.value;
	var nameUserStr = form.fullName.value;
	
	// Test if 'Enter details' has bee replaced
	if(nameUserStr=="Enter your Name" || emailUserStr=="Enter your Email"){
		alert("Please enter your Correct Details.");
		return;
	}
	
	// Test if name is valid
	if(nameValidatorStr.test(nameUserStr)) nameOK = true;
    else alert("There is something wrong with the name you have provided");
	
	// Test if email address is correct
	if(emailValidatorStr.test(emailUserStr)){
		emailOK = true;
	}else{
		alert("Email Address is not Correct.");
		return;
	}
	
	if(nameOK && emailOK) form.submit();	

}

function submitContactEmail(form){
	var nameOK = false;
	var emailOK = false;
	var nameValidatorStr = /^\w+([\.-]?\w+)/;
	var emailValidatorStr = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; 	
	
	// Test if any fields are empty
	if(form.fullname.value=="" || form.email.value=="" || form.msg.value==""){alert("You have left some fields incomplete");return;}
	
	// Test if name is valid
	if(nameValidatorStr.test(form.fullname.value)) nameOK = true;
    else{ alert("There is something wrong with the name you have provided");return;}
	
	// Test if email is valid
	if(emailValidatorStr.test(form.email.value)) emailOK = true;
    else{ alert("There is something wrong with the email you have provided");return;}	
	
	if(nameOK && emailOK) form.submit();
	
}

function submitComments(form){

	var OK = false;

	var commentsUserStr = form.comments.value;
	var nameUserStr = form.handle.value;
	
	// Test if 'Enter details' has bee replaced
	if(nameUserStr=="Enter your Name" || commentsUserStr=="Enter your Comments"){
		alert("Please enter your Name and Comments");
		return;
	}else{
		OK = true;
	}

	
	if(OK) form.submit();	

}



function textInputSelect(str){
	if(str.value=="Enter your Name" || str.value=="Enter your Email") str.value="";
}

function commentsInputSelect(str){
	if(str.value=="Enter your Name" || str.value=="Enter your Comments") str.value="";
}

// Popup Div javascript

var popShowing = null;
var timerId = null;

var ns4=(document.layers)? true:false;
var ns6=(document.getElementById)? true:false;
var ie4=(document.all)? true:false;
var ie5=false;
if(ie4){
	if((navigator.userAgent.indexOf('MSIE 5')> 0)||(navigator.userAgent.indexOf('MSIE 6')> 0)){
		ie5=true;
		ie4 = false;
	}
	if(ns6){
		ns6=false;
	}
}

var over;


if((ns4)||(ie4)||(ie5)||(ns6)){
document.onmousemove=mouseMove
if(ns4)document.captureEvents(Event.MOUSEMOVE)
}

function mouseMove(e) {
	if (popShowing != null) {
		if ((ns4) || (ns6) ) {
			newX=e.pageX; 
			newY=e.pageY;
		}
		if (ie4) {newX=event.x; newY=event.y;}
		if (ie5) {newX=event.x+document.body.scrollLeft; newY=event.y+document.body.scrollTop;}
		
		if (ns4||ns6) {
			windowHeight = window.innerHeight;
			windowWidth = window.innerWidth;
		} else if (ie4||ie5) {
			windowHeight = document.body.offsetHeight;
			windowWidth = document.body.offsetWidth;
		}
		if (ie4||ie5||ns6) {
			width = over.offsetWidth;
			height = over.offsetHeight;
		} else if (ns4) {
			width = over.clip.width;
			height = over.clip.height;
		}
		if (width+newX > windowWidth) {
			// Move to the left of the cursor
			newX = newX - width-10;
			if (newX < 0) {
				newX = 0;
			}
		} else {
			newX += 10;
		}
		if (height+newY > windowHeight) {
			// Move to the left of the cursor
			newY = newY - height-10;
		} else {
			newY += 10;
		}
		repositionTo(over, newX, newY);
	}
}

function showObject(obj){
	if(ns4) obj.visibility="show";
	else if(ie5) obj.style.visibility="visible";
	else if(ie4) obj.visibility="visible";
	else if(ns6) obj.style.visibility="visible";
}

function hideObject(obj){
	if(ns4)obj.visibility="hide";
	else if(ie5) obj.style.visibility="hidden";
	else if(ie4)obj.visibility="hidden";
	else if(ns6)obj.style.visibility="hidden";
}

function repositionTo(obj,xL,yL){
	if(ie5||ns6){
		obj.style.left=xL + "px";
		obj.style.top=yL+ "px";
	} else if(ns4) {
		obj.left=xL;
		obj.top=yL;
	} else if(ie4){
		obj.left=xL;
		obj.top=yL;
	}
}

function removePopUp() {
	hideObject(over);
	popShowing = null;
	if (timerId != null) {
		clearTimeout(timerId);
		timerId = null;
	}
	
	
}



function layerWrite(txt) {
	txt += "\n";
	
    if (ns4) {
    	var lyr = over.document
        lyr.write(txt)
        lyr.close()
    } else if (ie4||ie5) {
		over.innerHTML = txt
	} else if (ns6) {
		range = document.createRange();
		range.setStartBefore(over);
		domfrag = range.createContextualFragment(txt);
		
		while (over.hasChildNodes()) {
			over.removeChild(over.lastChild);
		}
		over.appendChild(domfrag);
	}
}

function popUpFromDiv(theDiv) {
	
	if ((popShowing != null) && (popShowing == theDiv) && (timerId != null)) {
		window.clearTimeout(timerId);
		return;
	} else if (popShowing != null) {
		removePopUp();
	}
	if (ie4||ie5) {
		over = document.all[theDiv];
	} else if (ns4) {
		over = eval("document."+theDiv);
	} else if (ns6) {
		over = document.getElementById(theDiv);
	}
	
	if (ie4|ie5) {
		windowHeight = document.body.offsetHeight;
		windowWidth = document.body.offsetWidth;
		newX = window.event.x;
		newY = window.event.y;
		if (over.offsetWidth+newX > windowWidth) {
			// Move to the left of the cursor
			newX = newX - over.offsetWidth-10;
		} else {
			newX += 10;
		}
		if (over.offsetHeight+newY > windowHeight) {
			// Move to the left of the cursor
			newY = newY - over.offsetHeight-10;
		} else {
			newY += 10;
		}
		repositionTo(over, newX, newY);
	}
	showObject(over);
	popShowing = theDiv;
}
	
function popUpFromArr(id) {
	if ((popShowing != null) && (popShowing == id) && (timerId != null)) {
		window.clearTimeout(timerId);
		return;
	} else if (popShowing != null) {
		removePopUp();
	}
	if (ie4||ie5) {
		over = overDiv;
	} else if (ns4) {
		over = document.overDiv;
	} else if (ns6) {
		over = document.getElementById("overDiv");
	}
	layerWrite(popMessages[id]);
	
	if (ie4|ie5) {
		repositionTo(over, event.x, event.y);
	}
	showObject(over);
	popShowing = id;
}

function popDown() {
	if (popShowing != null) {
		timerId = setTimeout(removePopUp, 300);
	}
}

// End Popup Dic javascript

function openWindow(name, title){
	win = window.open(name, title, "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=785,height=540")
	
}


function openCenterWin(url,width,height)
{

  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  str += ",scrollbars=yes, resizable=yes";
  return window.open(url, '', str);
}



