function check_email(email)
{
   AtPos = email.indexOf("@")
   StopPos = email.lastIndexOf(".")
            
   if (email == "") {
      return false;
   }
            
   if (AtPos == -1 || StopPos == -1) {
     return false;
   }
            
   if (StopPos < AtPos) {
     return false;
   }
            
   if (StopPos - AtPos == 1) {
     return false;
   } 
            
   return true;
}

function validateForm() 
{
		//Check for Bride Name
        if (document.getElementById('form1').bride.value == "") 
        {
        alert("Please enter the 1st name.");
        return false;
        }
		/*//Check for Groom Name      
        if (document.getElementById('form1').groom.value == "") 
        {
        alert("Please enter the groom's name.");
        return false;
        }*/
		//Check for Surname     
        if (document.getElementById('form1').surname_initial.value == "") 
        {
        alert("Please enter your last name.");
        return false;
        }
		//Check for Email      
        if (document.getElementById('form1').email.value == "") 
        {
        alert("Please enter your email address.");
        return false;
        }
				/*else if(!check_email(document.getElementById('form1').email.value)) 
				{
				 	alert("It appears you have not entered a valid email address.\nPlease check the address.");
        	return false;
				}*/
		//Check for phone      
        if (document.getElementById('form1').phone.value == "") 
        {
        alert("Please enter your telephone number.");
        return false;
        }
		//Check for address_1      
        if (document.getElementById('form1').address_1.value == "") 
        {
        alert("Please enter your Address1.");
        return false;
        }
				
				var country_id = document.getElementById('form1').country_id;
				var city = document.getElementById('form1').city;
				var postcode = document.getElementById('form1').postcode;
				
				if (document.getElementById('form1').state_province)
					 var state_province = document.getElementById('form1').state_province;
				
				if (document.getElementById('form1').other_state)
					 var state_province = document.getElementById('form1').other_state;
					 
		//Check for country_id      
        if (document.getElementById('form1').country_id == "") 
        {
        alert("Please enter your Country.");
        return false;
        }
		//Check for city      
        if (document.getElementById('form1').city == "") 
        {
        alert("Please enter your City.");
        return false;
        }
		//Check for postcode      
        if (document.getElementById('form1').postcode.value == "") 
        {
        alert("Please enter your Postcode.");
        return false;
        }
		//Check for state_province      
        if (state_province.value == "") 
        {
        alert("Please enter your State/Province.");
        return false;
        }

	return true;
}

function change_state_drop(cid){
  idd = cid.options[cid.selectedIndex].value;//document.mainform[cid].value;
	
	if (idd == 240)
	{
    $state = ' <input type="text" name="other_state" class="mono_field" id="other_state" />';
    document.getElementById('st_drop').innerHTML = $state;
	}
	else
	{
	 	$state = ' <select name="state_province" class="mono_field" id="state_province"> '+cat[idd]+' </select>';
    document.getElementById('st_drop').innerHTML = $state;
	}  
}

function init_td(stat){
  pr = 'prev';
	nx = 'nex';

	if (stat == 'hide'){
		 res_p = res_n = 'hidden';
	}
	if (stat == 'show'){
		 if (cpage >0)
		 		res_p = 'visible';
		 else
		    res_p = 'hidden';

		 if (cpage < pages){
		 		res_n = 'visible';
		 }
		 else
		    res_n = 'hidden';
	}
//	if (document.getElementById(pr)){
    	document.getElementById(pr).style.visibility = res_p;
			document.getElementById(nx).style.visibility = res_n;
/*  }
  if (document.all) {
    	document.all[pr].style.display = res_p;
			document.all[nx].style.display = res_n;
  }
  if (document.layers) {
    	document.layers[pr].style.display = res_p;
			document.layers[nx].style.display = res_n;
  }*/
}
	
/*var floatingMenuId = 'floatdiv';
//var floatingMenu = { targetX: 50, targetY: 148, hasInner: typeof(window.innerWidth) == 'number', hasElement: document.documentElement && document.documentElement.clientWidth, menu: document.getElementById ? document.getElementById(floatingMenuId) : document.all ? document.all[floatingMenuId] : document.layers[floatingMenuId] };

//if (document.getElementById(floatingMenuId)){
	var floatingMenu = document.getElementById(floatingMenuId).style;
}
if (document.all) {
	var floatingMenu = document.all[floatingMenuId].style;
}
if (document.layers) {
	var floatingMenu = document.layers[floatingMenuId];
}*/

function movee() {
    if ((newX<curX && direction == 'right') || (newX>curX && direction == 'left')){
  	  curX = curX+(ind*step);
      if (document.layers)   
      {   
          floatingMenu.left = curX;   
      }   
      else  
      {   
          floatingMenu.left = curX + 'px';   
      }   
      //alert((-1*curX)-(-1*newX));
  		if ((-1*(newX-curX)>450 && direction == 'right') || ((-1*curX)-(-1*newX)>450 && direction == 'left'))
				 step+=0.5;
			else{
			   if (step>0)
			   		step-=0.5;
				 else
				    step=0.5;
			}
				 
  		setTimeout('movee()', 5);
  	}
		else{
				init_td('show');
		}
}

