// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array();
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = "/slideshow/mod1.jpg"
Pic[1] = "/slideshow/mod2.jpg"
Pic[2] = "/slideshow/mod3.jpg"
Pic[3] = "/slideshow/mod4.jpg"
Pic[4] = "/slideshow/mod5.jpg"
Pic[5] = "/slideshow/mod6.jpg"

// do not edit anything below this line
var t;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];

}

function runSlideShow() 

{

if (document.all) {
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
t = setTimeout('runSlideShow()', slideShowSpeed);
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i>a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i>d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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 ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	} 
	
function validatefrm(t,secverify,flg)
{
if(flg==1)
{
	if(t.name.value=="")
	{
		alert("Please specify your Name....");
		t.name.focus();
		return 0;
	}
	if(t.companyname.value=="")
	{
		alert("Please specify your Company Name....");
		t.companyname.focus();
		return 0;
	}
	if(t.address.value=="")
	{
		alert("Please specify your Postal Address....");
		t.address.focus();
		return 0;
	}
	if(t.cityname.value=="")
	{
		alert("Please specify your City/ Town Name....");
		t.cityname.focus();
		return 0;
	}
	if(t.distname.value=="")
	{
		alert("Please specify your District Name....");
		t.distname.focus();
		return 0;
	}
	if(t.statename.value=="")
	{
		alert("Please specify your State Name....");
		t.statename.focus();
		return 0;
	}
	if(t.country.value=="")
	{
		alert("Please specify your Country Name....");
		t.country.focus();
		return 0;
	}
	var emailID=t.email

	
	if (chkblank(t.email,"Please enter E-mail Id!")==0)
		return 0;
	if (t.email.value!="")
	{
		if (echeck(t.email.value)==false)
		{
			t.email.value="";
			t.email.focus();
			return 0;
		}
	}
		if (chkblank(t.phones,"Please specify Mobile Number!")==0)
		return 0;
	mob1=t.phones.value;
		if (mob1!="" || mob1!=0)
	{
		if (mobcheck(t.phones)==0)
			return 0;
	}
	
}
			var statusList = document.getElementById('typ');
			var selectedStatus = statusList.options[statusList.selectedIndex].value; 
			
			if (selectedStatus=="Enquiry")
				{	
				if (chkselect(t.selproduct,"Please Select Product!")==0)
				return 0;
				
				}


	if(t.comments.value=="")
	{
		alert("Please specify your Comments/ Suggestions....");
		t.comments.focus();
		return 0;
	}
	if (flg==1)
	{
	if(t.strCAPTCHA.value=="")
	{
		alert("Please specify capture code shown in image above - Used for controlling automated harvesting....");
		t.strCAPTCHA.focus();
		return 0;
	}
	 } 
	t.submit();
	return 1;
}



function mobcheck(input)
{

var str = input.value;

	if (str.length!=10)
	{
		alert("Invalid Mobile number...");
		input.focus();
	    return false;
	}
	if (str.substring(1,0)<"6")
	{
		alert("Invalid Mobile number...");
		input.focus();
	    return false;
	}
	for (var i = 0; i < str.length; i++) 
	{
        	var ch = str.substring(i, i + 1)
	        if (ch < "0" || "9" < ch) 
			{
			input.value=""
        	alert("Invalid Mobile number...");
			input.focus();
		    return false;
	    	}
	}
	return true;
}
//Blank textfield validation
function chkblank(t,msg)
{
	if (t.value=="")
	{
		alert(msg);
		t.focus();
		return 0;
	}
	return true;
}
function chkradio(r,msg)
{
myOption = -1;
	
	for (i=r.length-1; i > -1; i--)
	 {
	if (r[i].checked) 
	{
		myOption = i; i = -1;
	}
	}
	if (myOption == -1) {
	alert(msg);
	return 0;
	}
}

//validation for selection list
function chkselect(t,msg)
{
	selno = t.selectedIndex; 
	
	selvalue = t.options[selno].value; 
	if (selvalue==0)
	{
		alert(msg);
		t.focus();
		return 0;
	}
	return true;
}


function chkseldate(dy,mth,yrs,msg)
{
	td=dy.selectedIndex;
	td=dy.options[td].value;
	if (td==0)
	{
		alert("Please specify date!");
		dy.focus();
		return 0;
	}
	tm=mth.selectedIndex;
	tm=mth.options[tm].value;
	if (tm==0)
	{
		alert("Please specify Month!");
		mth.focus();
		return 0;
	}
	ty=yrs.selectedIndex;
	ty=yrs.options[ty].value;
	if (ty==0)
	{
		alert("Please specify Year!");
		yrs.focus();
		return 0;
	}
	md=monthdays(tm,ty);
	if (td>md)
	{
		alert(msg);
		dy.focus();	
		return 0;
	}
	else
	
		return 1;
}

function monthdays(mon1,yr)
{
	switch (mon1){	
	case "2":
		if (yr==0)
			mdays=29;
		else
		{
			lp1=yr % 400;
			if (lp1==0)
				mdays=29;
			else
			{
				lp2=yr % 4;
				lp3=yr % 100;
				if ((lp2==0) && (lp3>0))
					mdays=29;
				else
					mdays=28;
			}
		}
		break;
	case "4":	
	case "6":
	case "9":	
	case "11":
		mdays=30;
		break;
	default:
		mdays=31;
		break;
	}
	return mdays;
}

function CheckNumber(input)
{

	var str = input.value;
	for (var i = 0; i < str.length; i++) 
	{
        	var ch = str.substring(i, i + 1)
	        if ((ch < "0" || "9" < ch) && ch != '.'  && ch!=",") 
			{
			input.value=""
        	      	alert("Please Enter Numeric Value...");
			input.focus();
		        return false;
	    	}
	}
	return true;
}

 function changepage(f)
{
	pg=f.pgno.selectedIndex;
	pg=f.pgno.options[pg].value
	f.s.value=f.cntrr.value * (pg -1 ) +1;
	f.submit();
}
function cdel(lnk,msg,nid)
{
	
	x=confirm(msg);
	if (x==true)	
		document.location.href= lnk + "?id=" + nid;
		
}
function changep(f)
{
	if (chkblank(f.opwd,"Please specify your old password!")==0)
		return 0;
	if (chkblank(f.npwd,"Please specify new password!")==0)
		return 0;
	if (chkblank(f.cpwd,"Please confirm your password by retyping it!")==0)
		return 0;
	if (f.npwd.value!=f.cpwd.value)
		{
			alert("Your new password does not match with the confirm password. Make sure they are same!!!")
			f.npwd.focus();
			return 0;
		}
		f.submit();
		return 1;	
}



//this function use button onclick check checkbox checked or not and confirmation message for submit the form
function delchk(f,msg,lnk)
{
	titems=f.ccnt.value;
	j=0;
	i=0;
	while (j<=titems)	
	{	
		if(eval("f.chk"+j+".checked")==true)
		
		i++;
	    j=j+1;
	}
	if (i==0)
	{
		alert("Please select Items To Delete")
		return false;
	}
	
	x=confirm(msg);
	if (x==true)	
	{	
	f.action=lnk;
	f.submit();
	return 1;
	}
}
// this function checked all checkbox
function setchkall(f)
{
	titems=f.ccnt.value;
	
	j=0;
	
	while (j<=titems)	
	{	
		eval("f.chk"+j+".checked=f.chk.checked");	
	    j=j+1;
	}
}

function buttondlink(lnk)
{
	
	location.href=lnk;	
	return 1;
}

function buttonlink(f,lnk)
{
	f.action=lnk;
	f.submit();
	return 1;
}

function valrequestdealer(f)
{
	if (chkblank(f.txtname,"Please specify Company Name!")==0)
		return 0;
	if (chkblank(f.txtaddress,"Please specify Contact Address!")==0)
		return 0;
	if (chkblank(f.txtconpname,"Please specify Contact Person Name!")==0)
		return 0;
	if (chkblank(f.mobile,"Please specify Mobile Number!")==0)
		return 0;
	mob1=f.mobile.value;
		if (mob1!="" || mob1!=0)
	{
		if (mobcheck(f.mobile)==0)
			return 0;
	}
	
	if (chkblank(f.email,"Please enter E-mail Id!")==0)
		return 0;
	if (f.email.value!="")
	{
		if (echeck(f.email.value)==false)
		{
			f.email.value="";
			f.email.focus();
			return 0;
		}
	}
	
	
	if (chkblank(f.txtcity,"Please specify City!")==0)
		return 0;

	if (chkblank(f.txtpin,"Please specify  Pin-code!")==0)
		return 0;
		
		if (CheckNumber(f.txtpin)==0)
			return 0;
		
				
		if (chkselect(f.selcountry,"Select Country!")==0)
		return 0;
		
		var statusList = document.getElementById('selcountry');
			var selectedStatus = statusList.options[statusList.selectedIndex].text; 
			
			if (selectedStatus=="India")
			{
				document.getElementById('st').style.display="block";
				if (chkselect(f.selstate,"Select state!")==0)
				return 0;
			}
	
	if (chkblank(f.txtbrandname,"Please specify Others Co. Dealership Brand Name!")==0)
		return 0;
	if (chkblank(f.txtturnover,"Please specify Yearly Turn Over!")==0)
		return 0;
	if (chkblank(f.txtemployee,"Please specify Total Employee!")==0)
		return 0;
		if (CheckNumber(f.txtemployee)==0)
			return 0;
	if (chkradio(f.rbvan,"Please Select Delivery Van")==0)
		return 0;
	if (chkblank(f.txtarea,"Please specify Area To Be Covered!")==0)
		return 0;
	if (chkblank(f.txtcoverage,"Please specify Total Coverage of Shops/Dealers !")==0)
		return 0;
	if (chkblank(f.txtvat,"Please specify VAT And CST No.!")==0)
		return 0;
			
	
	if (chkselect(f.selcategory,"Please Select Your Category!")==0)
		return 0;
		
	
	if (chkblank(f.txtremark,"Please specify Remark!")==0)
		return 0;
	
	if (chkblank(f.strCaptcha,"Please specify Code!")==0)
		return 0;
		
		f.submit();
	return 1;
}

function checkcountry(f)
{
	
		var statusList = f.selcountry
		//var statusList = document.getElementById('selcountry');
			var selectedStatus = statusList.options[statusList.selectedIndex].text; 
			
			if (selectedStatus=="India")
			{
				document.getElementById('st').style.display="block";
				//if (chkselect(f.selstate,"Select state!")==0)
				//return 0;
			}	
			else
			{
				document.getElementById('st').style.display="none";
			}
}

// change online language script start ---->
function splitmsg(lang)
{
	 var txt=document.getElementById("article").innerHTML;
	var len= txt.length;
	 var words = 500;
	for (ii=0; ii<=(len/words); ii++)
	{
		var source=txt.substr(ii*words, words)
		//alert(source);
		 translate(lang,source)
	}
}


 function translate(lang) {
		
  var source=document.getElementById("article").innerHTML;

   var len = source.length;
 
   // Google Language API accepts 500 characters per request 
   var words = 500;

   // This is for English pages, you can change the
   // sourcelang variable for other languages
   
   var sourcelang = "en";
   document.getElementById("translation").innerHTML = "";
	
   for(i=0; i<=(len/words); i++) {
       google.language.translate (source.substr(i*words, words),"en", lang, function (result) 
	{
	
     if (!result.error) {
	
   document.getElementById("translation").innerHTML = document.getElementById("translation").innerHTML + result.translation;
		
    } }); 
	 	
	 }  

  // Hide the text written in the original language
  document.getElementById("article").style.display = 'none';
  document.getElementById("translation").innerHTML = "";
   return false;
    
 }

 // Switch to the original language

 function original() {
  document.getElementById("translation").style.display='none';
  document.getElementById("article").style.display = 'block';
  return false;
 }
 
 //--------- end ------>
 
 function photoview(pname)
{
	pname="../asp/view.asp?pi="+pname
	window.open(pname,"Photo","resizable=yes,toolbar=0,location=0,menubar=0,status=0,height=500 ,top=220,left=250,width=700,,status=0,scrollbars=0");	
}
 

