/* $Id: msm_common.js,v 1.4 2002/06/07 08:20:35 kalpesh Exp $ */
var g = 1 ;
var banid=new Array('');
var links=new Array('');
var alt=new Array('');
var duration=new Array('');
var target=new Array('');


var msgMandatoryFieldEmpty="You must enter all the mandatory fields marked with *.";
var msgUserIdMustLong="User ID must be of 4 to 12 characters long.";
var msgWhiteSpace="White spaces are not allowed.";
var msgSpecialChar="Special characters are are not allowed.";
var msgPasswdMustLong="Password must be of 4 to 12 characters long.";
var msgSamePasswd="Please, enter same values for password and confirm password.";


function makeChange(v1,v2,curval,cond)
{
	if(isNaN(curval))
		var id_model = ' ';
	else
		var id_model = curval;
        var makeid = new String(v1.options[v1.selectedIndex].value);
	if(makeid != "")
	{
		if(cond == "Y" )
		{
	        	v2.length = 1;	        	
	                var j = 1;
		}
		else if(v2.length > 0 && v2.options[0].value == "")
		{
	        	v2.length = 1;	        	
	                var j = 1;
		}		
		else
		{
	        	v2.length = 0;
			var j = 0;	
		}
        	v2.selectedIndex = 0;			
	        for(i=0;i < vmake[makeid]['model'].length;i++)
	       	{		
	           	var model_value = new String(vmake[makeid]['model'][i]) ;
			var model_text = vmodel[model_value];	
			if(cond == "Y")
			{
				if(vcount[model_value] > 0)
				{				
			                modelOpt =new Option(model_text,model_value);				
				        eval("v2.options[j] = modelOpt");
				        if(id_model == model_value)
			       		       	v2.selectedIndex = j;
					j++;
				}
			}
			else
			{
			        modelOpt =new Option(model_text,model_value);
				eval("v2.options[j] = modelOpt");		            
				if(id_model == model_value)
			       	    	v2.selectedIndex = j;
	
				j++;
			}
	        }
	}        		  
	else
	{
	     v2.length = 1;
	     var disp = v2.options[0].text;	     
	     v2.options[0].text = disp;
	     v2.options[0].value = '';
	     var j = 1;	  
	     for(k=0; k< vsmake.length;k++)
	     {  	                	        
	        var makeid = vsmake[k];      
	        for(i=0;i < vmake[makeid]['model'].length;i++)
	       	{		
	           	var model_value = new String(vmake[makeid]['model'][i]) ;
			var model_text = vmodel[model_value];	
			if(cond == "Y")
			{
				if(vcount[model_value] > 0)
				{				
			                modelOpt =new Option(model_text,model_value);				
				        eval("v2.options[j] = modelOpt");
				        if(id_model == model_value)
			       		       	v2.selectedIndex = j;
					j++;
				}
			}
			else
			{
			        modelOpt =new Option(model_text,model_value);
				eval("v2.options[j] = modelOpt");		            
				if(id_model == model_value)
			       	    	v2.selectedIndex = j;
	
				j++;
			}
              }
         }	  
      }
}
function yearChange(v1,v2,curval)
{	
	var tot = v1.selectedIndex + 1;	
	if(tot ==1)
	  tot = v1.options.length - 1;
	v2.length = 1;	
	for(i=1,j=1; i < tot; j++,i++)
	{
		temp = new Option(v1.options[i].value,v1.options[i].value);
		eval("v2.options[j] = temp");	
		
		if(curval == v1.options[i].value)
			v2.selectedIndex = j;		
	}
	
}
function priceChange(v1,v2,curval)
{
	var st = v1.selectedIndex;
	if(st == 0)
	  st = 1;
	var tot = v1.length;	
	v2.length = 1;
	for(i=st,j=1; i < tot; j++,i++)
	{
		temp = new Option(v1.options[i].value,v1.options[i].value);
		eval("v2.options[j] = temp");	
		
		if(curval == v1.options[i].value)
			v2.selectedIndex = j;
	}

}
function emailInvalid(s)
{
	if(!(s.match(/^[\w]+([_|\.-][\w]{1,})*@[\w]{2,}([_|\.-][\w]{1,})*\.([a-z]{2,4})$/i) ))
        {
		return false;
	}
	else
		return true;
}
function openWin(win_nm,nm)
{ 
        var h=screen.height;
        h=h-100;
                
        var myfeatures = 'directories=no,location=no,menubar=no,status=yes,titlebar=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height='+h+',left=0,top=0';
        
        if(nm == '') 
        	nm='new'; 
        
        var newImg = window.open(win_nm,nm,myfeatures);
        newImg.focus();

}
       
