function preloadimages()
{
	pic1= new Image(); 
	pic1.src="http://www.findtabs.com/images/gbullet_ov.jpg"; 
	
	pic2= new Image(); 
	pic2.src="http://www.findtabs.com/images/home_ov.jpg"; 
	
	pic3= new Image(); 
	pic3.src="http://www.findtabs.com/images/login_ov.jpg";
	
	pic4= new Image(); 
	pic4.src="http://www.findtabs.com/images/logout_ov.jpg";
	
	pic5= new Image(); 
	pic5.src="http://www.findtabs.com/images/sitemap_ov.jpg";
	
	pic6= new Image(); 
	pic6.src="http://www.findtabs.com/images/tbullet_ov.jpg";
	
	pic7= new Image(); 
	pic7.src="http://www.findtabs.com/images/regimg_ov.jpg";
	
	pic8= new Image(); 
	pic8.src="http://www.findtabs.com/images/ratingbarslice_ov1.jpg";
	
	pic9= new Image(); 
	pic9.src="http://www.findtabs.com/images/ratingbarslice_ov2.jpg";
	
	pic10= new Image(); 
	pic10.src="http://www.findtabs.com/images/ratingbarslice_ov3.jpg";
	
	pic11= new Image(); 
	pic11.src="http://www.findtabs.com/images/ratingbarslice_ov4.jpg";
	
	pic12= new Image(); 
	pic12.src="http://www.findtabs.com/images/ratingbarslice_ov5.jpg";
	
	pic13= new Image(); 
	pic13.src="http://www.findtabs.com/images/ratingbarslice_ov6.jpg";
	
	pic14= new Image(); 
	pic14.src="http://www.findtabs.com/images/ratingbarslice_ov7.jpg";
	
	pic15= new Image(); 
	pic15.src="http://www.findtabs.com/images/ratingbarslice_ov8.jpg";
	
	pic16= new Image(); 
	pic16.src="http://www.findtabs.com/images/ratingbarslice_ov9.jpg";
	
	pic17= new Image(); 
	pic17.src="http://www.findtabs.com/images/ratingbarslice_ov10.jpg";

	pic18= new Image(); 
	pic18.src="http://www.findtabs.com/images/contact_ov.jpg";
}

function validatecntus()
{	
	var str = "";
	
	if(document.contactform.name.value=="")
	{
		str += "Input Your Name\n";
		document.contactform.email.focus();
	}
	if(document.contactform.subject.value=="")
	{
		str += "Input Subject\n";
		document.contactform.subject.focus();
	}
	if(document.contactform.email.value=="")
	{
		str += "Input Email Address\n";
		document.contactform.email.focus();
	}
	var x=document.contactform.email.value;
	if(!checkemail(x))
		{  
			str+="Not a Valid Email Address";
		}
		
	if(document.contactform.message.value=="")
	{
		str += "Input Message\n";
		document.contactform.message.focus();
	}
	
	if(str != "")
	{
		alert("The following error(s) occured :\n ________________________\n"+str);
		document.contactform.email.focus();
		return false;
	}
	return true;
}

function rollon(img_name1, img_src1)
{
	document[img_name1].src = img_src1;
}
function rollout(img_name2, img_src2)
{
	document[img_name2].src = img_src2;
}



function validate()
{	
	var str = "";
	
	if(document.register.user.value=="")
	{
		str += "Input user name\n";
		document.register.user.focus();
	}
	else 
     	{
			var x = document.register.user.value;
			if(!isProper(x))
			{
				str += "-Invalid LOGIN ID\n"  ;
				document.register.user.value="";
				document.register.user.focus();
			}
    	}		
	if(document.register.pass1.value=="")
	{
		str += "Input password\n";
		document.register.pass1.focus();
	}
	if(document.register.pass2.value=="")
	{
		str += "Re-type Password\n";
		document.register.pass2.focus();
	}
	if(document.register.pass1.value!=document.register.pass2.value)
	{
		str += "Passwords mis-match\n";
	}
	if(document.register.email.value=="")
	{
		str += "Input Email Address\n";
		document.register.email.focus();
	}
	var x=document.register.email.value;
	if(!checkemail(x))
		{  
			str+="Not a valid Email Address";
		}
	
	/*
	if(document.register.fname.value=="")
	{
		str += "Input First Name\n";
		document.register.fname.focus();
	}
	if (document.register.instrument.selectedIndex <= 0) 
	{
		str += "Select Instrument\n";
		document.register.instrument.focus();
	} 
	
	if(document.register.agree.checked==false)
	{
		str += "Accept Agreement\n";
		//document.register.email.focus();
	}*/
	if(str != "")
	{
		alert("The following error(s) occured :\n ________________________\n"+str);
		document.register.user.focus();
		return false;
	}
	return true;
}

