  function getPhotoImage(path)
  {
	$.ajax({
		type:"GET",
		url :"photos_view.php",
		data: path,
		dataType : 'json',
		success: function (data)  {
			htm = '<ul id="vertical-carousel" class="jcarousel-skin-tango">';
			j = 0;
			p = '';
			sz = 0;
			for (i in data) {
				if (j == 0) {
					p = data[i].href;
				}
				htm += '<li><a href="'+data[i].href+'" onclick="return getMainImage(\''+data[i].href+'\')"><img width="115px" height="87px" border="0" src="'+data[i].src+'" /></a></li>';
				j++;
				sz++;
			}
			htm += '</ul>';
			$('#vertical-carousel').closest('div.jcarousel-skin-tango').replaceWith(htm);
			$('#vertical-carousel').jcarousel({vertical: true, scroll: 6, size: sz});
			if (p != '') {
				getMainImage(p);
			}
		}
	});
	  return false;
  }

  function getMainImage(path)
  {
	$.ajax({
		type:"GET",
		url :"photos_view.php",
		data:path,
		dataType : 'json',
		success: function(data) {
			href = '';
			for (i in data) {
				href = data[i].email_href;
				htm = '<a  href="#" id="main_photo_img" style="cursor: default;"><img WIDTH=542 height=450 src="'+data[i].src+'" border="0" class="reflect" style="cursor: default;"/></a>';
			}
			$('#main_photo_img').replaceWith(htm);
			$('#main_photo_img').children('img').load( function () {
				Reflection.add($(this)[0], { height: null, opacity : null});
				n_href = 'email_friend_photo.php?path='+php_urlencode(href);

				$('div.photos-buy-now > a').attr('href', n_href);
				$(".shadow").colorbox({width:"708", height:"640", opacity:"0.0", iframe:true});

			});
		}
	});
	return false;
  }

 var flag = "";
 function getPlayer(i) {
	if (flag != 'i') {
		$("#pos_"+flag).slideUp();
	}
    if ($("#pos_"+i).is(":hidden")) {
		$("#pos_"+i).slideDown("1500");
    } else {
      $("#pos_"+i).slideUp();
    }
	  flag = i;
	  return false;
 }

 function getVideoImage(path)
  {
	  $.ajax({
		type:"GET",
		url :"videos_view.php",
		data: path,
		dataType : 'json',
		success: function (data)  {
			htm = '<ul id="vertical-carousel" class="jcarousel-skin-tango">';
			j = 0;
			p = '';
			sz = 0;
			for (i in data) {
				if (j == 0) {
					p = data[i].href;
				}
				htm += '<li><a href="#" onclick="return getMainVideo(\''+data[i].href+'\')"><img width="115px" height="87px" border="0" src="'+data[i].src+'" /></a></li>';
				j++;
				sz++;
			}
			htm += '</ul>';
			$('#vertical-carousel').closest('div.jcarousel-skin-tango').replaceWith(htm);
			$('#vertical-carousel').jcarousel({vertical: true, scroll: 6, size: sz});
			if (p != '') {
				getMainVideo(p);
			}
		}
	  });
	  return false;
  }
  function getMainVideo(path)
  {
	$.ajax({
		type:"GET",
		url :"videos_view.php",
		data:path,
		dataType : 'json',
		success: function(data) {
			href = '';
			for (i in data) {
				href = data[i].email_href;
				issalebale = data[i].issalebale;
				video_buy_url = data[i].video_buy_url;
				n_htm = '<object width="560" height="440" name="main_big_video" id="main_big_video"><param name="movie" value="'+data[i].src+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed wmode="transparent" src="'+data[i].src+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>';
				buy_string='<a href="#" onclick="window.open(\''+video_buy_url+'\',\'\',\'height=800,width=800,scrollbars=1\');"><img src="images/buythisvideo.png" style="margin-right:290px"/></a>';
			}
			n_href = 'email_friend.php?path='+php_urlencode(href);

			if(issalebale == 1) {
				$('.saleable').html(buy_string);
			} else {
				$('.saleable').html('&nbsp;');
			}
			$('div.video_email > a.shadow').attr('href', n_href);
			$('#main_big_video').html(n_htm);
			/*$('#main_big_video').children('movie').load( function () {
				Reflection.add($(this)[0], { height: null, opacity : null});
				$(".shadow").colorbox({width:"708", height:"640", opacity:"0.0", iframe:true});
			})*/
		}
	});
	return false;
  }

  function php_urlencode (str) {
	str = escape(str);
	return str.replace(/[*+\/@]|%20/g,
	function (s) {
	switch (s) {
	case "*": s = "%2A"; break;
	case "+": s = "%2B"; break;
	case "/": s = "%2F"; break;
	case "@": s = "%40"; break;
	case "%20": s = "+"; break;
	}
	return s;
	}
	);
  }

$(document).ready(function(){
  $("#sub_id").click(function(){
		var contact_name = $("#contact_name").val();
		var contact_email = $("#contact_email").val();
		var contact_state = $("#contact_state").val();
		var contact_msg = $("#contact_msg").val();

	  errors = false;
	  str = "";

	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   if(reg.test(contact_email) == false) {
		  errors = true;
	   }

	   if (contact_msg == "") {
		   errors = true;
	   }

	   if (contact_state == "") {
		   errors = true;
	   }

	   if (contact_name == "") {
		   errors = true;
	   }

	   if (errors) {
			$('#mes_err').html("<span class = 'errorMsg'>Some of the fields are not entered correctly !</span>");
		   return false;
	   } else {
			var datastr ="contact_email=" + contact_email + "&contact_name=" + contact_name + "&contact_state=" + contact_state + "&contact_msg=" + contact_msg;
			send(datastr);
			return false;
	   }

  });
})

$(document).ready(function() {
    /*$('#flash_banner').cycle({
			fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});*/
});

function send(datastr){
	/*alert(datastr);*/
	/*alert(basepath);*/
  $.ajax({
    type: "POST",
    url: basepath+"valid_contact.php",
    data: datastr,
    cache: false,
		/*dataType : 'json',*/
    success: function(html){
			if (html.msg=="Invalid Email"){
				$("#contact_email").val(html.contact_email);
				$("#contact_name").val(html.contact_name);
				$("#contact_state").val(html.contact_state);
				$("#contact_msg").val(html.contact_msg);
				$('#mes_err').html("<span class = 'successMsg'>Invalid Email! </span>");
			} else {
				$("#contact_email").val("");
				$("#contact_name").val("");
				$("#contact_state").val("");
				$("#contact_msg").val("");
				$('#mes_err').html("<span class = 'successMsg'>Your request has been submitted successfully! </span>");
			}
    }
  });
}