function openImg(img_nm,w,h,nm)
{
	var myfeatures = 'directories=no,location=no,menubar=no,status=yes,titlebar=no,toolbar=no,resizable=yes,scrollbars=yes,width='+w+',height='+h+',left=0,top=0';
	        
     	if(nm == '') 
        	nm='new';
     	    	
	var newImg = open(img_nm,nm,myfeatures);
	newImg.focus();
}

function openMsg(img_nm,w,h,nm)
{
	var myfeatures = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,resizable=yes,top=0,left=0,scrollbars=no,width='+w+',height='+h+',left=0,top=0';
	        
     	if(nm == '') 
        	nm='new';
     	    	
		var newImg = open(img_nm,nm,myfeatures);
		newImg.focus();
}

function imageout(imgname, path)
{
	imgname.src = path + "/listBlank.gif" ;
}


function imagein(imgname,path)
{
	imgname.src = path + "/listClick.gif";
}
function msgWin(img_nm,w,h)
{
	var myfeatures = 'directories=no,location=no,menubar=no,status=yes,titlebar=no,toolbar=no,resizable=yes,scrollbars=yes,width='+w+',height='+h+',left=0,top=0';	        
     	var nm='new';     	    	
	var newImg = open(img_nm,nm,myfeatures);
	newImg.document.writeln('<HTML><HEAD><TITLE>'+msgNettiauto+'</TITLE></HEAD><BODY>');
	newImg.document.writeln('<TABLE width=100%><TR>\n<TD><img src=\"\/extra\/siteimage\/nettiauto.gif\" border=0></TD>');
	newImg.document.writeln('<TD>'+ img_nm + '</TD></TR>');
	newImg.document.writeln('<TR><td colspan=2 align=center><Form><input type=button name=close value='+ msgClose+' onClick=\"window.close();\"></form></TD></TR></TABLE>');		
	newImg.document.close();
	newImg.focus();
}

function doLogin()
{
	openMsg("msgWin.php?opt=OnlyForRegisteredUser",350,130);	
}

function submitNav(pno)
{	
	document.nav.page.value=pno;	
	document.nav.submit();
}

function submitFav()
{
	var flag = "N";
	for(i= 1; i < document.fav.length; i++)
	{
		if(document.fav.elements[i].type == "checkbox")
		{
			if(document.fav.elements[i].checked)
			{
				flag = "Y";
				continue;
			}
		}
	}
	if(flag != "Y")
		alert(msgSelectAtLeastOne);
	else
	{
		document.fav.opt.value = 'Fav';
		document.fav.submit();
	}
}

function isblank(s)
{
	for(var i=0; i < s.length; i++)
	{
		var c = s.charAt(i);
		
		if((c != ' ') && (c != '\n') && (c != '\t'))
			return false;
	}
	return true;
}
function sortForm(col,ord)
	{
		document.sortl.sortCol.value = col;
		document.sortl.ord.value = ord;		
		document.sortl.submit();
		
		
	}
	
function confirmDel(ref)
{
	if(confirm(msgDeleteConfirm))
		window.location.replace(ref);		
}










function Timer()
{
	if (g < duration.length - 2)
	{
		g++;
		document.banner.src = eval("banner" + g + ".src");
	}
	else
	{
		g = 1;
		document.banner.src = eval("banner" + g + ".src");
	}
	window.setTimeout("Timer()", duration[g]) ;
}

function clickLink()
{
	if(!(links[g] == ''))
	{
		if (target[g] == 'blank')
		{
			bid=banid[g] ;
			url=links[g] ;
			str1="&url="+url ;
			str = "banner_counter.php?id="+bid+str1 ;
			window.open(str);
		}
		else
		{
			bid=banid[g] ;
			url=links[g] ;
			str1="&url="+url ;
			str = "banner_counter.php?id="+bid+str1 ;
			window.location.replace(str);
		}
	}
}
function descript()
{
	if (links[g] == "addUser.php")
		window.status=msgRegiUser;
	else
		window.status=links[g];
		
	if ((navigator.appName == 'Netscape') && (parseFloat(navigator.appVersion.substr(0, 3)) < 5.0))
	{
		document.netBan.visibility='show' ;
		text='';
		
		if (links[g] == "addUser.php")
			text = msgRegiUser;
		else
			text = alt[g];

		document.netBan.document.write('<layer id=id1 top=20 left=450 bgColor=#F7F7D3 style="border:0px solid white; font-family: Verdana; font-size:11px; color:black; ">'+text+'</layer>') ;
	}
	else
	{
		if (links[g] == "addUser.php")
			document.banner.title=msgRegiUser;
		else
			document.banner.title=alt[g];
	}
}
function remove()
{
	window.status='';
	
	if ((navigator.appName == "Netscape") && (parseFloat(navigator.appVersion.substr(0, 3)) < 5.0))
		document.netBan.visibility="hide" ;
}