function isProper(string) {

   if (!string) return false;
   var iChars = "*|,\":<>[]{}`\';()@&$#%";

   for (var i = 0; i < string.length; i++) {
      if (iChars.indexOf(string.charAt(i)) != -1)
         return false;
   }
   return true;
}
// Validation for Song name & Band name
function isNameProper(string)
	{
   if (!string) return false;
   var iChars = "~^&?/=+_*|,\":<>[]{}\;@&$#%!";

   for (var i = 0; i < string.length; i++) {
      if (iChars.indexOf(string.charAt(i)) != -1)
         return false;
   }
   return true;
}
function deletetab(insid,tabid,instname,memtype,sname)
{
	if(memtype=="")
	{
		var reurl='http://www.findtabs.com/login.php';
		location=reurl;
	}
	else
	{
		if(tabid!="")
			{
				if(memtype=="UM")
				{
						var url='http://www.findtabs.com/verifyemailpopup.php';
						window.open(url,'popup','height=251,width=427');
						return false;
					
				}
				else
				{
					if(confirm("Are you sure  you want to vote to delete "+sname+"?"))
					{	
						document.tabdetail.votedel.value="yes";
						document.tabdetail.submit();
						
					}
				}
			}
	 }
   return true;
}
// to adopt the tab by valid users
function adopttab(insid,tabid,memtype,memname)
{	//alert(arg);
	if(memtype=="")
	{
		var reurl='http://www.findtabs.com/login.php';
		location=reurl;
	}
	else
	{		
		if(tabid!="")
		{
			if(memtype=="CM" || memtype=="MO" || memtype=="SM" || memtype=="SA")
			{			
				if(memname=="Unregistered")
				{  
					var reurl='http://www.findtabs.com/adopttab.php?dID='+tabid+'&insid='+insid;//alert(reurl);
					location=reurl;
					//alert("You are not allowed to delete the tab");
					//return false;
				}
				
				else
				{
					var reurl='http://www.findtabs.com/accessdeniedpage.php?dID='+tabid+'&insid='+insid;
					//alert(reurl);
					location=reurl;
				}

			}
			else
			{
					var reurl='http://www.findtabs.com/accessdeniedpage.php?dID='+tabid+'&insid='+insid;
					//alert(reurl);
					location=reurl;
				
			}
		}
  }
   return true;
}



function validateartist()
{
	var str = "";
	if(document.register.bandname.value=="")
	{
		str += "Enter Band name\n";
		document.register.bandname.focus();
	}
	if(document.register.skill.value=="")
	{
		str += "Enter Skills\n";
		document.register.skill.focus();
	}
	if(str != "")
	{
		alert("The following error(s) occured :\n ________________________\n"+str);
		return false;
	}
	return true;
}



function getmemtypeEmail(string)
{
	if (string.length >0) {
	 i=string.indexOf("@")
	 j=string.indexOf(".",i)
	 k=string.indexOf(",")
	 kk=string.indexOf(" ")
	 jj=string.lastIndexOf(".")+1
	 len=string.length

 	if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) 
 		return true;	
 	else 
		return false;
 }
}
//for email validations
function checkemail(email)
{
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|in)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=email.match(emailPat);
if (matchArray==null) {
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
return false;
   }
}
if (user.match(userPat)==null) {
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
return false;
   }
}
return true;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
return false;
   }
}
if (checkTLD && domArr[domArr.length-1].length!=2 &&
domArr[domArr.length-1].search(knownDomsPat)==-1) {
return false;
}
if (len<2) {
    return false;
   }
  return true;
}

