// Verify
function checkEmail(e)
{
 ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

 for(i=0; i < e.length ;i++)
  if(ok.indexOf(e.charAt(i))<0)
   return (false);

 if (document.images)
 {
  re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
  re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
  if (!e.match(re) && e.match(re_two))
   return true;
  else
   return false;

 }
 return true;

}

function valid_form(){

  var err='';
  if (document.getElementById("mortgage_co").value == ""){
    err = err + '<li>Mortgage Co</li>';
  }
  if(err==""){
  	document.getElementById("order_form").submit();
  }
  else{
  	err = '<strong>Please, fill in the following field</strong><ul>'+err+'</ul>';
  	document.getElementById("check_error").innerHTML = err;
    self.location.href='#check_error';
  }
}

function valid_private_form(){

  var err='';
  if (document.getElementById("login").value == ""){
    err = err + '<li>Login</li>';
  }
  if (document.getElementById("pass").value == ""){
    err = err + '<li>Password</li>';
  }
  if(err==""){
  	document.getElementById("private_form").submit();
  }
  else{
  	err = '<strong>Please, fill in the following field</strong><ul>'+err+'</ul>';
  	document.getElementById("check_error").innerHTML = err;
    self.location.href='#check_error';
  }
}
//
// Verify 2
function valid_form_2(){

  var err='';
  if (document.getElementById("first_name_or").value == ""){
    err = err + '<li>First Name</li>';
  }
  if (document.getElementById("last_name_or").value == ""){
    err = err + '<li>Last Name</li>';
  }
  if (document.getElementById("e_mail_address_or").value == ""){
    err = err + '<li>E-Mail Address</li>';
  }
  if (document.getElementById('e_mail_address_or').value != '')
 {
  if (!checkEmail(document.getElementById('e_mail_address_or').value))
  {
   err = err + '<li>Invalid Email</li>';
  }
 }
  if (document.getElementById("company_name_or").value == ""){
    err = err + '<li>Company Name</li>';
  }
  if (document.getElementById("address_or").value == ""){
    err = err + '<li>Address</li>';
  }
  if (document.getElementById("telephone_or").value == ""){
     err = err + '<li>Telephone #</li>';
  }
  if (document.getElementById("details_requests").value == ""){
    err = err + '<li>Details or Custom Requests</li>';
  }
  if(err==""){
  	document.getElementById("order_form_2").submit();
  }
  else{
  	err = '<strong>Please, fill in the following fields of the form with the required information:</strong><ul>'+err+'</ul>';
  	document.getElementById("check_error_2").innerHTML = err;
    self.location.href='#check_error_2';
  }
}
//

function hide_id(nodeId)
{
    var node = document.getElementById(nodeId);
    if (node)
    {
        node.className=node.className.replace('showed', '');
        node.className += ' hidden';
    }
}

function show_id(nodeId)
{
    var node = document.getElementById(nodeId);
    if (node)
    {
        node.className=node.className.replace('hidden', '');
        node.className += ' showed';
       $('html, body').animate({scrollTop:0}, 'slow');
    }
}

function toggle_id(nodeId)
{
    var node = document.getElementById(nodeId);
    if (node)
    {
        if (node.className.indexOf('hidden') != -1)
            node.className=node.className.replace('hidden', 'showed')
        else if (node.className.indexOf('showed') != -1)
            node.className=node.className.replace('showed', 'hidden')
        else node.className += ' showed';
     }
}

function setPrintCSS(isPrint) {
// By Akella cssing.org.ua
  if (document.getElementsByTagName)
      x = document.getElementsByTagName('link');
  else
  {
      return;
  }
  for (var i=0;i<x.length;i++) {
      if(x[i].title == 'printview'){x[i].disabled = !isPrint;}
      if(x[i].title == 'screenview'){x[i].disabled = isPrint;}
  }
}

