function saveSignupForm()
{	 
      if(trimEmptySpace(document.getElementById("customerEmail").value)==""){
	       alert("Please enter your Email address.");
	       document.getElementById("customerEmail").focus();
	       return false;
	  }
	  if(!isValidEmail(document.getElementById("customerEmail"))){
	       return false;
	  }
	
	var userEmail = document.getElementById("customerEmail").value;
	$.post(sitePath+"savesignupdetails.htm",
	{	
		userEmail:userEmail
	},
	function(data)
	{
		//alert(data);
		eval(data);
		var status = obj.successMsg;
		alert(status);
		document.getElementById("customerEmail").value = "";				
	},
	"html");
}

function trimEmptySpace(str)
{
    if(!str || typeof str != 'string'){
    	str="";
    	return str;
    }
    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}

function isValidEmail(obj)
{	
	str = obj.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (!filter.test(str))
	{
		alert("Please enter a valid E-mail Id");
		obj.focus();
		return false;
	}
	return true;
}

var flag = "img1";
/*
$(
		function()
		{
			var mn = $(".mn-level1 > li > div");
			if(mn.length > 0)
			{
				$(".mn-level1 > li > div").hide();
				$(".mn-level1 > li > a").click(function(){
					var indx = $(".mn-level1 > li > a").index(this);
					$(".mn-level1 > li > div").slideUp("slow");
					$(".mn-level1 > li").css({'backgroundImage': 'url('+ sitePath + 'sitecontent/images/buttons/expand.gif)','backgroundRepeat': 'no-repeat','backgroundPosition': '0px 4px'});
					var status = $(".mn-level1 > li > div").eq(indx).css("display");
					$(".mn-level1 > li > a").css({'color': '#837072'});
					if(status=='none')
					{
						$(".mn-level1 > li > div").eq(indx).slideDown("slow");
						$(".mn-level1 > li > a").eq(indx).css({'color': '#501d30'});
						$(".mn-level1 > li").eq(indx).css({'backgroundImage': 'url('+ sitePath + 'sitecontent/images/buttons/collapse.gif)','backgroundRepeat': 'no-repeat','backgroundPosition': '0px 5px'});
					}
					else if (status=='block')
					{
						$(".mn-level1 > li > div").eq(indx).slideUp("slow");
					}
					else
					{
						$(".mn-level1 > li > a").eq(indx).css({'color': '#501d30'});
					}
				});
				
			}
	}	
);

*/

function show_hide_vmenu(id)
{
	var indx = id-1;
	$(".mn-level1 > li > div").slideUp("slow");
	$(".mn-level1 > li").css({'backgroundImage': 'url('+ sitePath + 'sitecontent/images/buttons/expand.gif)','backgroundRepeat': 'no-repeat','backgroundPosition': '0px 4px'});
	var status = $(".mn-level1 > li > div").eq(indx).css("display");
	$(".mn-level1 > li > a").css({'color': '#837072'});
	if(status=='none')
	{
		$(".mn-level1 > li > div").eq(indx).slideDown("slow");
		$(".mn-level1 > li > a").eq(indx).css({'color': '#501d30'});
		$(".mn-level1 > li").eq(indx).css({'backgroundImage': 'url('+ sitePath + 'sitecontent/images/buttons/collapse.gif)','backgroundRepeat': 'no-repeat','backgroundPosition': '0px 5px'});
	}
	else if (status=='block')
	{
		$(".mn-level1 > li > div").eq(indx).slideUp("slow");
	}
	else
	{
		$(".mn-level1 > li > a").eq(indx).css({'color': '#501d30'});
	}
}

function show_hide_rightmenu(id)
{
	var indx = id-1;
	$(".mn-level2 > li > div").slideUp("slow");
	$(".mn-level2 > li").css({'backgroundImage': 'url('+ sitePath + 'sitecontent/images/buttons/expand.gif)','backgroundRepeat': 'no-repeat','backgroundPosition': '0px 4px'});
	var status = $(".mn-level2 > li > div").eq(indx).css("display");
	$(".mn-level2 > li > a").css({'color': '#837072'});
	if(status=='none')
	{
		$(".mn-level2 > li > div").eq(indx).slideDown("slow");
		$(".mn-level2 > li > a").eq(indx).css({'color': '#501d30'});
		$(".mn-level2 > li").eq(indx).css({'backgroundImage': 'url('+ sitePath + 'sitecontent/images/buttons/collapse.gif)','backgroundRepeat': 'no-repeat','backgroundPosition': '0px 5px'});
	}
	else if (status=='block')
	{
		$(".mn-level2 > li > div").eq(indx).slideUp("slow");
	}
	else
	{
		$(".mn-level2 > li > a").eq(indx).css({'color': '#501d30'});
	}
}

