//----------------------------------------------------
// These Scripts added by Noor Thapa
//----------------------------------------------------
// This is the Tips Portion
// Add/Edit/Delete as you want in an array
//----------------------------------------------------
//----------------------------------------------------
// Form Validation Routines.
// Currently has Phone and password match
//----------------------------------------------------
var digits = "0123456789";
var phoneNumberDelimiters = "()- ";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 10;
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

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 Address")
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address")
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address")
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address")
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }
 							
	}


// ************************************************
//  FORM CHECKING MEAT CODE !
// ************************************************
function NTcheckForm() {
// -----------------------------------------------------------------------------
//  Phone Number Checking
// -----------------------------------------------------------------------------
	var phone=document.register.phone
	if ((phone.value==null)||(phone.value=="")){
		alert("Please Enter your Phone Number")
		phone.focus()
		return false
	}
	if (checkInternationalPhone(phone.value)==false){
		alert("Please Enter a Valid Phone Number")
		phone.value=""
		phone.focus()
		return false
	}
// -----------------------------------------------------------------------------
// Password match Check
// -----------------------------------------------------------------------------
	pw1 = document.register.password.value;
	pw2 = document.register.password2.value;	
	
	if (pw1==null) {
		alert("Please Enter both passwords.")
		password.focus()
		return false
	}
	if (pw2==null) {
		alert("Please Enter both passwords.")
		password2.focus()
		return false
	}
	if (pw1 != pw2) {
		alert ("Your passwords do not match ! \n Please re-enter your passwords.")
		document.register.password.focus()
		return false
	}
// -----------------------------------------------------------------------------
// Email Check
// -----------------------------------------------------------------------------
	var email=document.register.email
	if ((email.value==null)||(email.value=="")){
		alert("Please Enter your Email Address")
		email.focus()
		return false
	}
	if (echeck(email.value)==false){
		email.value=""
		email.focus()
		return false
	}
	return true
 }
// ********************************************END*


// ************************************************
// This is the BookMark portion
// Add/Edit/Delete as you want in an array
// ************************************************
function addbookmark()
{
bookmarkurl=""
bookmarktitle=""
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}
// ********************************************END*


// ************************************************
// This is the Open Image portion
// This Function will create a new window
// and resize that window to the image 
// it is holding. Useful to use for galleries
// that need popup windows to display
// images when clicked on the thumbnails
// ************************************************
PositionX = 100;
PositionY = 100;
defaultWidth  = 500;
defaultHeight = 500;
var AutoClose = true;

// Do not edit below this line...
//-------------------------------------------- 
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function NTpopImage(imageURL,imageTitle){
	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
		with (imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
			writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
			writeln('width=100-(document.body.clientWidth-document.images[0].width);');
			writeln('height=100-(document.body.clientHeight-document.images[0].height);');
			writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
			writeln('window.innerWidth=document.images["NThapa"].width;');writeln('window.innerHeight=document.images["NThapa"].height;}}');
			writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
		if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
		else 
			writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
			writeln('<a href=javascript:close()><img border=0 name="LaDance" src='+imageURL+' style="display:block"></a></body></html>');
			close();		
		}}


//-------------------------------------------- 
//                GET URL..
//-------------------------------------------- 
function NT_goToURL() {
  var i, args=NT_goToURL.arguments; document.NT_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
// ********************************************END*
