var isAddOverlay=false;
var rootFolder="/";
//var rootFolder="/sedona/";
var $url="http://"+document.domain+rootFolder;
  $(function(){
     
	  var ar=new Array("newMap");
		makeLink(ar,"images/","newMap");
		$('body').append('<a id="photoGalleryBox"><\/a>');
       // $('#movBox').prettyPhoto();
        
;
        
        
        var cName = $("#cName"),
			rpstName = $("#rpstName"),
            cAddress = $("#cAddress"),
            cTel = $("#cTel"),
            cEmail = $("#cEmail"),
            clName = $("#clName"),
            clNation = $("#clNation"),
            clInterest = $("#clInterest"),			
            allFields = $([]).add(cName).add(rpstName).add(cAddress).add(cTel).add(cEmail).add(clName).add(clNation).add(clInterest),
			tips = $("#validateTips");

		function updateTips(t) {
			tips.text(t).effect("highlight",{},1500);
		}

		function checkLength(o,n,min,max) {

			if ( o.val().length > max || o.val().length < min ) {
				o.addClass('ui-state-error');
				updateTips("Length of " + n + " must be between "+min+" and "+max+".");
				return false;
			} else {
				return true;
			}

		}

		function checkRegexp(o,regexp,n) {

			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass('ui-state-error');
				updateTips(n);
				return false;
			} else {
				return true;
			}

		}

          
				// Dialog			
				$("#dialog").dialog({
			bgiframe: true,
			autoOpen: false,
			height: 700,
            width:500,
			modal: true,
			buttons: {
				'Submit': function() {
					var bValid = true;
					allFields.removeClass('ui-state-error');

					bValid = bValid && checkLength(cName ,"Company Name:",3,80);
                    bValid = bValid && checkLength(rpstName  ,"Representative’s Name",3,80);
                    bValid = bValid && checkLength(cAddress  ,"Company Address",3,150);
                    bValid = bValid && checkLength(cTel  ,"Telephone",6,50);
					bValid = bValid && checkLength(cEmail ,"Email",6,80);
                    bValid = bValid && checkLength(clName ,"Client's Full Name",6,80);
                    bValid = bValid && checkLength(clNation ,"Nationality",2,80);
 
					/*bValid = bValid && checkRegexp(name,/^[a-z]([0-9a-z_])+$/i,"Username may consist of a-z, 0-9, underscores, begin with a letter.");*/
					// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
					bValid = bValid && checkRegexp(cEmail,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. info@yourdomain.com");
				/*	bValid = bValid && checkRegexp(password,/^([0-9a-zA-Z])+$/,"Password field only allow : a-z 0-9");*/
					
					if (bValid) {
						$(this+':button').attr({'disabled':'disabled'}).addClass('ui-state-disabled');
						$('form[name="formSending"]').submit();
					}
				}/*,
				Cancel: function() {
					$(this).dialog('close');
				}*/
			},
			close: function() {
				allFields.val('').removeClass('ui-state-error');
			}
		});
 
//22 feb 2010
var showHouse1=Array("showhouse1-1","showhouse1-2","showhouse1-3","showhouse1-4","showhouse1-5","showhouse1-6","showhouse1-7","showhouse1-8","showhouse1-9","showhouse1-10","showhouse1-11","showhouse1-12","showhouse1-13","showhouse1-14","showhouse1-15","showhouse1-16","showhouse1-17","showhouse1-18","showhouse1-19");
makeLink(showHouse1,"images/photo-gallery/showhouse1/","glShowHouse1");

//var construction=Array("con1","con2","con3","con4","con5","con6","con7","con8");
//makeLink(construction,"images/photo-gallery/construction/","glConstruction");
//-----------

var ploat7=Array("phoenix-ploat7","phoenix-ploat7 (2)","phoenix-ploat7 (3)","phoenix-ploat7 (4)","phoenix-ploat7 (5)","phoenix-ploat7 (6)","phoenix-ploat7 (7)","phoenix-ploat7 (8)","phoenix-ploat7 (9)","phoenix-ploat7 (10)","phoenix-ploat7 (11)","phoenix-ploat7 (12)","phoenix-ploat7 (13)","phoenix-ploat7 (14)","phoenix-ploat7 (15)","phoenix-ploat7 (16)","phoenix-ploat7 (17)","phoenix-ploat7 (18)","phoenix-ploat7 (19)","phoenix-ploat7 (20)","phoenix-ploat7 (21)","phoenix-ploat7 (22)","phoenix-ploat7 (23)","phoenix-ploat7 (24)","phoenix-ploat7 (25)");
makeLink2(ploat7,"images/photo-gallery/plot7/","glPlot7",true);

//---------

//-----------

var ploat4=Array("cimmeron-plot4","cimmeron-plot4 (2)","cimmeron-plot4 (3)","cimmeron-plot4 (4)","cimmeron-plot4 (5)","cimmeron-plot4 (6)","cimmeron-plot4 (7)","cimmeron-plot4 (8)","cimmeron-plot4 (9)","cimmeron-plot4 (10)","cimmeron-plot4 (11)","cimmeron-plot4 (12)","cimmeron-plot4 (13)","cimmeron-plot4 (14)","cimmeron-plot4 (15)","cimmeron-plot4 (16)","cimmeron-plot4 (17)","cimmeron-plot4 (18)","cimmeron-plot4 (19)","cimmeron-plot4 (20)","cimmeron-plot4 (21)","cimmeron-plot4 (22)","cimmeron-plot4 (23)","cimmeron-plot4 (24)","cimmeron-plot4 (25)","cimmeron-plot4 (26)","cimmeron-plot4 (27)");
makeLink2(ploat4,"images/photo-gallery/plot4/","glPlot4",false);

var glent=Array("entrance","entrance (2)","entrance (3)","entrance (4)","entrance (5)","entrance (6)","entrance (7)","entrance (8)","entrance (9)","entrance (10)","entrance (11)","entrance (12)","entrance (13)","entrance (14)","entrance (15)","entrance (16)","entrance (17)","entrance (18)","entrance (19)","entrance (20)","entrance (21)","entrance (22)","entrance (23)","entrance (24)","entrance (26)");
makeLink2(glent,"images/photo-gallery/entrance/","glEntrance",true);

var glConstrction=Array("construction-oct-2010","construction-oct-2010 (2)","construction-oct-2010 (3)","construction-oct-2010 (4)","construction-oct-2010 (5)","construction-oct-2010 (6)","construction-oct-2010 (7)","construction-oct-2010 (8)","construction-oct-2010 (9)","construction-oct-2010 (10)","construction-oct-2010 (11)","construction-oct-2010 (12)","construction-oct-2010 (13)","construction-oct-2010 (14)","construction-oct-2010 (15)","construction-oct-2010 (16)","construction-oct-2010 (17)","construction-oct-2010 (18)","construction-oct-2010 (19)","construction-oct-2010 (20)","construction-oct-2010 (21)","construction-oct-2010 (22)","construction-oct-2010 (23)","construction-oct-2010 (24)","construction-oct-2010 (25)","construction-oct-2010 (26)","construction-oct-2010 (27)","construction-oct-2010 (28)","construction-oct-2010 (29)","construction-oct-2010 (30)","construction-oct-2010 (31)","construction-oct-2010 (32)","construction-oct-2010 (33)","construction-oct-2010 (34)","construction-oct-2010 (35)","construction-oct-2010 (36)","construction-oct-2010 (37)");
makeLink2(glConstrction,"images/photo-gallery/construction-photos/","glConstructionPhotos",true);

/************/


var type2=Array("type2-1","type2-2","type2-3","type2-4","type2-5","type2-6","type2-7","type2-8","type2-9","type2-10","type2-11","type2-12","type2-13","type2-14","type2-15","type2-16");
makeLink(type2,"images/photo-gallery/Cimeron_Type_2/","glType2");


var type3=Array("type3-1","type3-2","type3-3","type3-4","type3-5","type3-6","type3-7","type3-8","type3-9","type3-10","type3-11","type3-12","type3-13","type3-14","type3-15","type3-16");
makeLink(type3,"images/photo-gallery/Cimeron_Type_3/","glType3");



  }); // n doc

