function validateGoogle(){
	if(document.google.q.value==''){
	alert('Please specify a keyword');
	document.google.q.focus();
	return false;
	}
	return true;
}

function submitThisPage(){
	var ni = document.getElementById('myDiv2');
	var sectorId = document.add_event.category[document.add_event.category.selectedIndex].value;
	if(sectorId == ''){
		var stringSelect = 'Select category';
	}else{
		var stringSelect  = getSelect(sectorId);
	}
	ni.innerHTML = stringSelect;
}


function submitItem(){
		var root=document.add_event;
		var item=root.item[root.item.selectedIndex].value;
		var cat=root.category[root.category.selectedIndex].value;
		
		if(item!=''){
			location.href='/catalog/more.php?id='+item+'&c='+cat+'&p=1';
		}
		else{
			return false;
		}
}

function validateAddUserEvent(){
	var root = document.add_event;
	
	var name = root.name.value;
	if (name==''){
		blinkBlink('name');
		alert('Please fill up your name');
		root.name.focus();
		return false;
	}
	var email = root.email.value;
	if (email==''){
		blinkBlink('email');
		alert('Please fill up your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=email.match(pattern);
	if(!flag){
		blinkBlink('email');
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	var phone = root.phone.value;
	if (phone==''){
		blinkBlink('phone');
		alert('Please fill up your phone');
		root.phone.focus();
		return false;
	}
	var address = root.address.value;
	if (address==''){
		blinkBlink('address');
		alert('Please fill up your address');
		root.address.focus();
		return false;
	}
	
	var country = root.country.value;
	if (country==''){
		blinkBlink('country');
		alert('Please fill up your country');
		root.country.focus();
		return false;
	}
	
	var category = root.category.value;
	if (category==''){
		blinkBlink('category');
		alert('Please fill up your category');
		root.category.focus();
		return false;
	}	
	var title = root.title.value;
	if (title==''){
		blinkBlink('title');
		alert('Please fill up the title');
		root.title.focus();
		return false;
	}	
	
	var date = root.date.value;
	if (date==''){
		blinkBlink('date');
		alert('Please fill up the date');
		root.date.focus();
		return false;
	}
	
	var edate = root.edate.value;
	if (edate==''){
		blinkBlink('edate');
		alert('Please fill up the date');
		root.edate.focus();
		return false;
	}

	var hours = root.hours.value;
	if (hours==''){
		blinkBlink('hours');
		alert('Please fill up the hours');
		root.hours.focus();
		return false;
	}
	
	if(isNaN(hours)||hours<0 || hours>12){
		blinkBlink('hours');
		alert('Please fill enter a valid hour');
		root.hours.focus();
		return false;
	}
	
	var minutes = root.minutes.value;
	if (minutes==''){
		blinkBlink('minutes');
		alert('Please fill up the minutes');
		root.minutes.focus();
		return false;
	}
	
	if(isNaN(minutes)||minutes<0 || minutes>60){
		alert('Please fill enter a valid minute');
		root.minutes.focus();
		return false;
	}
	var place = root.place.value;
	if (place==''){
		blinkBlink('place');
		alert('Please fill up the place field');
		root.place.focus();
		return false;
	}
	
	var organizer = root.organizer.value;
	if (organizer==''){
		blinkBlink('organizer');
		alert('Please fill up the organizer field');
		root.organizer.focus();
		return false;
	}
	
	var description = root.description.value;
	if (description==''){
		blinkBlink('description');
		alert('Please fill up the description field');
		root.description.focus();
		return false;
	}
	var vcode = root.vcode.value;
	if (vcode==''){
		blinkBlink('vcode');
		alert('Please fill up the visual code field');
		root.vcode.focus();
		return false;
	}
	
	return true;
}

function clearAddEventForm(){
var con=confirm('Are you sure you want to clear the form?');
	if(con){
		var root = document.add_event;
		root.name.value='';
		root.email.value='';
		root.organizer.value='';
		root.url.value='';
		root.place.value='';
		root.hours.value='';
		root.minutes.value='';
		root.date.value='';
		root.title.value='';
		root.category.value='';
		root.country.value='';
		root.address.value='';
		root.phone.value='';
		root.email.value='';
		root.name.value='';
		root.description.value='';
		root.vcode.value='';		
	}else{
		return false;
	}
}

function validChars(e,goods,typeId,photoId) {
	
	var key, keychar;
	
	key = (window.event) ? window.event.keyCode : ((e) ? e.which : null);
		if(key==48){
	var qty=eval('document.sc.text_'+typeId+'_'+photoId+'.value');
	if(qty == ''){
		return false;
	}
	}
	if (key == null) return true;
	

	
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();
	if (goods.indexOf(keychar) != -1)
		return true;
 
	if (key==null || key==0 || key==8 || key==9 || key==13 || key==27){
		return true;
	}
 	
	return false;

}

function popImage(imageURL,imageTitle){
	//alert(imageURL);
	defaultWidth  = 500;
	defaultHeight = 500;
	//alert(imageURL);
	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
	var optIE='scrollbars=no,width=150,height=100,left=100,top=100';

	var AutoClose = true;

	if (parseInt(navigator.appVersion.charAt(0))>=4){
		var isNN=(navigator.appName=="Netscape")?1:0;
		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
		var optNN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
		var optIE='scrollbars=yes,width=150,height=100,left=100,top=100';

		//if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isIE){imgWin=window.open('about:blank','',optIE);}
		with (imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
			writeln('<sc'+'ript>');
			writeln('var isNN,isIE;');
			writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN=(navigator.appName=="Netscape")?1:0;');
			writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');
			writeln('if (isIE){');
			writeln('window.resizeTo(100,100);');
			writeln('width=100-(document.body.clientWidth-document.images[0].width);');
			writeln('height=100-(document.body.clientHeight-document.images[0].height);');
			writeln('window.resizeTo(width,height);}');
			writeln('if (isNN){');
			writeln('window.innerWidth=document.images["Image"].width;');
			writeln('window.innerHeight=document.images["Image"].height;}}');
			writeln('function doTitle(){document.title="'+imageTitle+'";}');
			writeln('</sc'+'ript>');
			if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
			else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
			writeln('<img name="Image" src="'+imageURL+'" style="display:block"></body></html>');
			close();
		}
}
function popImageForAlbum(imageURL,imageTitle,imageText){
	//alert(imageURL);
	defaultWidth  = 500;
	defaultHeight = 500;
	//alert(imageURL);
	var optNN='scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
	var optIE='scrollbars=no,resizable=1,width=150,height=100,left=100,top=100';

	var AutoClose = true;

	if (parseInt(navigator.appVersion.charAt(0))>=4){
		var isNN=(navigator.appName=="Netscape")?1:0;
		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
		var optNN='scrollbars=yes,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
		var optIE='scrollbars=yes,resizable=1,width=150,height=100,left=100,top=100';

		//if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isIE){imgWin=window.open('about:blank','',optIE);}
		with (imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
			writeln('<sc'+'ript>');
			writeln('var isNN,isIE;');
			writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN=(navigator.appName=="Netscape")?1:0;');
			writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');
			writeln('if (isIE){');
			writeln('window.resizeTo(100,100);');
			writeln('width=100-(document.body.clientWidth-document.images[0].width);');
			writeln('height=100-(document.body.clientHeight-document.images[0].height) + 50;');
			writeln('window.resizeTo(width,height);}');
			writeln('if (isNN){');
			writeln('window.innerWidth=document.images["Image"].width;');
			writeln('window.innerHeight=document.images["Image"].height + 50;}}');
			writeln('function doTitle(){document.title="'+imageTitle+'";}');
			writeln('</sc'+'ript>');
			if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
			else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
			writeln('<img name="Image" src="'+imageURL+'" style="display:block"><div align="center" style="color: #FFFFFF;">'+imageText+'</div></body></html>');
			close();
		}
}


//function popImageForAlbum(imageURL,imageTitle,imageText){
//	//alert(imageURL);
//	defaultWidth  = 500;
//	defaultHeight = 500;
//	//alert(imageURL);
//	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
//	var optIE='scrollbars=no,width=150,height=100,left=100,top=100';
//
//	var AutoClose = true;
//
//	if (parseInt(navigator.appVersion.charAt(0))>=4){
//		var isNN=(navigator.appName=="Netscape")?1:0;
//		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
//		var optNN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
//		var optIE='scrollbars=yes,width=150,height=100,left=100,top=100';
//
//		//if (isNN){imgWin=window.open('about:blank','',optNN);}
//		if (isNN){imgWin=window.open('about:blank','',optNN);}
//		if (isIE){imgWin=window.open('about:blank','',optIE);}
//		with (imgWin.document){
//			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
//			writeln('<sc'+'ript>');
//			writeln('var isNN,isIE;');
//			writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
//			writeln('isNN=(navigator.appName=="Netscape")?1:0;');
//			writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
//			writeln('function reSizeToImage(){');
//			writeln('if (isIE){');
//			writeln('window.resizeTo(400,400);');
//			writeln('width=100-(document.body.clientWidth-document.images[0].width);');
//			writeln('height=100-(document.body.clientHeight-document.images[0].height);');
//			writeln('window.resizeTo(width,height);}');
//			writeln('if (isNN){');
//			writeln('window.innerWidth=document.images["Image"].width;');
//			writeln('window.innerHeight=document.images["Image"].height  + 50;}}');
//			writeln('function doTitle(){document.title="'+imageTitle+'";}');
//			writeln('</sc'+'ript>');
//			if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
//			else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
//			writeln('<img name="Image" src="'+imageURL+'"><div style="color: #FFFFFF; padding-top: 5px;" align="center">'+imageText+'</div></body></html>');
//			close();
//		}
//}

function clearTellaFriend(e){
	var con=confirm('Are you sure you want to clear the form?');
	if(con){
		var root = document.tell_a_friend;
		root.name.value='';
		root.email.value='';
		root.message.value='';
		root.vcode.value='';
		for(var i=0;i<e;i++){
			var f_name= eval('root.f_name'+i+'');
			var f_email= eval('root.f_email'+i+'');
			f_name.value='';
			f_email.value='';
		}
	}else{
		return false;
	}
}

function validateTellAFriend(e){
	var root = document.tell_a_friend;
	var name = root.name.value;
	if (name==''){
		blinkBlink('name');
		alert('Please fill up your name');
		root.name.focus();
		return false;
	}
	var email = root.email.value;
	if (email==''){
		blinkBlink('email');
		alert('Please fill up your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=email.match(pattern);
	if(!flag){
		blinkBlink('email');
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	var count=0;
	for(var i=0;i<e;i++){
		var f_name= eval('root.f_name'+i+'.value');
		var f_email= eval('root.f_email'+i+'.value');
		if(f_name==''&&f_email==''){
			count++;
		}
		if(f_name==''&&f_email!=''){
			blinkBlink('f_name'+i);
			alert('Please fill up your friends name');
			eval('root.f_name'+i+'.focus()');
			return false;
		}
		if(f_name!=''&&f_email==''){
			blinkBlink('f_email'+i);
			alert('Please fill up your friends email');
			eval('root.f_email'+i+'.focus()');
			return false;
		}
		var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
		if(f_name!=''){
			flag=f_email.match(pattern);
			if(!flag){
				blinkBlink('f_email'+i);
				alert('Please insert a valid email address.');
				eval('root.f_email'+i+'.select()');
				return false;
			}
		}
	}
	if(count==e){
		blinkBlink('f_name0');
		alert('Please provide at least one friend email');
		root.f_name0.focus();
		return false;
	}
	var vcode = root.vcode.value;
	if (vcode==''){
		blinkBlink('vcode');
		alert('Please provide the visual code.');
		root.vcode.focus();
		return false;
	}
	return true;
}

function checkContactform(){
	var root=document.contactForm;

	var name=root.name;
	var company=root.company;
	var street=root.street;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var mobile=root.mobile;
	var email=root.email;
	var department=root.department;
	var subject=root.subject;
	var message=root.message;

	if(name.value==""){
		blinkBlink('name');
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(country.value==""){
		blinkBlink('country');
		alert('Please select a country from the list.');
		country.focus();
		return false;
	}
	if(phone.value==""){
		blinkBlink('phone');
		alert('Please enter your home phone number.');
		phone.focus();
		return false;
	}
	if(isNaN(phone.value)){
		blinkBlink('phone');
		alert('The phone number should only contain digits.');
		phone.select();
		return false;
	}
	if(isNaN(mobile.value) && mobile.value!=""){
		blinkBlink('mobile');
		alert('The mobile phone number should only contain digits');
		mobile.select();
		return false;
	}
	if(email.value==""){
		blinkBlink('email');
		alert('Please enter an email address.');
		email.focus();
		return false;
	}
	if(department.value==""){
		blinkBlink('department');
		alert('Please select the department you wish to contact.');
		department.focus();
		return false;
	}
	if(subject.value==""){
		blinkBlink('subject');
		alert('Please enter the subject.');
		subject.focus();
		return false;
	}
	if(message.value==""){
		blinkBlink('message');
		alert('Please enter your message.');
		message.focus();
		return false;
	}
}

function clearContactForm(){
	var root=document.contactForm;

	var name=root.name;
	var company=root.company;
	var street=root.street;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var mobile=root.mobile;
	var email=root.email;
	var department=root.department;
	var subject=root.subject;
	var message=root.message;

	if(confirm('Are you sure you want to clear this form?')){
		name.value="";
		company.value="";
		street.value="";
		city.value="";
		state.value="";
		country.value="";
		phone.value="";
		mobile.value="";
		email.value="";
		department.value="";
		subject.value="";
		message.value="";

		return false;
	}

	return false;
}

function blinkExecute(target,color){
	document.getElementById(target).style.backgroundColor = color;
}

function blinkBlink (target){
	color1 = "#CD2228"; // blinking color
	color2 = ""; // background color

	setTimeout('blinkExecute("'+target+'","'+color1+'")',0);
	setTimeout('blinkExecute("'+target+'","'+color2+'")',500);
	setTimeout('blinkExecute("'+target+'","'+color1+'")',1000);
	setTimeout('blinkExecute("'+target+'","'+color2+'")',1500);
	setTimeout('blinkExecute("'+target+'","'+color1+'")',2000);
	setTimeout('blinkExecute("'+target+'","'+color2+'")',2500);
	setTimeout('blinkExecute("'+target+'","'+color1+'")',3000);
	setTimeout('blinkExecute("'+target+'","'+color2+'")',3500);
	document.getElementById(target).focus();
}

function displayMakeUsYourHomepage(){

	browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		temp.style.behavior='url(#default#homepage)';
		temp.setHomePage('http://www.bigtraveler.com');
	}

	else {
		alert('In order to set our website to your homepage, please go to Tools/Options from your browser, and enter \'http://www.bigtraveler.com\' in the Homepage / Location(s) field, and then click Ok');
	}
	return false;
}

function validateSearch(){
	root = document.search;
	if(root.keyword.value==''){
	alert('Please enter a search word.');
	root.keyword.focus();
	return false;
	}
	return true;
}

function submitNewsletter(){
	var root = document.newsletter;
	
	var name = root.name.value;
	var email = root.email.value;
	
	if (name == ''){
		alert('Please give your name');
		root.name.focus();
		return false;
	}
	if (email == ''){
		alert('Please give your email');
		root.email.focus();
		return false;
	}
	return true;
}