function controlTabs(noOfTabs, curTab, className)
{
	var obj, obj1 = null;
		for(i=1;i<=noOfTabs;i++)
	{
		obj	=	document.getElementById("tab_"+i);
		obj.className	=	'tab-off_rev';
		obj1	=	document.getElementById("p_"+i);
		obj1.style.display = 'none';
	}
	obj		=	document.getElementById("tab_"+curTab);
	obj.className	=	className;
	obj1	=	document.getElementById("p_"+curTab);
	obj1.style.display = 'block';
}


var count = 0;
$(function(){
	var w_mid = $(".mid").width();
	var w_lst = $("#lst > table").width();
	var w_li = $("#lst > table tr td:first").width();
	w_li = w_li * 3+12;
	$(".last > a").click(function (){
		MoveFront(( w_lst - w_li ),w_li);
	});
	$(".first > a").mousedown(function (){
		MoveBack( w_li);
	});
	
	$("#lst > table tr td > a").click(function (){
		var indx = $("#lst > table tr td > a").index(this);
		flag = "img"+(indx+1);
		
		var desc = $("#lst > table tr td > a").eq(indx).attr("title");
		var img_name = $("#lst > table tr td > a").eq(indx).attr("rel");
		var mid_img_path = sitePath + "imagelibraryupload/productimageupload/productimage/230X230_"+img_name;
		var zoom_img_path = sitePath + "imagelibraryupload/productimageupload/productimage/"+img_name;
		//$("#demo_pro > a").attr({href:zoom_img_path});
		$("#demo_pro > a > img").attr({src:mid_img_path});
		//$("#img_desc").text(desc);
		//alert("mid_img_path: "+ mid_img_path);
		//zoom_load();
	});
})
function show_thickboxImage()
{
	$("#"+flag).click();
	return false;
}
function MoveFront(t,w)
{
	if(t < 0)
	{
		t=0;
	}
	count = count + w;
	if (count <= t)
	{
		$("#lst > table").animate( { marginLeft:"-"+count+"px"}, 1000 );
	}
	else
	{
		count = t;
		$("#lst >table").animate( { marginLeft:"-"+count+"px"}, 1000 );
	}
}
function MoveBack(w)
{
	count = count - w;
	if (count >= 1)
	{
		$("#lst >table").animate( { marginLeft:"-"+count+"px"}, 1000 );
	}
	else
	{
		count = 0;
		$("#lst > table").animate( { marginLeft:"-"+count+"px"}, 1000 );
	}
}

$(document).ready(function(){

	$(".accordion h3:first").addClass("active");
	//$(".accordion div:not(:first)").hide();

	$(".accordion h3").click(function(){

		$(this).next("div").slideToggle("slow").siblings("div:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");

	});
	$('#bookmarks').hide();
	
	scrollBasketDiv();
});

function scrollBasketDiv()
{
	var anc = $('.click');	
	//alert("anc:" + anc);
	if(anc.length > 0)
	{
		
    	var offset = anc.offset();
    	var divid = $('.content1');
    	divid.css({top:offset.top,left:offset.left-84});
    	$(".click").mouseover(function (){
    		divid.css({top:offset.top,left:offset.left-84});
    		$(".content1").slideDown("slow");    		
    		//$(".click").hide();
    		//$(".click").css("height","25px");
    	});
    
		$("div.content1").bind("mouseleave",function(){
			$(".content1").slideUp("slow");
			//$(".click").show();
		});
		
	}	
}

jQuery.fn.center = function () {
	this.css("position","absolute");
	this.css("top", $(window).scrollTop() + "px");
	//this.css("left", "710px");
	//this.css("margin-top", "8px");
	//this.css("float", "right");
	return this;
}

function scrollBasketDown(){
	
	$(".content1").center();
	$(".content1").slideDown("slow");
	setTimeout("scrollBasketUp()",5000);	
}
function scrollBasketUp(){
	$(".content1").slideUp("slow");
}
function addToBasktDivHide(productCode){
	$("#addbskt > div > a").addClass("add-basket3");
	$("#"+productCode).hide();
}
function addToBasktDivShow(productCode){	
	
	$("#addbskt > div > a").removeClass("add-basket3");
	$("#addbskt > div > a").addClass("add-basket1");
	$("#"+productCode).show();
	
	//alert($("#addbskt > div > a"));
	var viewBsktDiv = "#viewbskt";	
	var viewBsktStr = "<div class='flft' style='margin-left:23px;'>"+
					  "<a href='"+sitePath+"basket.htm' class='bsk-txtbx1' ></a>"+
					  "</div>";
	$(viewBsktDiv).html(viewBsktStr);
	//alert($(viewBsktDiv));
}

function basketboxwrite(){	
	$.ajax({
	  url: sitePath+"basketbox.htm?"+new Date().valueOf(),
	  success: function(data){
		  $('#basketItemMessage').html(data);
	  }
	});
}

