if (parent.frames.length > 0) {
	parent.location.href = location.href;
}

 
function openWindow(theURL,winName,features) {window.open(theURL,winName,features);}
function launch(newURL, newName, newFeatures, orgName) {
  var remote = open(newURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
  return remote;
}
    


//////////////
function trim( s ) {
	// trim leading and trailing "whitespace"
	var whitespace = " \t\n\r";
	var i = 0;
	while ((i < s.length) && (whitespace.indexOf(s.charAt(i)) != -1)) i++;
	var j = s.length;
	while ((j > i) && (whitespace.indexOf(s.charAt(j-1)) != -1)) j--;
	return s.substr(i,j - i);
}


function formValidation(form){
	e = "";

	
	var count = 0;
	for(i=0;i< 16;i++){
		if (form.item_id[i].checked) count++;
 	}
	if (count == 0) e += "- Please select a Firework.\n";
 

	if (trim(form.email.value) == "") {
		 e += "- Please enter your email address.\n";
	}
	if (trim(form.name.value) == "") {
		 e += "- Please enter your name.\n";
	}

	if ( form.age1.options[form.age1.selectedIndex].value == "0" && form.age2.options[form.age2.selectedIndex].value == "0" ) {
		 e += "- Please select your age.\n";
	}


	if (trim(form.city.value) == "") {
		 e += "- Please enter the Firework's city name.\n";
	}
	if ( form.country_id.options[form.country_id.selectedIndex].value == "0") {
		 e += "- Please select the Firework's country.\n";
	}

	if (trim(form.map_latitude.value) == "") {
		 e += "- Please enter the map latitude coordinates.\n";
	}
	if (trim(form.map_longitude.value) == "") {
		 e += "- Please enter the map longitude coordinates.\n";
	}
	if (trim(form.security_code.value) == "") {
		 e += "- Please enter the security code.\n";
	}


  	if (e != "") {
		e = "Please correct the following errors, then resubmit the form. Thank you.\n\n" + e;
		alert(e);
		return false;
	}
return true;  
}
 


//////////////////////////////////////////
function formValidation_contactus(form){
	e = "";
	if (trim(form.myname.value) == "") {
		 e += "- Please enter your name.\n";
	}
	if (trim(form.myemail.value) == "") {
		 e += "- Please enter your email address.\n";
	}
 
	if (trim(form.mymessage.value) == "") {
		 e += "- Please enter your message.\n";
	}
	if (trim(form.security_code.value) == "") {
		 e += "- Please enter the security code.\n";
	}
  	if (e != "") {
		e = "Please correct the following errors, then resubmit the form. Thank you.\n\n" + e;
		alert(e);
		return false;
	}
return true;  
}
 
//////////////////////////////////////////
function formValidation_tellafriend(form){
	e = "";
	if (trim(form.myname.value) == "") {
		 e += "- Please enter your name.\n";
	}
	if (trim(form.myemail.value) == "") {
		 e += "- Please enter your email address.\n";
	}
 
 	if (trim(form.recipient_email.value) == "") {
		 e += "- Please enter the recipient email address.\n";
	}

	if (trim(form.mymessage.value) == "") {
		 e += "- Please enter your message.\n";
	}
	if (trim(form.security_code.value) == "") {
		 e += "- Please enter the security code.\n";
	}
  	if (e != "") {
		e = "Please correct the following errors, then resubmit the form. Thank you.\n\n" + e;
		alert(e);
		return false;
	}
return true;  
}
 


//////////////////// 
function CheckForm()
{
   errorFields = "";

	if (trim(document.item_form_main.name.value) == "") {
		errorFields += "- Enter your name.\n";
	}
	if (trim(document.item_form_main.city.value) == "") {
		errorFields += "- Enter a city Name.\n";
	}


	var model = null;
	for (var i=0; i < document.item_form_main.kite.length; i++) {
		if (document.item_form_main.kite[i].checked) {
			model = document.item_form_main.kite[i].value;
			break;
		}
	}
	if (model == null) {
		errorFields += "- Please choose a Firework model before submiting thos form.\n";
	} 

	if (errorFields != "") {
		errorFields = "Please correct the following errors, then resubmit the form. Thank you.\n\n" + errorFields;
		alert(errorFields);
		return false;
	}
return true;  
}
 


 
///////////
function NewWindow(mypage,myname,w,h,scroll){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=no';
  winpopup=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){winpopup.window.focus();}
}

///////////
function showHideForm()
{ 
	var obj = document.getElementById('counteries_more');
	if(obj.style.display=='block'){
		obj.style.display='none';
	}else{
		obj.style.display='block';
	}		
} 