function isValidate() {
	var email = /^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/;
	var name = /^[a-zA-Z\ \']+$/;
	var urName = document.getElementById('txtUrName');
	var frndName = document.getElementById('txtFrndName');
	var urEmail = document.getElementById('txtUrEmail');
	var frndEmail = document.getElementById('txtFrndEmail');
	var message = document.getElementById('message');
	if (urName.value == '') {
		$('#nmEmpty').show();
		urName.focus();
		return false;
	} else if (!urName.value.match(name)) {
		$('#nmEmpty').hide();
		$('#nmInvalid').show();
		urName.focus();
		return false;
	} else if (urEmail.value == '') {
		$('#nmEmpty').hide();
		$('#nmInvalid').hide();
		$('#urEmailEmpty').show();
		urEmail.focus();
		return false;
	} else if (!urEmail.value.match(email)) {
		$('#urEmailEmpty').hide();
		$('#nmInvalid').hide();
		$('#urEmailInvalid').show();
		urEmail.focus();
		return false;
	} else if (frndName.value == '') {
		$('#urEmailEmpty').hide();
		$('#urEmailInvalid').hide();
		$('#frndNameEmpty').show();
		frndName.focus();
		return false;
	} else if (!frndName.value.match(name)) {
		$('#frndNameEmpty').hide();
		$('#urEmailInvalid').hide();
		$('#frndNameInvalid').show();
		frndName.focus();
		return false;
	} else if (frndEmail.value == '') {
		$('#frndNameEmpty').hide();
		$('#frndNameInvalid').hide();
		$('#frndEmailEmpty').show();
		frndEmail.focus();
		return false;
	} else if (!frndEmail.value.match(email)) {
		$('#frndNameInvalid').hide();
		$('#frndEmailEmpty').hide();
		$('#frndEmailInvalid').show();
		frndEmail.focus();
		return false;
	} else if (message.value == '' || message.value != '') {
		$('#frndEmailInvalid').hide();
	} else {
		return true;
	}
}

function tb_remove() {
	$("#TB_imageOff").unbind("click");
	$("#TB_closeWindowButton").unbind("click");
	$("#TB_window").fadeOut(
			"fast",
			function() {
				$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload")
						.unbind().remove();
			});

	$("#TB_load").remove();
	if (typeof document.body.style.maxHeight == "undefined") {// if IE 6
		$("body", "html").css( {
			height : "auto",
			width : "auto"
		});
		$("html").css("overflow", "");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}

function goTo(pageno) {
	currentPosition = pageno - 1;
	// alert(currentPosition);
	document.getElementById("gotoFlip").value = (currentPosition + 1);
	$('#slideInner').animate( {
		'marginLeft' : slideWidth * (-currentPosition)
	});
	showHideHotSpots();
}

function goprev() {
	if (currentPosition > 0) {
		currentPosition--;
		// alert(currentPosition);
		document.getElementById("gotoFlip").value = (currentPosition + 1);

		$('#slideInner').animate( {
			'marginLeft' : slideWidth * (-currentPosition)
		});
	}
	showHideHotSpots();
}

function gonext(pgno) {
	/* currentPosition = pgno -1; */
	if (currentPosition < (pgno - 1)) {
		currentPosition++;
		// alert(currentPosition);
		document.getElementById("gotoFlip").value = (currentPosition + 1);

		$('#slideInner').animate( {
			'marginLeft' : slideWidth * (-currentPosition)
		});
	}
	showHideHotSpots();
}

function gonexts(pgno) {
	currentPosition = pgno;
	slideWidth = 863;
	/* # */
	var slides = $('.slide');
	var numberOfSlides = slides.length;
	$('#slidesContainer').css('overflow', 'hidden');
	slides.wrapAll('<div id="slideInner"></div>').css( {
		'float' : 'left',
		'width' : slideWidth
	});
	$('#slideInner').css('width', slideWidth * numberOfSlides);

	$('#slideshow')
			.prepend(
					'<span class="control" id="leftControl">Clicking moves left</span>')
			.append(
					'<span class="control" id="rightControl">Clicking moves right</span>');

	//manageControls(currentPosition);

	var pageno = 32;

	if (currentPosition < (pageno - 1)) {
		currentPosition = ($(this).attr('id') == 'rightControl') ? currentPosition + 1
				: currentPosition - 1;
		document.getElementById("gotoFlip").value = (currentPosition + 1);
		manageControls(currentPosition);
		$('#slideInner').animate( {
			'marginLeft' : slideWidth * (-currentPosition)
		});
	}

	function manageControls(position) {
		// Hide left arrow if position is first slide
		if (position == 0) {
			$('#leftControl').hide()
		} else {
			$('#leftControl').show()
		}
		// Hide right arrow if position is last slide
		if (position == numberOfSlides - 1) {
			$('#rightControl').hide()
		} else {
			$('#rightControl').show()
		}
	//}

	/* # */
	if (currentPosition < (pgno - 1)) {
		currentPosition++;
		// alert(currentPosition);
		document.getElementById("gotoFlip").value = (currentPosition + 1);

		$('#slideInner').animate( {
			'marginLeft' : slideWidth * (-currentPosition)
		});
	}
	showHideHotSpots();
}

function gotoFlip(e) {
	if (e.which == '13') {
		var gotoFlip = document.getElementById("gotoFlip");
		var FlipValue = (gotoFlip.value) - 1;
		currentPosition = FlipValue;

		$('#slideInner').animate( {
			'marginLeft' : slideWidth * (-currentPosition)
		});
		showHideHotSpots();
		return true;
	}
}

function printSelected() {

	var asdf = "<html><body onload='javascript: window.print();'><form id='print_doc'>";

	var cnt = $("#hiddenresultp input[type=checkbox]:checked").length;

	// alert(cnt+"print Selected");

	$("#hiddenresultp input[type=checkbox]:checked").each(function() {

		var value = $(this).val();

		asdf = asdf + '<img src=large/' + value + '.jpg />';

	});

	asdf = asdf + "</form></body></html>";

	document.write(asdf);

	document.close();

}

function printAll() {

	var asdf = "<html><body onload='javascript: window.print();'><form id='print_doc'>";

	var cnt = $("#hiddenresultp input[type=checkbox]").length;

	// alert(cnt+"print All");

	$("#hiddenresultp input[type=checkbox]").each(function() {

		var value = $(this).val();

		asdf = asdf + '<img src=large/' + value + '.jpg />';

	});

	asdf = asdf + "</form></body></html>";

	document.write(asdf);

	document.close();

}
function showHideHotSpots() {
	var pagno = $("#pag_nos").val();
	var a, b, count, hotspots, qwe_a, qwe_b, com, emm, wl, pal, pvl, gtp, dow, these = 0;
	b = $("#gotoFlip").val();
	count = $("#counts").val();
	$("#em").hide();
	$("#com").hide();
	$("#wl").hide();
	$("#pal").hide();
	$("#pvl").hide();
	$("#gtp").hide();
	$("#dow").hide();
	$("#as").hide();
	for (a = 0; a < count; a++) {
		hotspots = $("#hots" + a).val();
		if (b == hotspots) {
			qwe_a = 1;
		} else {
			qwe_b = 1;
		}
	}
	if (qwe_a == 1) {
		for (a = 1; a < count + 1; a++) {
			$("#pvl_" + b).hide();
			$("#pal_" + b).hide();
			emm = $("#ems" + b + "_" + a).val();
			if (emm == b) {
				these = "emm";// alert("ems");
				$("#em").show();
			}
			com = $("#com" + b + "_" + a).val();
			if (emm == b) {
				these = "com";// alert("ems");
				$("#com").show();
			}
			wl = $("#wl" + b + "_" + a).val();
			if (wl == b) {
				these = these + "wl";// alert("wl");
				$("#wl").show();
			}
			pal = $("#pal" + b + "_" + a).val();// alert(pal);
			if (pal == b) {
				these = these + "pal";
				$("#pal").show();
				$("#asds")
						.html(
								"<img src='../images/audio.png' width='21<?= $nowBTWidth ?>px' height='21<?= $nowBTHeight ?>px' id='asd'/>");
			}
			pvl = $("#pvls" + b + "_" + a).val();// alert(pvl);
			if (emm == b) {
				these = these + "emm";
				$("#pvl").show();
				$("#asp")
						.html(
								"<img src='../images/video.png' width='21<?= $nowBTWidth ?>px' height='21<?= $nowBTHeight ?>px' id='as'/>");
			}
			gtp = $("#gtp" + b + "_" + a).val();
			if (emm == b) {
				these = these + "gtp";// alert("gtp");
				$("#gtp").show();
			}
			dow = $("#dow" + b + "_" + a).val();
			if (dow == b) {
				these = these + "dow";// alert("dow");
				$("#dow").show();
			}
		}
		// alert("Yes-"+these);
	} else if (qwe_b == 1) {// alert("No");
		$("#em").hide();
		$("#com").hide();
		$("#wl").hide();
		$("#pal").hide();
		$("#pvl").hide();
		$("#gtp").hide();
		$("#dow").hide();
		$("#asp").html("");
		$("#asds").html("");
	}
}