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

opentriangle= new Image(11,11);
opentriangle.src = "/images/opentriangle.png";
triangle = new Image(11,11);
triangle.src = "/images/triangle.png"; 
///////////
function showHideForm()
{ 
	var obj = document.getElementById('counteries_more');
	if(obj.style.display=='block'){
		obj.style.display='none';
		/* document.tri_img.src = triangle.src; return true; */
		document.images['tri_img'].src = opentriangle.src; 
		return true;
	}else{
		obj.style.display='block';
		/*document.tri_img.src = opentriangle.src; return true;*/
		document.images['tri_img'].src = triangle.src; 
		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 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<24;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.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.city.value) == "") {
		 e += "- Please enter the Firework's City.\n";
	}
	if ( form.country_id.options[form.country_id.selectedIndex].value == "0") {
		 e += "- Please select the Firework's country.\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();}
}




var time=new Date();
var hour,min,sec;
var d=document;

function showDate(){
  
  var dayOfWeek=time.getDay();
    if(dayOfWeek==0) dayOfWeek="Sunday  ";
    if(dayOfWeek==1) dayOfWeek="Monday  ";
    if(dayOfWeek==2) dayOfWeek="Tuesday  ";
    if(dayOfWeek==3) dayOfWeek="Wednsday  ";
    if(dayOfWeek==4) dayOfWeek="Thursday  ";
    if(dayOfWeek==5) dayOfWeek="Friday  ";
    if(dayOfWeek==6) dayOfWeek="Saturday  ";
    

    var day=time.getDate();
    if(day<10) day="0"+day;
    day+=", ";
    
    var mon=time.getMonth();
      if(mon==0) mon="Jan. ";
      if(mon==1) mon="Feb. ";
      if(mon==2) mon="Mar. ";
      if(mon==3) mon="Apr. ";
      if(mon==4) mon="May ";
      if(mon==5) mon="June ";
      if(mon==6) mon="July ";
      if(mon==7) mon="Aug. ";
      if(mon==8) mon="Sep. ";
      if(mon==9) mon="Oct. ";
      if(mon==10) mon="Nov. ";
      if(mon==11) mon="Dec. ";
    
    var year=time.getYear()+1900;

    d.write(dayOfWeek+mon+day+year);
  
}
 
function cal() {
	var amount		= document.mortgage.amount.value;
	var rate			= document.mortgage.rate.value;
 	var term			= document.mortgage.term.options[document.mortgage.term.selectedIndex].value;
	var frequency			= document.mortgage.frequency.options[document.mortgage.frequency.selectedIndex].value;
 
	var periods = 54;
	if (frequency=="monthly") { periods=12; } 
     var payment = (amount*((rate/(periods*100))/(1-(Math.pow(1+(rate/(periods*100)),((term*periods)*-1))))));
    var interest = (( payment*( term*periods))-amount)
	document.mortgage.payment.value = calcRound(payment);
	document.mortgage.interest.value = calcRound(interest);
}
 
 function calcRound(num) {
   result="$"+Math.floor(num)+"." 
   n = result.length
   if (num>1000 && num<999999) {  
     result="$"+result.substring(1,n-4)+","+result.substring(n-4,n)
   }
   if (num>1000000) {  
     result = "$"+result.substring(1,n-7)+","+result.substring(n-7,n-4)+","+result.substring(n-4,n)
   }
   var cents=100*(num-Math.floor(num))+0.5
   result += Math.floor(cents/10)
   result += Math.floor(cents%10)
   return(result)
}
 