/* jQuery Cycle Lite Plugin */
(function(D){var A="Lite-1.0";D.fn.cycle=function(E){return this.each(function(){E=E||{};if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=0;this.cyclePause=0;var I=D(this);var J=E.slideExpr?D(E.slideExpr,this):I.children();var G=J.get();if(G.length<2){if(window.console&&window.console.log){window.console.log("terminating; too few slides: "+G.length)}return }var H=D.extend({},D.fn.cycle.defaults,E||{},D.metadata?I.metadata():D.meta?I.data():{});H.before=H.before?[H.before]:[];H.after=H.after?[H.after]:[];H.after.unshift(function(){H.busy=0});var F=this.className;H.width=parseInt((F.match(/w:(\d+)/)||[])[1])||H.width;H.height=parseInt((F.match(/h:(\d+)/)||[])[1])||H.height;H.timeout=parseInt((F.match(/t:(\d+)/)||[])[1])||H.timeout;if(I.css("position")=="static"){I.css("position","relative")}if(H.width){I.width(H.width)}if(H.height&&H.height!="auto"){I.height(H.height)}var K=0;J.css({position:"absolute",top:0,left:0}).hide().each(function(M){D(this).css("z-index",G.length-M)});D(G[K]).css("opacity",1).show();if(D.browser.msie){G[K].style.removeAttribute("filter")}if(H.fit&&H.width){J.width(H.width)}if(H.fit&&H.height&&H.height!="auto"){J.height(H.height)}if(H.pause){I.hover(function(){this.cyclePause=1},function(){this.cyclePause=0})}D.fn.cycle.transitions.fade(I,J,H);J.each(function(){var M=D(this);this.cycleH=(H.fit&&H.height)?H.height:M.height();this.cycleW=(H.fit&&H.width)?H.width:M.width()});J.not(":eq("+K+")").css({opacity:0});if(H.cssFirst){D(J[K]).css(H.cssFirst)}if(H.timeout){if(H.speed.constructor==String){H.speed={slow:600,fast:200}[H.speed]||400}if(!H.sync){H.speed=H.speed/2}while((H.timeout-H.speed)<250){H.timeout+=H.speed}}H.speedIn=H.speed;H.speedOut=H.speed;H.slideCount=G.length;H.currSlide=K;H.nextSlide=1;var L=J[K];if(H.before.length){H.before[0].apply(L,[L,L,H,true])}if(H.after.length>1){H.after[1].apply(L,[L,L,H,true])}if(H.click&&!H.next){H.next=H.click}if(H.next){D(H.next).bind("click",function(){return C(G,H,H.rev?-1:1)})}if(H.prev){D(H.prev).bind("click",function(){return C(G,H,H.rev?1:-1)})}if(H.timeout){this.cycleTimeout=setTimeout(function(){B(G,H,0,!H.rev)},H.timeout+(H.delay||0))}})};function B(J,E,I,K){if(E.busy){return }var H=J[0].parentNode,M=J[E.currSlide],L=J[E.nextSlide];if(H.cycleTimeout===0&&!I){return }if(I||!H.cyclePause){if(E.before.length){D.each(E.before,function(N,O){O.apply(L,[M,L,E,K])})}var F=function(){if(D.browser.msie){this.style.removeAttribute("filter")}D.each(E.after,function(N,O){O.apply(L,[M,L,E,K])})};if(E.nextSlide!=E.currSlide){E.busy=1;D.fn.cycle.custom(M,L,E,F)}var G=(E.nextSlide+1)==J.length;E.nextSlide=G?0:E.nextSlide+1;E.currSlide=G?J.length-1:E.nextSlide-1}if(E.timeout){H.cycleTimeout=setTimeout(function(){B(J,E,0,!E.rev)},E.timeout)}}function C(E,F,I){var H=E[0].parentNode,G=H.cycleTimeout;if(G){clearTimeout(G);H.cycleTimeout=0}F.nextSlide=F.currSlide+I;if(F.nextSlide<0){F.nextSlide=E.length-1}else{if(F.nextSlide>=E.length){F.nextSlide=0}}B(E,F,1,I>=0);return false}D.fn.cycle.custom=function(K,H,I,E){var J=D(K),G=D(H);G.css({opacity:0});var F=function(){G.animate({opacity:1},I.speedIn,I.easeIn,E)};J.animate({opacity:0},I.speedOut,I.easeOut,function(){J.css({display:"none"});if(!I.sync){F()}});if(I.sync){F()}};D.fn.cycle.transitions={fade:function(F,G,E){G.not(":eq(0)").css("opacity",0);E.before.push(function(){D(this).show()})}};D.fn.cycle.ver=function(){return A};D.fn.cycle.defaults={timeout:9000,speed:1000,next:null,prev:null,before:null,after:null,height:"auto",sync:1,fit:0,pause:0,delay:0,slideExpr:null}})(jQuery)

