// 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/sidepic1.jpg"
Pic[1] = "/slideshow/sidepic2.jpg"
Pic[2] = "/slideshow/sidepic3.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;
	}
	var emailID=t.email
	if(emailID.value=="" && t.phones.value=="")
	{
		alert("Please specify either Contact Mobile Number or E-mail address...");
		t.phones.focus();
		return false;
	}
	if (emailID.value!="" && echeck(emailID.value)==false)
	{
	
		emailID.value=""
		emailID.focus()
		return false
	}
}
	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;
}
//Blank textfield validation
function chkblank(t,msg)
{
	if (t.value=="")
	{
		alert(msg);
		t.focus();
		return 0;
	}
	return true;
}


function mobcheck(input)
{

var str = input.value;

	if (str.length!=10)
	{
		alert("Invalid Mobile number...");
		input.focus();
	    return false;
	}
	if (str.substring(1,0)<"8")
	{
		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;	
}

function formattext(f,cnt,id)
{
var txtar = eval("document.getElementById('" + id + "')");
txtval=f.descrip.value;

var IE = document.all?true:false;

if (IE)
{
	var sel = document.selection.createRange();
	if (sel!=""){
		switch (cnt)
				{
					case 1:				
						sel.text = '<b>' + sel.text + '</b>';
						break;
					case 2:
						sel.text = '<i>' + sel.text + '</i>';
						break;
					case 3:
						sel.text = '<u>' + sel.text + '</u>';
						break;
					case 4:
						fface=f.fontface.selectedIndex;
						fface=f.fontface.options[fface].value;
						sel.text = "<font face='" + fface + "'>"  + sel.text + '</font>';
						break;
					case 5:
						fface=f.fontsz.selectedIndex;
						fface=f.fontsz.options[fface].value;
						sel.text = "<font size=" + fface + ">"  + sel.text + '</font>';
						break;
				}
			 }
}
else
{
	
	start=f.descrip.selectionStart;
	end=f.descrip.selectionEnd;
	len=txtval.length;
	var sel=txtval.substring(start,end);
	
	if (sel!="")
	{		switch (cnt)
				{
					case 1:				
							sel= "<b>" + sel + "</b>";
							f.descrip.value=txtval.substring(0,start) + sel + txtval.substring(end,len);
						break;
					case 2:
							sel = "<i>" + sel + "</i>";
							f.descrip.value=txtval.substring(0,start) + sel + txtval.substring(end,len);
						break;
					case 3:
							sel = "<u>" + sel + "</u>";
							f.descrip.value=txtval.substring(0,start) + sel + txtval.substring(end,len);
						break;
					case 4:
							fface=f.fontface.selectedIndex;
							fface=f.fontface.options[fface].value;
							sel = "<font face='" + fface + "'>"  + sel + '</font>';
							f.descrip.value=txtval.substring(0,start) + sel + txtval.substring(end,len);
						break;
					case 5:
						fface=f.fontsz.selectedIndex;
						fface=f.fontsz.options[fface].value;
						sel= "<font size=" + fface + ">"  + sel + '</font>';
						f.descrip.value=txtval.substring(0,start) + sel + txtval.substring(end,len);
						break;
				}
			} 
		}
			fillmsg(f);
f.descrip.focus();

}

function fillmsg(f)
{
	window.document.getElementById('fprev').style.display="block";
	showpreview(1);
	window.document.getElementById('preview').innerHTML=f.descrip.value;
}

function showLinkEditor(){
e = document.getElementById('linkInsert');
if(e.style.display=="none") e.style.display = "block";
else e.style.display = "none";
}

function insertLink(f){
content = f.descrip.value;
linkText = document.getElementById('l1').value;
linkUrl = document.getElementById('l2').value;
protocol = document.getElementById('prot').value;
lnk = "<a href='"+linkUrl+"' target='_blank'>"+linkText+"</a>&nbsp;";
f.descrip.value = content+lnk;
document.getElementById('l1').value="";
document.getElementById('l2').value="";
document.getElementById('linkInsert').style.display="none"; 
fillmsg(f);
}

function showpreview(cnt){
e = document.getElementById('preview');
if (cnt==1)
	e.style.display="block";
else
	 e.style.display = "none";

}

function replacecarriagereturn(textarea,replaceWith)   
{    
 textarea.value = escape(textarea.value);   
  //encode all characters in text area   
  //to find carriage return character   
 for(i=0; i < textarea.value.length; i++)   
 {    
  //loop through string, replacing carriage return    
  //encoding with HTML break tag   
  if(textarea.value.indexOf("%0D%0A") > -1)   
  {    
   //Windows encodes returns as \r\n hex   
   textarea.value=textarea.value.replace("%0D%0A",replaceWith);   
  }   
 else if(textarea.value.indexOf("%0A") > -1)   
  {    
   //Unix encodes returns as \n hex   
   textarea.value=textarea.value.replace("%0A",replaceWith);   
  }   
  else if(textarea.value.indexOf("%0D") > -1)   
  {    
  //Macintosh encodes returns as \r hex   
 textarea.value=textarea.value.replace("%0D",replaceWith);   
}   
}   
textarea.value=unescape(textarea.value);   
//decode all characters in text area back 
}


function vernotice(t)
{
	replacecarriagereturn(t.descrip,"<br>");
	
	if (t.servicetitle.value=="")
	{
		alert("Please specify Title");
		t.servicetitle.focus();
		return 0;
	}
	
	if(t.descrip.value=="")
	{
		alert("Please specify descrption...");
		t.descrip.focus();
		return 0;
	}

	t.submit();
	return 1;
}
// validate member login
function vallogin(t)
{
	if(t.uname.value=="")
	{
		alert("Please specify your User ID....");
		t.uname.focus();
		return 0;
	}
	if(t.upwd.value=="")
	{
		alert("Please specify your Login Password....");
		t.upwd.focus();
		return 0;
	}
	t.submit();
	return 1;
}

function enterkey(f)
{
	if(window.event.keyCode==13)
	{
		vallogin(f)
	}
}

function chknum(f)
{
if (CheckNumber(f.txtyear)==0)
			return 0;
}

function cdelcat(lnk,msg,nid,cid)
{
	
	x=confirm(msg);
	if (x==true)	
		document.location.href= lnk + "?id=" + nid + "&cname=" + cid;
}
function cdelnot(lnk,msg,nid,cid,cnt)
{
	
	x=confirm(msg);
	if (x==true)	
		document.location.href= lnk + "?id=" + nid + "&chk=" + cid + "&cnt=" + cnt ;
}

 
function valimgfile(t)
{
	if (chkselect(t.selcat,"Please Select category!")==0)
		return 0;
	
	if(t.imgfile.value=="")
	{
		alert("Please specify Image file for thumbnail to Upload...");
		t.imgfile.focus();
		return 0;
	}
	strr=t.imgfile.value;
	ln=strr.length;
	s1=strr.substring(ln-4,ln);
	
	if(s1!=".jpg" && s1!=".JPG")
	{
		alert("File type not supported! Only jpg image files can be uploaded.");
		t.imgfile.focus();
		return false;	
	}
	
	if(t.imgfile2.value=="")
	{
		alert("Please specify Image file to Upload...");
		t.imgfile2.focus();
		return 0;
	}
	strr=t.imgfile2.value;
	ln=strr.length;
	s1=strr.substring(ln-4,ln);
	
	if(s1!=".jpg" && s1!=".JPG")
	{
		alert("File type not supported! Only jpg image files can be uploaded.");
		t.imgfile2.focus();
		return false;	
	}
	t.submit();
	return 1;
}

function cdelpht(lnk,msg,nid,cid)
{
	
	x=confirm(msg);
	if (x==true)	
		document.location.href= lnk + "?fnm=" + nid + "&fval=" + cid;
}

function cdelpht1(lnk,msg,cid)
{
	
	x=confirm(msg);
	if (x==true)	
		document.location.href= lnk + "?fval=" + cid;
}

function valcategory(f)

{
	if (chkblank(f.catname,"Please specify category Name!")==0)
		return 0;
	
		f.submit();
		return 1;
}

function valcontent(f)

{
	if (chkblank(f.catname,"Please specify Page Name!")==0)
		return 0;
	
		f.submit();
		return 1;
}

function valvdo(f,flg)

{
	if (chkblank(f.txttitle,"Please Specify Video Title!")==0)
		return 0;
		if (flg==1)
		{
			if (chkblank(f.catname,"Please Paste Embedded Code!")==0)
				return 0;
		}
	if (chkblank(f.txtdur,"Please Specify Duration Of Video!")==0)
		return 0;
	if (CheckNumber(f.txtdur)==0)
		return 0;
		f.submit();
		return 1;
}



function valtextdate(f)
{
	if (chkblank(f.fromdt,"Please specify From Date!")==0)
		return 0;
		
	if (chkblank(f.todt,"Please specify To Date!")==0)
		return 0;
	
		f.submit();
		return 1;
		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 valjob(f)
{
		
		if (chkblank(f.txtname,"Please specify name!")==0)
			return 0;
		if (chkblank(f.txtaddress,"Please specify your Address!")==0)
			return 0;
		if (chkblank(f.txtcity,"Please specify city!")==0)
			return 0;
		if (chkblank(f.txtpin,"Please specify  Pin-code!")==0)
		return 0;	
			if(f.txtpin.value!=0 || f.txtpin.value!="")
			{
				if (CheckNumber(f.txtpin)==0)
					return 0;
				else
				{
					l=f.txtpin.value;
					llen=l.length;
					if (llen!=6)
					{
						alert("Invalid Zip/Postal Code!");
						f.txtpin.focus();
						return 0;
					}
				}
			}
	if (chkselect(f.country,"Select country!")==0)
		return 0;
	
		if (chkradio(f.gender,"Please specify Gender!")==0)
			return 0;
		if (chkseldate(f.bdd,f.bmm,f.byy,"Invalid birthDate!")==0)
			return 0;
	mob1=f.mobile.value;
	if (chkblank(f.mobile,"Please enter mobile no!")==0)
		return 0;
	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.fileresume,"Please Upload File!")==0)
		return 0;
	strr=f.fileresume.value;
	ln=strr.length;
	s1=strr.substring(ln-4,ln);
	
	if(s1!=".doc" && s1!=".docx" && s1!=".pdf")
	{
		alert("File type not supported! Only doc, docx, pdf files can be uploaded.");
		f.fileresume.focus();
		return false;	
	}
	if (chkblank(f.strCaptcha,"Please specify Code!")==0)
		return 0;	
		f.submit();
	return 1;
}

