//username and email validation
var xmlHttp = createXmlHttpRequestObject();
// creates an XMLHttpRequest instance
function createXmlHttpRequestObject()
{
// will store the reference to the XMLHttpRequest object
var xmlHttp;
// this should work for all browsers except IE6 and older
try
{
// try to create XMLHttpRequest object
xmlHttp = new XMLHttpRequest();
}
catch(e)
{
// assume IE6 or older
var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
"MSXML2.XMLHTTP.5.0",
"MSXML2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0",
"MSXML2.XMLHTTP",
"Microsoft.XMLHTTP");
// try every prog id until one works
for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
{
try
{
// try to create XMLHttpRequest object
xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
}
catch (e) {}
}
}
// return the created object or display an error message
if (!xmlHttp)
alert("Error creating the XMLHttpRequest object.");
else
return xmlHttp;
}



function isemail(st) {
if (st.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){
return true;}
else{
return false;
}
}


function send(){
var illegalchars = /\W/;
	
var name=document.getElementById('name').value;
var email=document.getElementById('email').value;
var comment=document.getElementById('comment').value;
if(isemail(email)==false || illegalchars.test(name) || name.length>20 || name.length<3 || email.length>20 || email.length<5 || comment.length<5){
     if(isemail(email)==false || email.length>20 || email.length<5){
	 document.getElementById('errcnt').innerHTML="Email is invalid";
	 }else if(comment.length<5){
	 document.getElementById('errcnt').innerHTML="comments reqiured.";
	 }else if(illegalchars.test(name) || name.length>20 || name.length<3){
	 document.getElementById('errcnt').innerHTML="Name please.";
	 }
}else{
//here

// only continue if xmlHttp isn't void

if (xmlHttp)
{
// try to connect to the server
try
{
// initiate reading the async.txt file from the server
var url="send.php?name="+encodeURIComponent(document.getElementById('name').value);
url=url+"&email="+encodeURIComponent(document.getElementById('email').value);
url=url+"&comment="+encodeURIComponent(document.getElementById('comment').value);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = handleit;
xmlHttp.send(null);
}
// display the error in case of failure
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}




//end
}
}


function handleit(){
if (xmlHttp.readyState == 1){
document.getElementById('chge').innerHTML='<img align="center" src="images/loading.gif">';
}else{
document.getElementById('chge').innerHTML=xmlHttp.responseText;
}
}

function over(id){
if(id==1){
document.getElementById('home').src='images/home_h.jpg';
}else if(id==2){
document.getElementById('home').src='images/home_a.jpg';
}else if(id==3){
document.getElementById('port').src='images/portf_h.jpg';
}else if(id==4){
document.getElementById('port').src='images/portf_a.jpg';
}else if(id==5){
document.getElementById('about').src='images/about_h.jpg';
}else if(id==6){
document.getElementById('about').src='images/about_a.jpg';
}else if(id==7){
document.getElementById('cont').src='images/contact_h.jpg';
}else if(id==8){
document.getElementById('cont').src='images/contact_a.jpg';
}
}

$(document).ready(function(){
  $(".confrm").click(function(){
  $(".contactform").slideToggle();
  
  if( $("#aboutinfo").is(":visible") == true ){
   $("#aboutinfo").slideToggle("slow");
}
  });
});




function imgone(){
document.getElementById('one').src="images/ads_yellow.jpg";
document.getElementById('two').src="images/ads_gray.jpg";
document.getElementById('three').src="images/ads_gray.jpg";
$("#adsbnr").fadeTo("slow",0.15);
document.getElementById('adsbnr').src="images/jilaa.jpg";
$("#adsbnr").fadeTo("slow",1);
var num=0;
}

function imgtwo(){
document.getElementById('two').src="images/ads_yellow.jpg";
document.getElementById('three').src="images/ads_gray.jpg";
document.getElementById('one').src="images/ads_gray.jpg";
$("#adsbnr").fadeTo("slow",0.15);
document.getElementById('adsbnr').src="images/horn.jpg";
$("#adsbnr").fadeTo("slow",1);
var num=1;
}

function imgthree(){
document.getElementById('three').src="images/ads_yellow.jpg";
document.getElementById('two').src="images/ads_gray.jpg";
document.getElementById('one').src="images/ads_gray.jpg";
$("#adsbnr").fadeTo("slow",0.15);
document.getElementById('adsbnr').src="images/diirad.jpg";
$("#adsbnr").fadeTo("slow",1);
var num=2;
}


//rotate adbanners
 var num = 0;