function getFlash(w,h,s,t){
    
    return AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width',w,'height',h,'title',t,'src',s,'quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie',s  ,'wmode','transparent' );
    
}


  function boxx(a){
		$('#'+a).click();
	} //
	function makeLink(ar,path,classes){
		var str='';
		for(i=0;i<ar.length;i++){
				str+='<a href="'+path+ar[i]+'.jpg" id="'+ar[i]+'" class="'+classes+'"><'+'/'+'a>';
		} //
		$('body').append(str);
		$(function() {$('.'+classes).lightBox();});
		
	}//
	
	function makeLink2(ar,path,classes,fileTypeUpper){
		var str='';
		fileTypeUpper=fileTypeUpper==true?"JPG":"jpg";
		for(i=0;i<ar.length;i++){
				str+='<a href="'+path+ar[i]+'.'+fileTypeUpper+'" id="'+classes+i+'" class="'+classes+'"><'+'/'+'a>';
		} //
		$('body').append(str);
		$(function() {$('.'+classes).lightBox();});
		
	}//
	
	function vdoBox(){
		$('embed, object, select').css({ 'visibility' : 'hidden' });scrollTo(0,0);
		$('body').append('<div id="vdoDiv"><\/div>');		
		$('#vdoDiv').empty().append('<object width="660" height="525"><param name="movie" value="http:\/\/www.youtube.com\/v\/LDwBPFUxAfA&hl=en&fs=1&border=1"><\/param><param name="allowFullScreen" value="true"><\/param><param name="allowscriptaccess" value="always"><\/param><embed src="http:\/\/www.youtube.com\/v\/LDwBPFUxAfA&hl=en&fs=1&border=1" type="application\/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="660" height="525"><\/embed><\/object><br\/><div id="mapClose"><a href="javascript:closeBox()"><img src="images\/lightbox-btn-close.gif" style="float:right;"\/> <\/a><\/div>').fadeIn().css({'left': $(window).width() / 2 - ($('#vdoDiv').width() / 2), 'visibility' : 'visible','display':'block' });
	//$('#flashVDO').css({ 'visibility' : 'visible' }).show();
    
	} // end function
	
	function closeBox(){
	
    $('#vdoDiv,#panoDiv,#panoOverlay').fadeOut('slow',function(){
	$('embed, object, select').css({ 'visibility' : 'visible' });
	
    });
    
} //end func

