//Function  trim()
function popwindow(url, windowname) {
var features =
        'width="150"'        + 
        ',height="100%"'      + 
        ',menubar=yes'     + 
        ',scrollbars=yes'  + 
       ',status=yes'      + 
        ',toolbar=yes'     + 
        ',Resizable=yes'  
 window.open (url, windowname, features);
}


function trim(sString) 
{
	while (sString.substring(0,1) == ' '){
	sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' '){
	sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

// open popup window
// created by adventurebrat.com designers
function popwindow2(url, windowname) {
var features =
        'width=800'        + 
        ',height=600'      + 
        ',menubar=no'     + 
        ',scrollbars=yes'  + 
       ',status=no'      + 
        ',toolbar=no'     + 
        ',Resizable=no'  +
        ',left=100,top=50';
 window.open(url, windowname, features);
}

function check_tourform(f)
{
	if(trim(f.name.value) == '' || f.company.value == '' || f.email.value == ''	 ||
		trim(f.title.value) == '' || trim(f.phone.value) == '' || trim(f.address.value) == '' ||
		trim(f.URL.value) == '' || trim(f.tours_offered.value) == '' || trim(f.clients_nubmer.value) == '' || 
		trim(f.comments.value) == ''){
		alert("Please fill all required fields!");
		return false;
	}
	return true;
}

function check_registration_form(f)
{
	if(trim(f.name.value) == '' || f.password.value == '' || f.username.value == '' || trim(f.email.value) == ''){
		alert("Please fill all required fields!");
		return false;
	}
	if(f.terms.checked == false){
		alert("Please check \"Terms and conditions\"!");
		return false;
	}
	return true;
}


function check_contact_form(f)
{
	if(trim(f.name.value) == '' || f.company.value == '' || f.email.value == ''){
		alert("Please fill all required fields!");
		return false;
	}
	return true;
}

function ShowImage(img,w,h,ff){
	var LeftPosition = (screen.width)? (screen.width-w)/2 : 0; 
	var TopPosition = (screen.height)? (screen.height-h)/2 - 20 : 0; 
	var winn=",left="+LeftPosition+",top="+TopPosition;
	myWin=window.open(img,"winName","width="+w+",height="+h+",status=no,toolbar=no,menubar=no,scrollbars=yes"+winn);
	//myWin.document.open();
//	myWin.document.write("<img src=\""+f+"\" width="+(ff-10)+" border=0 onclick=\"self.close();\" alt=\"Click on the image to close the window\" style=\"cursor:hand\">");
	
	 return true; 
}

function check_password_form(f)
{
	if(f.password.value.length == 0)				{	alert("Please enter your Old Password!");	return false;}
	else if(f.new_password.value.length < 3)		{	alert("New Password must be at least 3 characters!");	return false;}
		else if(f.new_password.value != f.new_password2.value)		{	alert("Passwords don't match!");	return false;}
	
	return true;
}