function mycheckDate(f)
{
	var dtCh= "/";
	var minYear=1000;
	var maxYear=3000;
	var dtStr=eval(f+".value");
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strMonth=dtStr.substring(0,pos1);
	var strDay=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++)
	{
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1)
	{
		alert("The date format should be : mm/dd/yyyy")
		eval(f+".select()");
		eval(f+".focus()");
		return false
	}
	if(isNaN(month)||isNaN(day)||isNaN(year))
	{
		alert("Please enter numeric date value");
		eval(f+".select()");
		eval(f+".focus()");
		return false;
	}
	if(month<1 || month>12) 
	{
		alert("Please enter a month between 1 and 12");
		eval(f+".select()");
		eval(f+".focus()");
		return false;
	}
	else if(day<1 || day>31) 
	{
		alert("Please enter a date between 1 and 31");
		eval(f+".select()");
		eval(f+".focus()");
		return false;
	}
	else if (strYear.length != 4 || year==0 || year<minYear || year>maxYear)
	{
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
		eval(f+".select()");
		eval(f+".focus()");
		return false;
	}
	else if (dtStr.indexOf(dtCh,pos2+1)!=-1)
	{
		alert("Please enter a valid date");
		eval(f+".select()");
		eval(f+".focus()");
		return false;
	}
	else
	{
		return true;
	}
}


function myvalid(mt)
{
	if(mt=="")
	{
		var reurl='http://www.findtabs.com/login.php';
		location=reurl;
		return false;
	}
	else
	{	
		if(mt=="UM")
		{
			var url='http://www.findtabs.com/verifyemailpopup.php';
			window.open(url,'popup','height=251,width=427');
			return false;
		}
		else
		{
			var str = "";
			
			if (document.register.instrument.selectedIndex <= 0) 
			{
				str += "Select Instrument\n";
				document.register.instrument.focus();
			} 
			if(document.register.bname.value=="")
			{
				str += "Input band name\n";
				document.register.bname.focus();
			}
			else 
			{
				var x = document.register.bname.value;
				if(!isNameProper(x))
				{
					str += "-Invalid band name \n"  ;
					document.register.bname.value="";
					document.register.bname.focus();
				}
			}		
			if(document.register.sname.value=="")
			{
				str += "Input song name\n";
				document.register.sname.focus();
			}
			else 
			{
				var x = document.register.sname.value;
				if(!isNameProper(x))
				{
					str += "-Invalid song name \n"  ;
					document.register.sname.value="";
					document.register.sname.focus();
				}
			}		
			if(document.register.tab.value=="")
			{
				str += "Input tab description\n";
				document.register.tab.focus();
			}
			if (document.register.type.selectedIndex <= 0) 
			{
				str += "Select Type\n";
				document.register.type.focus();
			} 
			if (document.register.version.selectedIndex <= 0) 
			{
				str += "Select Version\n";
				document.register.version.focus();
			} 
			if (document.register.part.selectedIndex <= 0) 
			{
				str += "Select Part\n";
				document.register.part.focus();
			} 
			if(str != "")
			{
				alert("The following error(s) occured :\n ________________________\n"+str);
				return false;
			}
			return true;
		}
	}
}
// for search form //

function submitform()
{
	
	if(document.search1.q2.value=="" && document.search1.q.value=="")
	{
		alert("Enter Band/song name");
		return false;
		
	}
	return true;
}

/*

function chkbname(b)
{
	
	if(b=="bnd" && document.search1.q.value=="")
	{
		alert("Enter Band name");
		return false;
		
	}
	else if(b=="sng" && document.search1.q2.value=="")
	{
		alert("Enter Song name");
		return false;
	}
	return true;
}*/
/*
function chksong()
{
	if(document.search2.q2.value=="")
	{
		alert("Enter Song name");
		return false;
	}
	
	return true;
}
*/

function chkaction(arg)
{
	document.comparison.hiddenaction.value=arg;
	document.comparison.submit();
	
}

function chksname()
{
	if(document.search1.sname.value=="")
	{
		alert("Enter song name");
		return false;
	}
	else
	{
		document.search1.go2.value="yes";
	}
	return true;
}
// to close the popup window
function winClose()
{
	window.close();
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);