
$(document).ready(function () {
	window_height = $(window).height(); 
	window_width = $(window).width(); 
	
	$("#leftmain").height(window_height);
	$("#rightback").height(window_height);
	
	
	leftmainwidth =  $("#leftmain").width();
	rightmainwidth = $("#rightback").width();
	
	//documentwidth = $(document).width(); 
	//alert (documentwidth);
	$("#container2").offset({left:leftmainwidth});

	
	
	$("#scrolldiv").height(window_height -  270 - 200);

	//$("#container2").width(rightmainwidth);
	
	
	//if ( dw_scrollObj.isSupported() ) {
    //dw_Util.writeStyleSheet('css/scroll.css');
    //dw_Event.add( window, 'load', init_dw_Scroll);

	//}
	
	switch_gallery(current_gallery);
	
	
	$("#container1").fadeIn(2000);
	$("#container2").fadeIn(2000);
	$("#container3").fadeIn(2000);
	$("#footer").width($(document).width());
	
$("#sendmail").click(function(){
		var valid = '';
		var isr = ' is required.';
		var name = $("#name").val();
		var mail = $("#mail").val();
		var subject = $("#subject").val();
		var text = $("#text").val();
		if (name.length<1) {
			valid += '<br />Name'+isr;
		}
		if (!mail.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
			valid += '<br />A valid Email'+isr;
		}
		if (subject.length<1) {
			valid += '<br />Subject'+isr;
		}
		if (text.length<1) {
			valid += '<br />Text'+isr;
		}
		if (valid!='') {
			$("#response").fadeIn("slow");
			$("#response").html("Error:"+valid);
		}
		else {
			var datastr ='name=' + name + '&mail=' + mail + '&subject=' + subject + '&text=' + text;
			$("#response").css("display", "block");
			$("#response").html("Sending message .... ");
			$("#response").fadeIn("slow");
			setTimeout("send('"+datastr+"')",2000);
		}
		return false;
	});

}
)

$(window).resize(function() {
	window_height = $(window).height(); 
	window_width = $(window).width(); 
	
	$("#leftmain").height(window_height);
	$("#rightback").height(window_height);
	
	
	leftmainwidth =  $("#leftmain").width();
	rightmainwidth = $("#rightback").width();
	
	//documentwidth = $(document).width(); 
	//alert (documentwidth);
	$("#container2").offset({left:leftmainwidth});

	
	
	$("#scrolldiv").height(window_height -  270 - 200);

	//$("#container2").width(rightmainwidth);

	$("#footer").width($(document).width());


});


function init_dw_Scroll() {
    var wndo = new dw_scrollObj('scrolldiv', 'innerscroll');

	wndo.setUpScrollControls('menu');
	wndo.setUpScrollControls('scrollup');
	wndo.setUpScrollControls('scrolldown');
	
	
	var wndo1 = new dw_scrollObj('wn', 'lyr1', 't1', 'galleryrow');
    wndo1.setUpScrollControls('galleryLinks');
}





/*
var oldgallery = "#gallery1";
function switch_gallery(gallery) {
	$(oldgallery).hide();
	$(gallery).show();
	oldgallery = gallery;	
}
*/

function spotlight(galleryname, imageid) {
	$("#rightback").hide();
	$("#image_loader").show();
	$("#gallery_spotlight").hide();
	$("#image_large").hide();	
	//window.scroll(100, 0);

		$.ajax({
		type: "GET",
		url: galleryname + ".xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('image[id='+imageid +']').each(function(){
				//$("#image_large").empty().html('<img src="images/ajax-loader.gif" />');
				
				var imagefronturl = $(this).find('imagefronturl').text();
				var imagesideurl = $(this).find('imagesideurl').text();
				var model = $(this).find('model').text();
				var brief = $(this).find('brief').text();
				var long = $(this).find('long').text();
				//var theImage = new Image();
				//theImage.src = imagefronturl;
				$("#image_model").html('' + brief);				
				//$("#image_large").html('<img id=\'imgLoad\' src=\'\' border=\'0\'></a>');				
				//$('#image_large').empty();$('#image_large').append(theImage);
				$('#imgLoad').attr('src',imagefronturl);
				$('#imgLoad').hide();
				$('#imgLoad').load(function() {$('#imgLoad').show();$("#image_loader").hide();	});


				$("#image_description").html(long);
				//alert(model);
				window.scrollBy(-500,00); // horizontal and vertical scroll increments
				$("#image_large").show();
				$("#gallery_spotlight").show();
				
    		});
		}
	});
	

	return false;
	
}


function send(datastr){
	$.ajax({	
		type: "POST",
		url: "sendmail.asp",
		data: datastr,
		cache: false,
		success: function(html){
		$("#response").fadeIn("slow");
		$("#response").html(html);
		setTimeout('$("#response").fadeOut("slow")',4000);
	}
	});
}

