
function init(id)
{
	strid=new String(id);
	if (id != 'list_linkSearch')
		changeImage(id,'a');
	pictlinesrc='pict'+strid.substring(strid.length-1)+'_line.gif'
	document.images("pictline").src='../images/'+pictlinesrc
}

function changeImage(id,letter)
{
	document.images(id).src='../images/'+id+letter+'.gif'
}

function changeCheckbox(field,number,value)
{
	ischecked=document.f1.elements(field+number).checked
	
	for(i=1; ;i++)
		if(document.f1.elements(field+i))
		{
			if (i != number)
				document.f1.elements(field+i).checked=false
		}
		else
			break
	//document.f1.elements(field).value=value
}

function setStyle(obj,clname)
{
	obj.className=clname;
}

//*************************************************************************************
// trim - this function deletes spaces around the string.
//*************************************************************************************
String.prototype.trim = function()
{
    // Use a regular expression to replace leading and trailing 
    // spaces with the empty string
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

function checkEmail(checkThisEmail){

//  return (strEmail.indexOf(".") > 2) && (strEmail.indexOf("@") > 0);
   //return /^\w+@([\w\-]+\.)+\w{2,3}$/.test(strEmail);
var myEMailIsValid = true;
var myAtSymbolAt = checkThisEmail.indexOf('@');
var myLastDotAt = checkThisEmail.lastIndexOf('.');
var mySpaceAt = checkThisEmail.indexOf(' ');
var myLength = checkThisEmail.length;


// at least one @ must be present and not before position 2
// @yellow.com : NOT valid
// x@yellow.com : VALID

if (myAtSymbolAt < 1 ) 
 {myEMailIsValid = false}


// at least one . (dot) afer the @ is required
// x@yellow : NOT valid
// x.y@yellow : NOT valid
// x@yellow.org : VALID

if (myLastDotAt < myAtSymbolAt) 
 {myEMailIsValid = false}

// at least two characters [com, uk, fr, ...] must occur after the last . (dot)
// x.y@yellow. : NOT valid
// x.y@yellow.a : NOT valid
// x.y@yellow.ca : VALID

if (myLength - myLastDotAt <= 2) 
 {myEMailIsValid = false}


// no empty space " " is permitted (one may trim the email)
// x.y@yell ow.com : NOT valid

if (mySpaceAt != -1) 
 {myEMailIsValid = false}


return myEMailIsValid

}


function getNumbers(){
	var ch=event.keyCode;
	event.returnValue =((ch >= 48 && ch <= 57) || ch ==46);
}


// ----------- calendar's functions -----------
var cal_w = null;
function popupcal(obField)
{
	f_name = "../include/popup_calend.asp?obName=" + obField.name + "&obValue='" + obField.value + "'"
	cal_w = window.open(f_name,"cal_w","left=250,top=150,height=180,width=180,status=no,toolbar=no,scroll=no,menubar=no,location=no")
	cal_w.focus();
	return false;
}
function win_close()
{
	if (cal_w)
	{cal_w.close();}
	
}
// ----------- end calendar's functions -----------
/*CHECK PHONE NUMBER*/

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- /";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 9;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
/*END ofPHONE CHECHING*/