function scrolltest(dir) {
  init_td('hide');
  direction = dir;
	
	step = 0.5;
	
	if (cpage==0)
		 w = myWidth;
	else
	   w = myWidth+1;
	
	if (direction == 'right'){
		newX = curX - w;
		ind = -1;
		cpage++;
	}
	if (direction == 'left'){
		newX = curX + w;
		ind = 1;
		cpage--;
	}
//	alert (newX+' == '+curX);
	movee();
}

function ch_photo(img_id){
	document.getElementById('ph_big').src = '/photos/'+imgs[img_id];
	document.getElementById('ph_big').alt = ttl[img_id];
	if (ath[img_id])
		 document.getElementById('ph_by').innerHTML = ath[img_id];
	else
		 document.getElementById('ph_by').innerHTML = '';
}

function flash(){
	objects = document.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++)
	{
    objects[i].outerHTML = objects[i].outerHTML;
	}
}

var close_w;
function newwin(url,theWidth, theHeight) {

 if (close_w) {
         close_w.close();
        }
 new_window = open(url,"displayWindow","width="+theWidth+", height="+theHeight+", scrollbars=yes,resizable=yes,toolbar=no,menubar=no,left=0,top=0");
 close_w=new_window;
}

function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}

function fea_pop(url) {
 if (close_w) {
         close_w.close();
        }
 new_window = open(url,"displayWindow","width=724, height=498,scrollbars=no,resizable=no,toolbar=no,menubar=no,left=0,top=0");
 close_w=new_window;
}

function video_popup(lang,src) {
 wdparms = 'width=715,height=420,scrollbars=no,resizable=yes,toolbar=no,menubar=no,left=0,top=0';
 window.open( lang+'/video.php?file='+src,'',  wdparms );
}

var restoreimgsrc1="";
function MMon(p){
restoreimgsrc1 = document.images[p].src;
document.images[p].src=restoreimgsrc1.substring(0,restoreimgsrc1.length-4)+"_on.jpg";
}

function MMof(p){
 document.images[p].src=restoreimgsrc1;
}

var restoreimgsrc = '';
var obj="";
var obj1="";

function CellChangeOn(l) {
  if (document.getElementById(l)){
  	obj = document.getElementById(l);
  }
  if (document.all) {
  	obj = document.all[l];
  }
  if (document.layers) {
  	obj = document.layers[l];
  }
	//restoreimgsrc = obj.style.backgroundImage;
	//alert (restoreimgsrc[l]);
	obj.style.backgroundImage  = 'url(/images/m_bg_on.gif)';//restoreimgsrc.substring(0,restoreimgsrc.length-5)+"_on.gif)";
//	alert (restoreimgsrc+'  -  '+obj.style.backgroundImage+' -  '+restoreimgsrc.substring(0,restoreimgsrc.length-11)+s+"l_item_bg.gif)")
}

function CellChangeOff(l){
  if (document.getElementById(l)){
  	obj = document.getElementById(l);
  }
  if (document.all) {
  	obj = document.all[l];
  }
  if (document.layers) {
  	obj = document.layers[l];
  }
	obj.style.backgroundImage  = '';
}

function hide_el1(id) { /// hide layers ///
		if (document.getElementById(id)){
			document.getElementById(id).style.visibility= "hidden";
		}
		if (document.all) {
			document.all[id].style.visibility = "hidden";
		}
		if (document.layers) {
			document.layers[id].visibility = "hide";
		}
}

function ShowMenu1(id) {
//hide_el();
//  level=id;
//alert (id);
if (document.getElementById(id)){
  document.getElementById(id).style.overflow = "auto";
	document.getElementById(id).style.visibility= "visible";
}
if (document.all) {
	document.all[id].style.overflow = "auto";
	document.all[id].style.visibility = "visible";
}
if (document.layers) {
	document.layers[id].overflow = "auto";
	document.layers[id].visibility = "show";
}
}

function popupWindow(src,width,height,scrollbars,toolbar,resizable, menubar,title,autosize) {
	 	wdparms = 'width='+width+',height='+height+',scrollbars='+scrollbars+',toolbar='+toolbar+',resizable='+resizable+',menubar='+menubar;
		window.open( '/popupWindow.php?src='+src+'&autosize='+autosize+'&title='+title, '',  wdparms );
}

function loadA(){
myUrl = "uses.html";
myTarget = "new_window"; 
myArgs =        "width=930,"
                        +"height=527,"
                        +"location=0,"
                        +"menubar=1,"
                        +"resizable=0,"
                        +"scrollbars=1,"
                        +"status=0,"
                        +"titlebar=1,"
                        +"toolbar=0,"
                        +"hotkeys=0,"
                        +"screenx=30,"
                        +"screeny=30,"
                        +"left=30,"
                        +"right=30";
                        
                        window.open( myUrl, myTarget, myArgs );
                        }
						
						



function leapto(form)
        {
        var myindex=form.dest.selectedIndex
        parent.frames[0].location.href = (form.dest.options[myindex].value);
        }
