function open_borderfree_window()
 {
  merch_url = location.href;
  redirect_url = "http://www.borderfree.com/bf/cgi-bin/popup_new.pl?id=81" +
"&m_url=" + merch_url;
  window.open(redirect_url,"thiswindow","width=418,height=380");
 }

function goYahoo(dropdown) {
    var id = dropdown.options[dropdown.selectedIndex].value;
    if (id) {
        var page = id + ".html";
        document.location.href = page;
    }
}

function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function tellAFriend (undef) {
    var baseRef = document.location.href.substring(document.location.href.lastIndexOf("/") + 1,location.href.length);
    baseRef = baseRef.substring(0,baseRef.lastIndexOf("."));
    var URL = "http://tellafriend.alight.com/cgi-bin/sendthis.pl?item=" + baseRef;
    MM_openBrWindow(URL,'tellAFriend','scrollbars=yes,resizable=yes,width=500,height=575,left=200,top=50');
}

function askquestion (undef) {
    var baseRef = document.location.href.substring(document.location.href.lastIndexOf("/") + 1,location.href.length);
    baseRef = baseRef.substring(0,baseRef.lastIndexOf("."));
    var URL = "http://tellafriend.alight.com/cgi-bin/askthis.pl?item=" + baseRef;
    MM_openBrWindow(URL,'tellAFriend','scrollbars=yes,resizable=yes,width=500,height=575,left=200,top=50');
}

function checkAvailability (code) {
    var URL = "http://www.sydandsam.com/alightrealtimeinventory.asp?item=" + code;
    MM_openBrWindow(URL,'availability','scrollbars=yes,resizable=yes,width=400,height=275,left=200,top=50');
}

function ZoomPopUp(theURL) {
    MM_openBrWindow(theURL,'ZoomPopUp','scrollbars=no,resizable=yes,width=490,height=560,left=200,top=50');
}

function isEmail(InString)  {

	if(InString.length!=1){
		return (false);
	}

	InString=InString.toLowerCase();
    RefString="1234567890abcdefghijklmnopqrstuvwxyz.@_-";

    if (RefString.indexOf (InString, 0)==-1){
		return (false);
	}

	return (true);

}

function checkEmail2(theField) {

	fldValue = theField.value;
	var check_at = 0;
	var check_dot = 0;
	var errorMessage = "You entered an invalid e-mail address. \nPlease note that you should enter only one e-mail address";

	for (var i = 0; i <fldValue.length;  i++) {
		var ch = fldValue.substring(i,i+1);
        var ret = isEmail(ch);
		if (ch =="@"){
		    check_at = 1;
		}
		if (ch =="."){
		    check_dot = 1;
		}

		if (ret == 0){
			alert(errorMessage);
            return(false);
            break;
         }
    }

	if ((check_at == 0) || (check_dot == 0)){
		alert(errorMessage);
        return(false);
    }

	if (fldValue.indexOf('@') != fldValue.lastIndexOf('@')){
        alert(errorMessage);
        return(false);
    }

	if (fldValue.lastIndexOf('.') == (fldValue.length + 1)){
		alert(errorMessage);
        return(false);
    }

	if (fldValue.lastIndexOf('@') == 0){
		alert(errorMessage);
        return(false);
    }

    var atDotOffset = fldValue.lastIndexOf('.') - fldValue.indexOf('@');
	if (atDotOffset < 2){
		alert(errorMessage);
        return(false);
    }

    return(true);

}