var rotate = true;
function rotateslide()
{
if (!rotate)
return;
switch(num)
{
case 0:
 imgone();
 num++;
 break;
case 1:
 imgtwo();
 num++;
break;
case 2:
 imgthree();
 num++;
 break;        
}
if (num == 3)
    num = 0;
if (rotate)
    setTimeout(rotateslide, 8000);    
}

function moreuniq(){

$("#moreit").slideToggle({height:200},"slow");

}
//about
function abouty(){
$("#aboutinfo").slideToggle("slow");	
 if( $(".contactform").is(":visible") == true ){
   $(".contactform").slideToggle("slow");
}	
}

function hidriders(){	
 if( $(".contactform").is(":visible") == true ){
   $(".contactform").slideToggle("slow");
}
if( $("#aboutinfo").is(":visible") == true ){
   $("#aboutinfo").hide("slow");
}

}
//gallery slide


$(document).ready(function(){	
 
 
//testimonilas custom
$("#testminls").easySlider({ 

		continuous: true,
        nextText: 	'<img src="images/next_test.jpg" />',
        prevText: 		'<img src="images/prev_test.jpg" />',
		vertical: true

	});
$("#slider").easySlider({        nextText: 	'<img src="images/next.jpg" />',
        prevText: 		'<img src="images/prev.jpg" />',vertical: false});
});	


(function($) {

	$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {			
			prevId: 		'prevBtn',
			prevText: 		'Previous',
			nextId: 		'nextBtn',	
			nextText: 		'Next',
			controlsShow:	true,
			controlsBefore:	'',
			controlsAfter:	'',	
			controlsFade:	true,
			firstId: 		'firstBtn',
			firstText: 		'First',
			firstShow:		false,
			lastId: 		'lastBtn',	
			lastText: 		'Last',
			lastShow:		false,				
			vertical:		false,
			speed: 			800,
			auto:			false,
			pause:			2000,
			continuous:		false
		}; 
		
		var options = $.extend(defaults, options);  
				
		this.each(function() {  
			var obj = $(this); 				
			var s = $("li", obj).length;
			var w = $("li", obj).width(); 
			var h = $("li", obj).height(); 
			obj.width(w); 
			obj.height(h); 
			obj.css("overflow","hidden");
			var ts = s-1;
			var t = 0;
			$("ul", obj).css('width',s*w);			
			if(!options.vertical) $("li", obj).css('float','left');
			
			if(options.controlsShow){
				var html = options.controlsBefore;
				if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>';
				html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>';
				html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>';

				
				if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>';
				html += options.controlsAfter;						
				$(obj).after(html);										
			};
	
			$("a","#"+options.nextId).click(function(){		
				animate("next",true);
			});
			$("a","#"+options.prevId).click(function(){		
				animate("prev",true);				
			});	
			$("a","#"+options.firstId).click(function(){		
				animate("first",true);
			});				
			$("a","#"+options.lastId).click(function(){		
				animate("last",true);				
			});		
			
			function animate(dir,clicked){
				var ot = t;				
				switch(dir){
					case "next":
						t = (ot>=ts) ? (options.continuous ? 0 : ts) : t+1;						
						break; 
					case "prev":
						t = (t<=0) ? (options.continuous ? ts : 0) : t-1;
						break; 
					case "first":
						t = 0;
						break; 
					case "last":
						t = ts;
						break; 
					default:
						break; 
				};	
				
				var diff = Math.abs(ot-t);
				var speed = diff*options.speed;						
				if(!options.vertical) {
					p = (t*w*-1);
					$("ul",obj).animate(
						{ marginLeft: p }, 
						speed
					);				
				} else {
					p = (t*h*-1);
					$("ul",obj).animate(
						{ marginTop: p }, 
						speed
					);					
				};
				
				if(!options.continuous && options.controlsFade){					
					if(t==ts){
						$("a","#"+options.nextId).hide();
						$("a","#"+options.lastId).hide();
					} else {
						$("a","#"+options.nextId).show();
						$("a","#"+options.lastId).show();					
					};
					if(t==0){
						$("a","#"+options.prevId).hide();
						$("a","#"+options.firstId).hide();
					} else {
						$("a","#"+options.prevId).show();
						$("a","#"+options.firstId).show();
					};					
				};				
				
				if(clicked) clearTimeout(timeout);
				if(options.auto && dir=="next" && !clicked){;
					timeout = setTimeout(function(){
						animate("next",false);
					},diff*options.speed+options.pause);
				};
				
			};
			// init
			var timeout;
			if(options.auto){;
				timeout = setTimeout(function(){
					animate("next",false);
				},options.pause);
			};		
		
			if(!options.continuous && options.controlsFade){					
				$("a","#"+options.prevId).hide();
				$("a","#"+options.firstId).hide();				
			};				
			
		});
	  
	};

})(jQuery);






//validate form




//



