// JavaScript Document
//=================================================================

$(document).ready(function()
{
	//Thumb li bg on hover and click
	$('.thumboff').each(function() {
            $(this).hover(function() {
                $(this).addClass('thumbon').removeClass('thumboff');
            },
           function() {
               $(this).addClass('thumboff').removeClass('thumbon');
           });
            $(this).click(function() {
				$('.thumbcurr').each(function() {
					$(this).addClass('thumboff').removeClass('thumbcurr');
				});
                $(this).addClass('thumbcurr').removeClass('thumbon');
				var imgid = $(this).attr("id");
				imgid = imgid.replace("img","");
				//alert (imgid);
				$('#projectdesc').fadeOut();
				$("#whiteboxoverlay").show();
				$.ajax({
				   type: "POST",
				   url: "scripts/update-whitebox.php",
				   data: "imgid="+imgid,
				   success: function(msg){
					 var currimgurl = $('#whiteboximg').attr("src");
					 $('#whiteboxinner').css('background-image', 'url("' + currimgurl + '")');
					 $('#whiteboxinner').html('<img src=\"admin/uploaded_photos/'+imgid+'_pimage.jpg\" alt=\"Creative Quest\" width=\"695\" height=\"545\" border=\"0\" id=\"whiteboximg\" />');
					 $('#whiteboximg').bind("load", function() {
					 $("#whiteboxoverlay").fadeOut();
					 $('#whiteboximg').fadeIn();
					 $('#projectdesc').html(msg).fadeIn();
					 });

				   }
				});
           });
    });

	$('#whiteboximg').hide();
	$("#whiteboximg").bind("load", function () { $(this).fadeIn(); });

});

//=======================================

// JavaScript Document
function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}

function checkfrm(frm)
{ 

 if (frm.name.value=="")
    {
      alert("Please enter your Name" );
      frm.name.focus();
      return false;
    }
 if (frm.email.value=="")
    {
      alert("Please enter your Email Id" );
      frm.email.focus();
      return false;
    }
 if (invalidemail(frm.email.value))
    {
  
  alert("Email address should be of type 'abc@pqr.com' or 'abc@pqr.co.in' etc. ");
       frm.email.focus();
       return false;
    }
 if (frm.phone.value=="")
    {
      alert("Please enter your Phone No." );
      frm.phone.focus();
      return false;
    }
 if (frm.query.value=="")
    {
      alert("Please enter your Query" );
      frm.query.focus();
      return false;
    }


return true;
}


function invalidemail(s)
{
  res=0;
  len=s.length;

   for(i=0;i<len;i++)
     { 
       if(s.charAt(i)=='@' )
	 
   for(j=i;j<len;j++)
            {
              if(s.charAt(j)=='.')
                  res=1;
	
             }
     }  
if (res==0)
    return true; 
  else
     return false; 
   
}

//==============Google Analytics===============
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-24320100-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();