/* *********************************
        ON LOAD
********************************* */
$(document).ready(function() {
    $('.slideshow_testom').cycle();
});


// S Google Maps //
    var map_1 = null;
    var map_2 = null;
    var map_3 = null;
    var map_4 = null;
    var map_5 = null;
    var geocoder = null;
    function initialize() {
      if (GBrowserIsCompatible()) {
        map_5 = new GMap2(document.getElementById("google_maps_5")); 
        map_4 = new GMap2(document.getElementById("google_maps_4")); 
        map_2 = new GMap2(document.getElementById("google_maps_2"));
        map_3 = new GMap2(document.getElementById("google_maps_3"));

        var address2 = "1490 S. Price Suite 10, Chandler, AZ";
        var address3 = "16155 N. 83rd Avenue Peoria, AZ 85382";
        //var address4 = "16155 N. 83rd Avenue Suite 101 Peoria, AZ 85382";
        var address4 = "6263 N Scottsdale Road, Suite 190, Scottsdale 85250";
        var address5 = "1423 S. Higley Road Suite 103 Bldg. 2, Mesa, AZ 85206";
        geocoder = new GClientGeocoder();
        if (geocoder) {
          geocoder.getLatLng(
          address2,
          function(point2) {
            if (!point2) {
              alert(address2 + " not found");
            } else {
              map_2.setCenter(point2, 13);
              var marker = new GMarker(point2);
              map_2.addOverlay(marker);


            }
          }
          );
          geocoder.getLatLng(
          address3,
          function(point3) {
            if (!point3) {
              alert(address3 + " not found");
            } else {
              map_3.setCenter(point3, 13);
              var marker = new GMarker(point3);
              map_3.addOverlay(marker);


            }
          }
          );
          geocoder.getLatLng(
          address4,
          function(point4) {
            if (!point4) {
              alert(address4 + " not found");
            } else {
              map_4.setCenter(point4, 13);
              var marker = new GMarker(point4);
              map_4.addOverlay(marker);


            }
          }


        );
          geocoder.getLatLng(
          address5,
          function(point5) {
            if (!point5) {
              alert(address5 + " not found");
            } else {
              map_5.setCenter(point5, 13);
              var marker = new GMarker(point5);
              map_5.addOverlay(marker);


            }
          }


        );
      }
      map_1.setUIToDefault();
      map_1.enableRotation();
      map_2.setUIToDefault();
      map_2.enableRotation();
      map_3.setUIToDefault();
      map_3.enableRotation();
      map_4.setUIToDefault();
      map_4.enableRotation();
      map_5.setUIToDefault();
      map_5.enableRotation();
      }
    }

// E Google Maps //
 function sendMail(form_id){
 	document.getElementById(form_id).submit();
 }

var demoWin;
function DoWin(namehtm,wwin,hwin) {
  if ((demoWin != null) && (!demoWin.closed)){demoWin.close()}
  eval("demoWin=window.open('"+namehtm+"', 'demonstrationWin', 'width="+wwin+",height="+hwin+",location=0,top=0')");
  demoWin.focus();
  return false;
}

/* S Print nah */
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

    if(document.location.hash=='#print') setActiveStyleSheet('printview');
/* E Print nah */

/* js valid */
/*

Form validating script

� Ivonin Oleg

*/


function validate_class_reg_title(){

  var err='';
  if (document.getElementById("name").value == ""){
    err = err + '<li>Name - required to be filled</li>';
  }

  if(err==""){
    return true;
  }
  else{
  	err = '<ul>'+err+'</ul>';
  	document.getElementById("fill_form").innerHTML = err;
    self.location.href='#fill_form';
    return false;
  }
}

/* \js valid */

