// JavaScript Document
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/********************** News Details *************************/

 function shownewsDetails(newsid){	
	$("#newsDetails").html("<div width=\"100%\" align=\"center\" id=\"loading\" style=\"padding-top:100px;\"><img src=\"images/ajax-loader.gif\" alt=\"loading\" /></div>");
	$(".newsListing").removeClass("selected");
	$("#news"+newsid).addClass("selected");
	$("#newsDetails").load("fashiondetails.php?newsid=" + newsid,function(){$('#loading').remove();});
 }
 
  function showstorenewsDetails(newsid){	
	$("#newsDetails").html("<div width=\"100%\" align=\"center\" id=\"loading\" style=\"padding-top:100px;\"><img src=\"images/ajax-loader.gif\" alt=\"loading\" /></div>");
	$(".newsListing").removeClass("selected");
	$("#news"+newsid).addClass("selected");
	$("#newsDetails").load("storenewsdetails.php?newsid=" + newsid,function(){$('#loading').remove();});
 }
/********************** Product Details *************************/
 function changepage(brandid,typeid,page)
 {	
	$("#ulProductsLising").html("<div id=\"loading\" width=\"100%\" align=\"center\" style=\"padding-top:100px;\"><img src=\"images/ajax-loader.gif\" alt=\"loading\" /></div>");
	$("#ulProductsLising").load("productslisting.php?type="+typeid+"&brand="+brandid+"&page="+page,function(){$('#loading').remove();});

 }
 function showproducts(brandid,typeid)
 {
	//	  document.location.href="products.php?ptype="+typeid+"&brandid="+brandid;
	if(typeid==1)
	{
		document.location.href="products-spectacles-" + brandid;
	}
	else
	{
		document.location.href="products-sunglasses-" + brandid;
	}

 }
 
 /********************** Lenses Details *************************/
 function showlenses(brandid,typeid,categoryid){	
		$("#ulLensesListing").html("<div id=\"loading\" width=\"100%\" align=\"center\" style=\"padding-top:100px;\"><img src=\"images/ajax-loader.gif\" alt=\"loading\" /></div>");
		$("#ulLensesListing").load("lenseslisting.php?type="+typeid+"&brand="+brandid+"&category="+categoryid,function(){$('#loading').remove();});
 }
 
 function showLensesDetails(lenseid)
 {	
	
		$("#lensesdetails").html("<div id=\"loading\" width=\"100%\" align=\"center\" style=\"padding-top:100px;\"><img src=\"images/ajax-loader.gif\" alt=\"loading\" /></div>");
		if(lenseid === undefined)
		{	}
		else
		{
		$("#lensesdetails").load("lensedetails.php?lenseid=" + lenseid,function(){$('#loading').remove();});	
		}
 }
 
function showCarousel(){
	$('#content-section').jScrollPane({showArrows:true});
	//alert('loaded');
}
 function showLensesFaq()
{	
	$("#ulLensesListing").html("");
	$("#lensesdetails").load("lensesFAQ.php", function(){
		setTimeout(function(){
			$('#content-section').jScrollPane({showArrows:true}).data().jsp.scrollToElement('#linkscrollto', 'true');
		}, 1000)
		//$('#content-section').jScrollPane({showArrows:true});
	});
}
 function showLensesFaqXML()
{	
	$("#ulLensesListing").html("");
	$("#lensesdetails").load("lensesFAQ.php"
	, function(){
	
		$('#content-section').jScrollPane({showArrows:true});
	});		//$('#content-section').jScrollPane({showArrows:true});

}

/*********Sending Email****************************************/
function sendmail(variablelist,formholderid)
{
	
		$("#"+formholderid+" form").hide();
		$("#"+formholderid).append("<div id=\"divloading\" width=\"100%\" align=\"center\" style=\"padding-top:100px;\"><img src=\"images/ajax-loader.gif\" alt=\"loading\" /></div>");
		$.post("sendmail.php",variablelist,function(data){
							$("#divloading").remove()
							if(data=="error")
							{
								$("#"+formholderid+" form").show();
  							    $("#"+formholderid).append("There was an error sending the email. Please try again or use the email link under the form.");
							}
							else
							{
								$("#"+formholderid).html("Thank you for contacting us. We will reply as soon as possible")								
							}													
													
													});
}






function IsValidEmail(bla)
{
  var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
  return filter.test(bla);
}

/*************STORE ACTIVITES ****************/
function showStoreActivitites(id)
{
	$(".storeactivities-links .selected").removeClass("selected");
	$("#store"+id).addClass("selected");
	$("#scrollActivites").html("<div width=\"100%\" align=\"center\" style=\" padding-left:30%;padding-top:100px;\"><img src=\"images/ajax-loader.gif\" alt=\"loading\" /></div>");
	$("div#makeMeScrollable").smoothDivScroll("replaceContent", "activities.php?countryid="+id);
//	$("#scrollActivites").load("activities.php?countryid="+id);
//  $("#scrollActivites").smoothDivScroll("recalculateScrollableArea");	
//	$("div#makeMeScrollable").smoothDivScroll("moveToElement", "first");
}

/*************SEARCH****************/
function searchResult(page,limit,keyword)
{
	$("#ulProductsLising").html("<div id=\"loading\" width=\"100%\" align=\"center\" style=\" padding-left:30%;padding-top:100px;\"><img src=\"images/ajax-loader.gif\" alt=\"loading\" /></div>");
	$("#ulProductsLising").load("searchFunction.php?page="+page+"&limit="+limit+"&keyword="+keyword,function(){$('#loading').remove();});	
}

/*************ry****************/
function changegallery(galleryid)
{
	
	$("#verticalCarousel").load("gallerylisting.php?id="+galleryid ,function(){	$('#verticalCarousel').jcarousel({vertical:true});$('#itemlist ul li:first a img').addClass('on');$('#gal_image').attr('src', $('#itemlist ul li:first a').attr("href"));});
	
}



/**********************************************back to top***************************************/
function scrollToTop(elem){
	//$("#toscroll").jScrollPane().data().jsp.scrollToY(0);
	$(elem).jScrollPane({showArrows:true}).data().jsp.scrollToY(0);
/*	$('.jspArrowUp').addClass('jspDisabled')
	$('.jspArrowDown').removeClass('jspDisabled')
*/}