function boxMe(f){
   $('#'+f).click();
} //end func
function box2Me(f){
   $('#photoGalleryBox').attr({'href':f}).lightBox().click();
} //end func
function box2Me2(i,prefix){
   $('#'+prefix+i).click();
} //end func
function registForm(){
    $("#dialog").dialog('open');
} //end func
function movMe(f){
    // $('#movBox').attr('href',f).click();
    var ff='images/panoramic/'+f;
    $('embed, object, select').css({ 'visibility' : 'hidden' });scrollTo(0,0);
		$('body').append('<div id="panoOverlay"><\/div><div id="panoDiv"><\/div>');		
		$('#panoDiv').empty().append('<object width="' +($(window).width()-50)+'" height="'+($(window).height()-100)+'"><param name="movie" value="' + $url + ff+'"><\/param><param name="allowFullScreen" value="true"><\/param><param name="allowscriptaccess" value="always"><\/param><embed src="'+ $url + ff+'" type="application\/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+($(window).width()-50)+'" height="'+($(window).height()-100)+'"><\/embed><\/object><br\/><br\/><br\/><br\/><div id="mapClose"><p class="boxDesc">Click and drag to move - [ SHIFT ] Zoom in - [ Ctrl ] Zoom out - [ Scroll mouse wheel ] - Zoom in and out<\/p><a href="javascript:closeBox()"><img src="images\/lightbox-btn-close.gif" style="float:right;padding:0 30px 0 0;"\/> <\/a><\/div>').fadeIn().css({'left': '0', 'visibility' : 'visible','display':'block','z-inex':'301' ,'position':'absolute','top':'0','width':$(window).width()-20,'height':$(window).height()-20});
        
       $('#panoOverlay').css({'left':'0','width': $(window).width()+10,'position':'absolute','top':'0px','height':$(window).height()+10 ,'background':'#000','z-inex':'300','opacity':'.8'}).fadeIn();
       
       $(window).resize(function(){
         $('#panoOverlay').css({'width': $(window).width(),'height':$(window).height() });
         $('#panoDiv').css({'left': $(window).width() / 2 - ($('#panoDiv').width() / 2)});
        });

}

