/*
+---------------------------------------------------------------+
|     ©2005 az-web.co.uk WebSite Designs
|     Developed by:
|     Yazid Abchiche
|     http://www.az-web.co.uk
|     yabchiche@az-web.co.uk
|
|     This script is a copyright of az-web.co.uk
+---------------------------------------------------------------+
*/
/* Add mailing  */
// check multi checkboxes based on the name passed in.
function CheckMultiple(name){
	theFrm = document.frmSS;
	for (var i=0; i < theFrm.length; i++) {
		fldObj = theFrm.elements[i];
		var fieldnamecheck=fldObj.name.indexOf(name);
		if (fieldnamecheck != -1) {
			if (fldObj.checked) {
				return true;
			}
		}
	}
	return false;
}

function CheckSS(){
	theFrm = document.frmSS;
	hasDot = theFrm.Email.value.indexOf(".");
	hasAt = theFrm.Email.value.indexOf("@");
	
	if (hasDot == -1 || hasAt == -1) {
		alert("Please enter a valid email address.");
		theFrm.Email.focus();
		theFrm.Email.select();
		return false;
	}
	return true;
}

/* End mailing  */

function mailto(username,domain) {
	//var username = 'info';
	//var domain   = 'mydomain.co.uk';
	document.location = 'mailto:' + username + '@' + domain;
}

function playSound(){
	document.sound1.play();
}

function stopSound(){
	document.sound1.stop();
}

function display_map(url, name, w ,h ) {
  	options='toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+'';
  	var wind=window.open(url, "", options);
  	wind.focus();
}

function display_win(url, w, h) {
  	options = 'toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+'';
  	var wind=window.open(url, name, options);
  	wind.focus();
}

function open_win(url, w, h) {
  	LeftPosition=(screen.width)?(screen.width-w)/2:100;
	TopPosition=(screen.height)?(screen.height-h)/2:100;
	options = 'width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
  	var wind=window.open(url, name, options);
  	wind.focus();
}

function NewWindow(mypage,myname,w,h,scroll,pos) {
  	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
  	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
  	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
  	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
  	win=window.open(mypage,myname,settings);
}

// Check Email Address
function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		alert("Invalid E-mail ID")
		return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		alert("Invalid E-mail ID")
		return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail ID")
		return false
	}
	if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail ID")
		return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail ID")
		return false
	}
	if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail ID")
		return false
	}		
	if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail ID")
		return false
	}
	return true					
}