function valupload(f)
{
	if (chkblank(f.txttitle,"Please specify Title!")==0)
		return 0;	
	if (chkblank(f.txtdesp,"Please specify Description!")==0)
		return 0;
	if (chkblank(f.fileupd,"Please Upload File!")==0)
		return 0;
	strr=f.fileupd.value;
	ln=strr.length;
	s1=strr.substring(ln-4,ln);
	
	if(s1!=".doc" && s1!=".xls" && s1!=".pdf" && s1!=".jpg" && s1!=".gif" && s1!=".zip")
	{
		alert("File type not supported! Only doc, xls, pdf, jpg, gif, zip files can be uploaded.");
		f.fileupd.focus();
		return false;	
	}
		f.submit();
	return 1;
	
}
function imgupload(f)
{
	if (chkblank(f.fileupd,"Please Upload File!")==0)
		return 0;
	strr=f.fileupd.value;
	ln=strr.length;
	s1=strr.substring(ln-4,ln);
	
	if(s1!=".jpg" && s1!=".gif")
	{
		alert("File type not supported! Only jpg And gif  files can be uploaded.");
		f.fileupd.focus();
		return false;	
	}
		f.submit();
	return 1;
}

function enterkeysub(f)
{
	if(window.event.keyCode==13)
	{
		valsubcribe(f);
		
	}
}




function valsubcribe(f)
{
	
	if (chkblank(f.txtsub,"Please specify Your e-Mail ID!")==0)
	    return 0;
	
	if (f.txtsub.value!="")
	{
		if (echeck(f.txtsub.value)==false)
		{
			f.txtsub.value="";
			f.txtsub.focus();
			return false;
		}
		
	}
			f.submit();
			return 1;
	
}

function enterkeyadmin(f)
{
	if(window.event.keyCode==13)
	{
		valadmin(f);
		
	}
}

function valadmin(f)
{
	if (chkblank(f.txtemail,"Please specify Admin ID!")==0)
	    return 0;
	if (chkblank(f.txtpass,"Please specify Your password!")==0)
	    return 0;
	f.submit();
			return 1;
	
}

function buttondlink(lnk)
{
	
	location.href=lnk;	
	return 1;
}

function buttonlink(f,lnk)
{
	f.action=lnk;
	f.submit();
	return 1;
}

function valselpage(f)
{
	if (chkselect(f.selhed,"Please Select Content Page!")==0)
		return 0;
		f.submit();
	return 1;
}
