  window.onload = function() {
     initialiseTestimonialFromURL();
   }
  
  function initialiseTestimonialFromURL() {
     var initialTestimonial = window.location.href;
     var testimonialIdbeforeIndex = initialTestimonial.lastIndexOf("?");
     var testimonialId =  initialTestimonial.substr(testimonialIdbeforeIndex+1,initialTestimonial.length) ;
     return testimonialId ;
   }

function ValidateForm()
    {
    var i=0;var j=0;var k=0; var l=0;
	var Name="";var testimonials="";var authenticateddoc="";var VideoURL="";
    if(document.getElementById("Name"))
		{
		Name=document.getElementById("Name").value;
		i=ValidationFields(Name,0,"Name");
		}
	if(document.getElementById("DisplayName"))
		{
		DisplayName=document.getElementById("DisplayName").value;
		m=ValidationFields(DisplayName,0,"DisplayName");
		}
	if(document.getElementById("testimonials"))
		{
		testimonials=document.getElementById("testimonials").value;
		j=ValidationFields(testimonials,0,"testimonials");
		}
	if(document.getElementById("UploadDoc"))
		{
		authenticateddoc=document.getElementById("UploadDoc").value;
		k=ValidationFields(authenticateddoc,0,"UploadDoc");
		}
	if(document.getElementById("VideoURL"))
		{
		var VideoURL=document.getElementById("VideoURL").value;
		l=ValidationFields(VideoURL,0,"VideoURL");
		}
	if(testimonials=="Write a testimonial....")
        {
        testimonials="";
        }
		if(i==0 && m==0 && j==0 && k==0)
        {
      	document.getElementById('FromWriteTestimonial').submit();
	 	}
		else
		{
			if(i==0 && m==0 && k==0 && l==0)
			{
				
				document.getElementById('FromWriteTestimonial').submit();	
			}
			
		}
		
        return false;
    }
function ValidationFields(value,mode,name)
    {
    var flag,amount;
    flag=0;   
    flag=CompulsaryCheck(value,name);
     if(flag==0)
            {
            var color="black";
            }
        else
            {
            var color="red";
            }
    document.getElementById(name+"Txt").style.color=color;
    document.getElementById(name+"Msg").style.color=color;
    
    return flag;   
    }
function cleararea()
    {
    var testimonials= document.getElementById("testimonials").value;
    if(testimonials=="Write a testimonial....")
        {
        document.getElementById("testimonials").value="";
        document.getElementById("testimonials").focus();
        }
    }
function restorerarea()
    {
    var testimonials= document.getElementById("testimonials").value;
    if(testimonials=="")
        {
        document.getElementById("testimonials").value="Write a testimonial....";
        document.getElementById("testimonials").focus();
        }
    }
function CompulsaryCheck(value,name)
    {
    var flag=0;
    if(value=="")
        {
        msg="This is a Mandatory Field";
        flag=1;
        }
    else
        {
        msg="";
        flag=0;
        }
     document.getElementById(name+"Msg").innerHTML=msg;
     return flag;
    }

function CurrentTestimonial(CountValue)
{ 
       // alert(CountValue)  ;
        var queryString;      
        var TestimonialId = initialiseTestimonialFromURL();
		var CountIndex=Number(document.getElementById('testimonialcount').value);
		var Count=CountIndex+Number(CountValue);
		var totaltestimonialsnumber=document.getElementById('totaltestimonialsnumber').value;
		if(Count==0)
			{
			Count=totaltestimonialsnumber;
			}
		else
			{
				if(Count>totaltestimonialsnumber)
				{
				Count=(Count%totaltestimonialsnumber);
				}
			}
		document.getElementById('testimonialcount').value=Count;
		var req=createobj();
			if(req)
					{
						req.onreadystatechange=ProcessRequestTestimonial;
                        if(CountValue==1 || CountValue==-1 ){
                        queryString= "?Count="+Count;
                        }else
                        {
                        queryString= "?Count="+Count+"&ID="+TestimonialId;    
                        }
						req.open("GET","/include/ajax/get_testimonials.php"+queryString,true);
						req.send(null);	
					}
			return false;

}
function createobj()
		{
		if(window.XMLHttpRequest)
						{
							req = new XMLHttpRequest();
						}
					if(window.ActiveXObject)
						{
							req = new ActiveXObject("Microsoft.XMLHTTP");
						}
				return req;
		}
function ProcessRequestTestimonial()
		{
			if(req.readyState==4)
				{
					
						if(req.status==200)
						{   
                            var testimonial = eval('(' + req.responseText + ')');
                            document.getElementById('testimonial_id').innerHTML = testimonial.TestimonialId;
							var testimoniallength=testimonial.TestimonialHtmlContent.length;
						   	var totaltestimonialsnumber=document.getElementById('totaltestimonialsnumber').value;
                            if(testimonial.TestimonialsCountIndex.length == 0)
                            var countindex=document.getElementById('testimonialcount').value;
                            else
                            {
                            var countindex=testimonial.TestimonialsCountIndex;
                            document.getElementById('testimonialcount').value = countindex;
                            }
                            
							document.getElementById('TestimonialsCountIndex').innerHTML=countindex+'/'+totaltestimonialsnumber;  
							if(testimoniallength>=1350)
								{
								var str='<table border="0" cellpadding="4" cellspacing="0"><tr><td><div id="wn"><div id="lyr1">'+testimonial.TestimonialHtmlContent+'</div></div></td><td><div id="scrollbar"><div id="up"><a class="mouseover_up" href=""><img src="/styles/oakviewlaw/img/btn-up.gif" width="11" height="11" alt="" border="0" /></a></div><div id="track"><div id="dragBar"></div></div><div id="down"><a class="mouseover_down" href=""><img src="/styles/oakviewlaw/img/btn-dn.gif" width="11" height="11" alt="" border="0" /></a></div></div></td></tr></table>';
								document.getElementById("main").innerHTML=str;
								if(document.getElementById("dscrollbar"))
									{
									document.getElementById("dscrollbar").style.display='block';
									}
								init_dw_Scroll();
                                
                                    tpvplayer = document.getElementById("testimonials_page_video");  
                                            
                                    if(!FlashDetect.installed && tpvplayer)
                                    {
                                        tpvplayer.innerHTML = "<span style='font-size: 16px;font-weight:bold'>Hello, you either have Flash plugin turned <br/> off or an old version of Adobe's<br/> Flash Player.</span><br/><br/><span style='font-weight:bold;'><a href='http://www.adobe.com/go/getflashplayer/' target='_blank'>Get the latest Flash player to view this video.</a><span/>";   
                                    }
								}
							else
								{
						var str='<table border="0" cellpadding="0" cellspacing="0"><tr><td><div id="wn">'+testimonial.TestimonialHtmlContent+'</div></td></tr></table>';
									document.getElementById("main").innerHTML=str;
								if(document.getElementById("dscrollbar"))
									{
									document.getElementById("dscrollbar").style.display='none';
									}
                                   
                                   tpvplayer = document.getElementById("testimonials_page_video");  
                                            
                                    if(!FlashDetect.installed && tpvplayer)
                                    {
                                        tpvplayer.innerHTML =  "<span style='font-size: 16px;font-weight:bold'>Hello, you either have Flash plugin turned <br/> off or an old version of Adobe's <br/> Flash Player</span>.<br/><br/><span style='font-weight:bold;'><a href='http://www.adobe.com/go/getflashplayer/' target='_blank'>Get the latest Flash player to view this video.</a><span/>";
                
                                    }
                                   
								}
								
								
						}
				}
		}