var previd = "";
function showhideDiv(id,ancpos)
{
	$(".cc-details").css({visibility:'hidden'});
	if(previd!="")
		$('#'+previd).hide();
	previd = id;
	var anc = $('#'+ancpos);
	var offset = anc.offset();
	var divid = $('#'+id);
	divid.css({position:"absolute",width:"auto",padding:"0",color:"#000",border:"1px solid #B06794",left:offset.left-600 ,top:offset.top-0});
	divid.show();
}
function closeDiv(id)
{
	$(".cc-details").css({visibility:'visible'});
	var divid = $('#'+id);
	divid.hide();
}


$(function (){
	var indx=-1;
	var msg="";
	// Tool tips - message
	$(".tipmsg").hover(function(e) {
		indx = $(".tipmsg").index(this);
		msg = $(".tipmsg").eq(indx).attr("rel");
		$('.tips > p').text("");
		$('.tips > p').append(msg);
		$('.tips').css({top:e.pageY + 10, left:e.pageX });
		$('.tips').show();
	}, function() {
		$('.tips').hide();
	});
	$(".tipmsg").mousemove(function(e) {
		$('.tips').css({top:e.pageY + 10, left:e.pageX });
	});
	// End of Tool tips - message


	// Tool tips - Image
	$(".TipsImg").hover(function(e) {
		indx = $(".TipsImg").index(this);
		msg = $(".TipsImg").eq(indx).attr("rel");
		$('.tipsImg').text("");
		$('.tipsImg').append('<img src="'+msg+'" alt="" />');
		$('.tipsImg').css({top:e.pageY - 0, left:e.pageX + 18});
		$('.tipsImg').show();
	}, function() {
		$('.tipsImg').hide();
	});
	$(".TipsImg").mousemove(function(e) {
		$('.tipsImg').css({top:e.pageY - 0, left:e.pageX + 18});
	});
	// End of - Tool tips - Image
})

// Book marks
function showBookmarks()
{
	var obj = $(".bookmark");
	var offset = obj.offset();
	$('#bookmarks').css({top:(offset.top+25), left:(offset.left-132)});
	$('#bookmarks').show();
}
function hideBookmarks()
{
	$('#bookmarks').hide();
}


function socialBookmark(str) {
	if (str == 'Delicious') {
		var URL = "http://del.icio.us/post?url=" + window.location.href + "&title=" + document.title;
		window.open(URL, str, 'toolbar=no,width=800,height=450,resizable=yes,scrollbars=yes');
	}
	if (str == 'Digg') {
		var URL = "http://digg.com/submit?phase=2&url=" + window.location.href + "&title=" + +encodeURIComponent(document.title);
		window.open(URL, str, 'toolbar=no,width=800,height=450,resizable=yes,scrollbars=yes');
		var URL = "http://digg.com/remote-submit?phase=2&url=" + window.location.href + "&title=" + document.title;
	}
	if (str == 'reddit') {
		var URL = "http://reddit.com/submit?url=" + window.location.href + "&title=" + document.title;
		window.open(URL, str, 'toolbar=no,width=800,height=450,resizable=yes,scrollbars=yes');
	}
	if (str == 'Facebook') {
		var URL = "http://www.facebook.com/sharer.php?u=" + window.location.href;
		window.open(URL, str, 'toolbar=no,width=800,height=450,resizable=yes,scrollbars=yes');
	}
	if (str == 'StumbleUpon') {
		var URL = "http://www.stumbleupon.com/submit?url=" + window.location.href + "&title=" + document.title;
		window.open(URL, str, 'toolbar=no,width=800,height=450,resizable=yes,scrollbars=yes');
	}
	return false;
}

function createBookmarkLink()
{
	var title = "Graduate Record Examination"; var url = window.location.href;
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
	window.external.AddFavorite( url, title);
	}else if(window.opera && window.print) { // Opera Hotlist
	return true;
	}
}
// End of Book marks

function preLoader()
{
	$.preloadCssImages();
}
function fnSearch(){
	document.frmSearch.action= sitePath + "search.htm";
	document.frmSearch.submit();
}


function showTips(tooltips,w,pos,id,msg)
{
	hideAllTips();
	$('#'+tooltips).text(msg);	
	var obj = $("#"+id);
	var offset = obj.offset();
	//alert("offset:" + offset)
	var h = $('.'+tooltips).height();
	$('.'+tooltips).fadeIn();
	if($.browser.msie)
	{
		$('.'+tooltips).css({width:w, top:(offset.top - h/2 + 10), left:offset.left + pos + 12});
	}
	else
	{
		$('.'+tooltips).css({width:w, top:(offset.top - h/2 + 10), left:offset.left + pos});
	}	
}
function hideTips(id)
{
	$('.'+id).hide();
}
function hideAllTips()
{
	$('.tips-left').hide();
	$('.tips-right').hide();
}

/*jQuery(document).ready(function() {
	
	if($("#mycarousel").length > 0)  
	{
	    jQuery('#mycarousel').jcarousel({
	    	wrap: 'circular'
	    });
	}
});*/


