String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}


function videoBoxClick(direction) {
	var imageattributes = document.getElementById("videoBoxJSlideContainer").attributes;
	var videoBoxPage = document.getElementById("videoBoxCurrentPage").value;
	var videoBoxTotalPages = document.getElementById("videoBoxTotalPages").value;
	//alert('-->'+videoBoxPage+"-->"+videoBoxTotalPages);
	if(direction == "right") {
		videoBoxPage = (videoBoxPage * 1) + 1;
		if(videoBoxPage > videoBoxTotalPages) {
			videoBoxPage = 1;
		}
		document.getElementById("videoBoxCurrentPage").value = videoBoxPage;
	} else {
		videoBoxPage = (videoBoxPage * 1) - 1;
		if(videoBoxPage == 0) {
			videoBoxPage = videoBoxTotalPages;
		}
		document.getElementById("videoBoxCurrentPage").value = videoBoxPage;
	}
	//now play with the dots
	var count = 1;
	for(count=1;count<=videoBoxTotalPages;count++) {
		document.getElementById("videoBullet"+count).src = "/eng/images/videoBox/bulletInactive.png";
	}
	document.getElementById("videoBullet"+videoBoxPage).src = "/eng/images/videoBox/bulletActive.png";
	//now play with the arrows
	if(videoBoxPage == 1) {
		document.getElementById("videoBoxLeftArrow").src = "/eng/images/videoBox/arrowLeftInactive.png";
	} else {
		document.getElementById("videoBoxLeftArrow").src = "/eng/images/videoBox/arrowLeftActive.png";
	}
	if(videoBoxPage == videoBoxTotalPages) {
		document.getElementById("videoBoxRightArrow").src = "/eng/images/videoBox/arrowRightInactive.png";
	} else {
		document.getElementById("videoBoxRightArrow").src = "/eng/images/videoBox/arrowRightActive.png";
	}
}

function populateVideoBox(title,description,id,pic) {
	document.getElementById('mainVideoTitle').innerHTML = title;
	document.getElementById('videoBoxArticleLink').href = id;
	$("#mainVideoDescription").html(description);
	$("#videoBoxMainPicHolder").attr('src',pic);	
}

function expandMoreStories(cat,subcat,runTimeNumber,excludeArticles) {
	//alert(excludeArticles);
	//alert('cat='+cat+' + subcat='+subcat+' + runtimenum='+runTimeNumber+' + excludeArticles='+excludeArticles);
	if(runTimeNumber>1) {
		document.forms['form'+cat+subcat].submit();
	} else {
		JsHttpRequest.query(
			'/eng/includes/ajaxMoreStories.php',
			{
				'cat':cat,
				'subcat':subcat,
				'runTimeNumber':runTimeNumber,
				'excludeArticles':excludeArticles
			},
			function(result, errors) {
				//alert(result['MoreStories']);
				document.getElementById('container'+cat+subcat).innerHTML += result['MoreStories'];
				document.getElementById('runTimeNum'+cat+subcat).value = result['runTimeNum'];
				if(result['runTimeNum']=2) {
					document.getElementById('excludeArticles'+cat+subcat).value = result['excludeArticles'];
				}
				if ($("#moreStoriesID"+cat+subcat+runTimeNumber).is(":hidden")) {
					$("#moreStoriesID"+cat+subcat+runTimeNumber).slideDown("slow");
				}
			},
			true
		);
		document.getElementById('closeMoreStories'+cat+subcat).style.display = "block";
	}
}

function closeMoreStories(cat,subcat,runTimeNumber) {
	//alert(result['MoreStories']);
	window.location.hash = '#container'+cat+subcat;
	window.scrollBy(0,-80);
	for(divNumber=runTimeNumber;divNumber>0;divNumber--) {
		if ($("#moreStoriesID"+cat+subcat+divNumber).is(":visible")) {
			$("#moreStoriesID"+cat+subcat+divNumber).slideUp("slow");
		}
	}
	document.getElementById('runTimeNum'+cat+subcat).value = 1;
	document.getElementById('closeMoreStories'+cat+subcat).style.display = "none";
}


function loadVideoFromBox(title,description,videoLink) {
	document.getElementById("mainVideoTitle").innerHTML = title;
	document.getElementById("mainVideoDescription").innerHTML = description;
	var videoObject = "<object width=\"245\" height=\"192\"><param name=\"movie\" value=\""+videoLink+"&\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><param name=\"wmode\" value=\"opaque\"></param><embed src=\""+videoLink+"&\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" width=\"245\" height=\"192\"></embed></object>";
	document.getElementById("mainVideoObject").innerHTML = videoObject;
}
function loadBlueBoxAround(value) {
	document.getElementById("smallVideoBox"+value).style.background = "url(/eng/images/videoBox/blueBox.png)";
}
function removeBlueBoxAround(value) {
	document.getElementById("smallVideoBox"+value).style.background = "";
}
setUpWeatherBlogs=function(){
	

			$("#blogs_container").html($("#blogsLenta").html());
		$("#scroll_down_blogs").click(function(){
var cp=Number($('#blogs_container').attr('currentP'));
var tp=Number($('#blogs_container').attr('totalP'));
if((cp+1)<tp)cp++;else cp=0;

$('#blogs_container').animate({top:-330*cp},300);
$('#blogs_container').attr('currentP',cp);

$(this).attr('src',(($(this).attr('src')=='/eng/images/blue_arrow_down.gif')?'/eng/images/blue_arrow_up.gif':'/eng/images/blue_arrow_down.gif'));
});
		$("#scroll_down_blogs2").click(function(){
var cp=Number($('#blogs_container').attr('currentP'));
var tp=Number($('#blogs_container').attr('totalP'));
if((cp+1)<tp)cp++;else cp=0;

$('#blogs_container').animate({top:-270*cp},240);
$('#blogs_container').attr('currentP',cp);
$(this).attr('src',(($(this).attr('src')=='/eng/images/blue_arrow_down.gif' && cp == (tp-1))?'/eng/images/blue_arrow_up.gif':'/eng/images/blue_arrow_down.gif'));
});
		$("#scroll_down_blogsVer2").click(function(){
var cp=Number($('#blogs_container').attr('currentP'));
var tp=Number($('#blogs_container').attr('totalP'));
if((cp+1)<tp)cp++;else cp=0;

$('#blogs_container').animate({top:-249*cp},240);
$('#blogs_container').attr('currentP',cp);
$(this).attr('src',(($(this).attr('src')=='/eng/images/blogs/arrDown.png' && cp == (tp-1))?'/eng/images/blogs/arrUp.png':'/eng/images/blogs/arrDown.png'));

});
		$("#scroll_down_blogs3").click(function(){
var cp=Number($('#blogs_container').attr('currentP'));
var tp=Number($('#blogs_container').attr('totalP'));
if((cp+1)<tp)cp++;else cp=0;

$('#blogs_container').animate({top:-300*cp},294);
$('#blogs_container').attr('currentP',cp);
$(this).attr('src',(($(this).attr('src')=='/eng/images/blue_arrow_down.gif' && cp == (tp-1))?'/eng/images/blue_arrow_up.gif':'/eng/images/blue_arrow_down.gif'));
});

//splash arrow hover
$('#splashNewScrollRight').hover(function () {
		$("#splashNewScrollRight").fadeTo("fast", 0.3);
        this.src = '/eng/images/homePage/splashScrollActiveNT.png';
		$("#splashNewScrollRight").fadeTo("fast", 1);
    }, function () {
        this.src = '/eng/images/homePage/splashScrollNT.png';
    });
$('#splashNewScrollLeft').hover(function () {
		$("#splashNewScrollLeft").fadeTo("fast", 0.3);
        this.src = '/eng/images/homePage/splashScrollActiveLeftNT.png';
		$("#splashNewScrollLeft").fadeTo("fast", 1);
    }, function () {
        this.src = '/eng/images/homePage/splashScrollLeftNT.png';
    });
$('#musicScrollRight').hover(function () {
		$("#musicScrollRight").fadeTo("fast", 0.3);
        this.src = '/eng/images/homePage/splashScrollActiveNT.png';
		$("#musicScrollRight").fadeTo("fast", 1);
    }, function () {
        this.src = '/eng/images/homePage/splashScrollNT.png';
    });
$('#musicScrollLeft').hover(function () {
		$("#musicScrollLeft").fadeTo("fast", 0.3);
        this.src = '/eng/images/homePage/splashScrollActiveLeftNT.png';
		$("#musicScrollLeft").fadeTo("fast", 1);
    }, function () {
        this.src = '/eng/images/homePage/splashScrollLeftNT.png';
    });



$('#sliderScrollRight').hover(function () {
		$("#sliderScrollRight").fadeTo("fast", 0.3);
        this.src = '/eng/images/homePage/splashScrollActiveRightWhite.png';
		$("#sliderScrollRight").fadeTo("fast", 1);
    }, function () {
        this.src = '/eng/images/homePage/splashScrollRightWhite.png';
    });
$('#sliderScrollLeft').hover(function () {
		$("#sliderScrollLeft").fadeTo("fast", 0.3);
        this.src = '/eng/images/homePage/splashScrollActiveLeftWhite.png';
		$("#sliderScrollLeft").fadeTo("fast", 1);
    }, function () {
        this.src = '/eng/images/homePage/splashScrollLeftWhite.png';
    });




$("#splashSmallContainer").html($("#splashSmallLenta").html());
$("#splashSmallContainer2").html($("#splashSmallLenta2").html());
$("#splashBigContainer").html($("#splashBigLenta").html());
$("#musicContainer").html($("#musicLenta").html());
$("#splashNewScrollRight").click(function(){
	
	var cp=Number($('#splashBigContainer').attr('currentP'));
	var tp=Number($('#splashBigContainer').attr('totalP'));
	
	if((cp+1)<tp)cp++;else cp=0;
	//alert('TP:'+tp+' CPRight:'+cp);
	$('#splashSmallContainer').animate({left:-163*cp}, "slow");
	$('#splashSmallContainer2').animate({left:-163*cp}, "slow");
	$('#splashBigContainer').animate({left:-290*cp}, "slow");
	$('#splashBigContainer').attr('currentP',cp);
});
$("#splashNewScrollLeft").click(function(){
	
	var cp=Number($('#splashBigContainer').attr('currentP'));
	var tp=Number($('#splashBigContainer').attr('totalP'));
	//alert('CP before change:'+cp);
	if((cp-1)<0)cp=(tp-1);else cp--;
	//alert('CP after change:'+cp);
	$('#splashSmallContainer').animate({left:-163*cp}, "slow");
	$('#splashSmallContainer2').animate({left:-163*cp}, "slow");
	$('#splashBigContainer').animate({left:-290*cp}, "slow");
	$('#splashBigContainer').attr('currentP',cp);
});

$("#musicScrollRight").click(function(){
	
	var cp=Number($('#musicContainer').attr('currentP'));
	var tp=Number($('#musicContainer').attr('totalP'));
	
	if((cp+1)<tp) {
		cp++;
		document.getElementById('musicCurPage'+cp).style.color = "#868686";
		document.getElementById('musicCurPage'+((cp*1)+1)).style.color = "#2683FC";
	} else {
		cp=0;
		document.getElementById('musicCurPage1').style.color = "#2683FC";
		document.getElementById('musicCurPage6').style.color = "#868686";
	}
	//alert('TP:'+tp+' CPRight:'+cp);
	$('#musicContainer').animate({left:-190*cp}, "slow");
	$('#musicContainer').attr('currentP',cp);
	
});
$("#musicScrollLeft").click(function(){
	
	var cp=Number($('#musicContainer').attr('currentP'));
	var tp=Number($('#musicContainer').attr('totalP'));
	//alert('CP before change:'+cp);
	if((cp-1)<0) {
		cp=(tp-1);
		document.getElementById('musicCurPage6').style.color = "#2683FC";
		document.getElementById('musicCurPage1').style.color = "#868686";
	} else {
		cp--;
		document.getElementById('musicCurPage'+((cp*1)+2)).style.color = "#868686";
		document.getElementById('musicCurPage'+((cp*1)+1)).style.color = "#2683FC";
	}
	//alert('CP after change:'+cp);
	$('#musicContainer').animate({left:-190*cp}, "slow");
	$('#musicContainer').attr('currentP',cp);
});
		
		switchTabs=function(img,src1,src2,map1,map2){
if(img.attr('src')==src1){
img.attr('src',src2);	img.attr('usemap',map2);	
	}else{
img.attr('src',src1);	img.attr('usemap',map1);	
		}

	}
	
$("#blogs_map").click(function(){switchTabs($("#wb_tabs"),'/eng/images/culture/weatherBlogs.gif','/eng/images/culture/weatherBlogs2.gif','#blogs_tab','#weather_tab'); $("#blogs_container").html($("#weatherLenta").html());document.getElementById('scroll_down_blogs3').style.visibility = "hidden";});
$("#weather_map").click(function(){switchTabs($("#wb_tabs"),'/eng/images/culture/weatherBlogs.gif','/eng/images/culture/weatherBlogs2.gif','#blogs_tab','#weather_tab'); $("#blogs_container").html($("#blogsLenta").html());document.getElementById('scroll_down_blogs3').style.visibility = "visible";});
//bottom is blogs, top is weather
//below is mapping and functions for homepage and economics
$("#blogs_map2").click(function(){switchTabs($("#wb_tabs2"),'/eng/images/homePage/weatherBlogs250.gif','/eng/images/homePage/weatherBlogs2502.gif','#blogs_tab2','#weather_tab2'); $("#blogs_container").html($("#weatherLenta").html());document.getElementById('scroll_down_blogs2').style.visibility = "hidden";});
$("#weather_map2").click(function(){switchTabs($("#wb_tabs2"),'/eng/images/homePage/weatherBlogs250.gif','/eng/images/homePage/weatherBlogs2502.gif','#blogs_tab2','#weather_tab2'); $("#blogs_container").html($("#blogsLenta").html());document.getElementById('scroll_down_blogs2').style.visibility = "visible";});
		
/*		switchTabs=function(img,src1,src2,map1,map2){
if(img.attr('src')==src1){
img.attr('src',src2);	img.attr('usemap',map2);	
	}else{
img.attr('src',src1);	img.attr('usemap',map1);	
		}

	}
	
	
$("#read_map").click(function(){switchTabs($("#rated_read_tabs"),'/eng/images/read_tab.gif','/eng/images/rated_tab.gif','#read_tab','#rated_tab'); $("#lenta_container").html($("#mostRatedLenta").html());});
$("#rated_map").click(function(){switchTabs($("#rated_read_tabs"),'/eng/images/read_tab.gif','/eng/images/rated_tab.gif','#read_tab','#rated_tab'); $("#lenta_container").html($("#mostReadLenta").html());});*/

	
	}





setUpMostClickedLatest=function(){
			$("#lenta_container").html($("#mostReadLenta").html());
		$("#scroll_down").click(function(){
var cp=Number($('#lenta_container').attr('currentP'));
var tp=Number($('#lenta_container').attr('totalP'));
if((cp+1)<tp)cp++;else cp=0;

$('#lenta_container').animate({top:-Number($('#lenta_container').parent().css("height").substr(0,3))*cp},300);
$('#lenta_container').attr('currentP',cp);

$(this).attr('src',(($(this).attr('src')=='/eng/images/blogs/arrDown.png' && cp == (tp-1))?'/eng/images/blogs/arrUp.png':'/eng/images/blogs/arrDown.png'));
});
		
		
		switchTabs=function(img,src1,src2,map1,map2){
if(img.attr('src')==src1){
img.attr('src',src2);	img.attr('usemap',map2);	
	}else{
img.attr('src',src1);	img.attr('usemap',map1);	
		}

	}
	
$("#read_map").click(function(){switchTabs($("#rated_read_tabs"),'/eng/images/video/latest_tab.jpg','/eng/images/video/popular_tab.jpg','#read_tab','#rated_tab'); $("#lenta_container").html($("#mostRatedLenta").html());});
$("#rated_map").click(function(){switchTabs($("#rated_read_tabs"),'/eng/images/video/popular_tab.jpg','/eng/images/video/latest_tab.jpg','#rated_tab','#read_tab'); $("#lenta_container").html($("#mostReadLenta").html());});

	}




setUpMostReadViewed=function(){
			$("#lenta_container").html($("#mostReadLenta").html());
		$("#scroll_down").click(function(){
var cp=Number($('#lenta_container').attr('currentP'));
var tp=Number($('#lenta_container').attr('totalP'));
if((cp+1)<tp)cp++;else cp=0;

$('#lenta_container').animate({top:-Number($('#lenta_container').parent().css("height").substr(0,3))*cp},300);
$('#lenta_container').attr('currentP',cp);

$(this).attr('src',(($(this).attr('src')=='/eng/images/blogs/arrDown.png' && cp == (tp-1))?'/eng/images/blogs/arrUp.png':'/eng/images/blogs/arrDown.png'));
});
		
		
		switchTabs=function(img,src1,src2,map1,map2){
if(img.attr('src')==src1){
img.attr('src',src2);	img.attr('usemap',map2);	
	}else{
img.attr('src',src1);	img.attr('usemap',map1);	
		}

	}
	
$("#read_map").click(function(){  switchTabs($("#rated_read_tabs"),'/eng/images/read_viewed_tab.gif','/eng/images/viewed_read_tab.gif','#read_tab','#rated_tab'); $("#lenta_container").html($("#mostRatedLenta").html());});
$("#rated_map").click(function(){ switchTabs($("#rated_read_tabs"),'/eng/images/viewed_read_tab.gif','/eng/images/read_viewed_tab.gif','#rated_tab','#read_tab'); $("#lenta_container").html($("#mostReadLenta").html());});

	}


setUpMostReadRated=function(){
			$("#lenta_container").html($("#mostReadLenta").html());
		$("#scroll_down").click(function(){
var cp=Number($('#lenta_container').attr('currentP'));
var tp=Number($('#lenta_container').attr('totalP'));
if((cp+1)<tp)cp++;else cp=0;

$('#lenta_container').animate({top:-Number($('#lenta_container').parent().css("height").substr(0,3))*cp},300);
$('#lenta_container').attr('currentP',cp);

$(this).attr('src',(($(this).attr('src')=='/eng/images/blogs/arrDown.png' && cp == (tp-1))?'/eng/images/blogs/arrUp.png':'/eng/images/blogs/arrDown.png'));
});
		
		
		switchTabs=function(img,src1,src2,map1,map2){
if(img.attr('src')==src1){
img.attr('src',src2);	img.attr('usemap',map2);	
	}else{
img.attr('src',src1);	img.attr('usemap',map1);	
		}

	}
	
$("#read_map").click(function(){switchTabs($("#rated_read_tabs"),'/eng/images/read_tab.gif','/eng/images/rated_tab.gif','#read_tab','#rated_tab'); $("#lenta_container").html($("#mostRatedLenta").html());});
$("#rated_map").click(function(){switchTabs($("#rated_read_tabs"),'/eng/images/read_tab.gif','/eng/images/rated_tab.gif','#read_tab','#rated_tab'); $("#lenta_container").html($("#mostReadLenta").html());});

$("#read_map2").click(function(){switchTabs($("#rated_read_tabs2"),'/eng/images/read_tab2.gif','/eng/images/rated_tab2.gif','#read_tab2','#rated_tab2'); $("#lenta_container").html($("#mostRatedLenta").html());});
$("#rated_map2").click(function(){switchTabs($("#rated_read_tabs2"),'/eng/images/read_tab2.gif','/eng/images/rated_tab2.gif','#read_tab2','#rated_tab2'); $("#lenta_container").html($("#mostReadLenta").html());});
	}
	

setUpBlogs=function(){
	
	setUpMostReadRated();
	setUpWeatherBlogs();

	
	}



setUpProductsPage=function(){
	//index
	$(".frontColumnSelector").hide();
	$(".frontColumnSelector",$(".frontCheck:checked").parent()).show();
	$(".frontCheck").change(function(){
									 select=$(".frontColumnSelector",$(this).parent());
						cb=$(this);			 
			 if($(this).attr('checked')){select.show(); select.selectedIndex=0;}else { $(':selected',select).removeAttr('selected');$(':first-child',select).attr('selected','selected'); select.hide();
			 $.post("includes/ajaxFuncs.php",{'function':'doHomePositioning','action':'unpost','id':$(this).parent().attr('id')}, function(feedback){$('.post_feedback',cb.parent()).text(feedback);});
			 }
});
	
	$(".frontColumnSelector").click(function(){this.lastSelected=this.selectedIndex;}).change(function(){
											cb=$(this); val=$(':selected',this).val();
											 if(this.selectedIndex==0)this.selectedIndex=this.lastSelected; else $.post("includes/ajaxFuncs.php",{'function':'doHomePositioning','action':'post','id':$(this).parent().attr('id'),'position':$(':selected',this).val()}, function(feedback){	 
																																																																				  if(feedback=='Posted!'){ocb=$(':selected[value='+val+']').parent(); ocb.hide(); $('.post_feedback',ocb.parent()).text(''); $('.post_feedback',cb.parent()).text(feedback); $(".frontCheck",ocb.parent()).removeAttr('checked'); $(".frontCheck",cb.parent()).attr('checked','checked'); cb.show();  }
																																																																				  if(feedback=='Posted for later!')$('.post_feedback',cb.parent()).text(feedback);
																																																																				  
																																																																				  });
																																																																								  
																																																																								  })
	
	//film home page selector (stas)
	$(".frontFilmCheck").change(function(){									 
			 if($(this).attr('checked')) {
				 $.post("includes/ajaxFuncs.php",{'function':'doFilmPositioning','action':'post','id':$(this).parent().attr('id'),'position':1}, function(feedback) {
						$('.post_feedbackFilm'+feedback).text('Posted!');
				});
			 } else {
				 $.post("includes/ajaxFuncs.php",{'function':'doFilmPositioning','action':'post','id':$(this).parent().attr('id'),'position':0}, function(feedback){
						$('.post_feedbackFilm'+feedback).text('Removed!');
				});
			}
});
	//music home page selector (stas)
	$(".frontMusicCheck").change(function(){									 
			 if($(this).attr('checked')) {
				 $.post("includes/ajaxFuncs.php",{'function':'doMusicPositioning','action':'post','id':$(this).parent().attr('id'),'position':1}, function(feedback) {
						$('.post_feedbackMusic'+feedback).text('Posted!');
				});
			 } else {
				 $.post("includes/ajaxFuncs.php",{'function':'doMusicPositioning','action':'post','id':$(this).parent().attr('id'),'position':0}, function(feedback){
						$('.post_feedbackMusic'+feedback).text('Removed!');
				});
			}
});
	//music home page selector (stas)
	$(".frontFoodCheck").change(function(){									 
			 if($(this).attr('checked')) {
				 $.post("includes/ajaxFuncs.php",{'function':'doFoodPositioning','action':'post','id':$(this).parent().attr('id'),'position':1}, function(feedback) {
						$('.post_feedbackFood'+feedback).text('Posted!');
				});
			 } else {
				 $.post("includes/ajaxFuncs.php",{'function':'doFoodPositioning','action':'post','id':$(this).parent().attr('id'),'position':0}, function(feedback){
						$('.post_feedbackFood'+feedback).text('Removed!');
				});
			}
});
	//culture index
	$(".frontCultureSelector").hide();
	$(".frontCultureSelector",$(".frontCultureCheck:checked").parent()).show();
	
	$(".frontCultureCheck").change(function(){
									 select=$(".frontCultureSelector",$(this).parent());
									 
			 if($(this).attr('checked')){
				 select.show();
				 select.selectedIndex=0;
			 } else {
				 $(':selected',select).removeAttr('selected');
				 $(':first-child',select).attr('selected','selected');
				 select.hide();
				 $.post("includes/ajaxFuncs.php",{'function':'doCulturePositioning','action':'post','id':$(this).parent().attr('id'),'position':0}, function(feedback){	 if(feedback=='Removed!'){ocb=$(':selected[value='+val+']').parent(); /*ocb.hide(); */$('.post_feedback',ocb.parent()).text(''); $('.post_feedback',cb.parent()).text(feedback); $(".frontCheck",ocb.parent()).removeAttr('checked'); $(".frontCheck",cb.parent()).attr('checked','checked'); cb.show();  }																																																																						 });
				 
			 }
});
	
	$(".frontCultureSelector").click(function(){this.lastSelected=this.selectedIndex;}).change(function(){
											cb=$(this); val=$(':selected',this).val();
											 if(this.selectedIndex==0)this.selectedIndex=this.lastSelected; else $.post("includes/ajaxFuncs.php",{'function':'doCulturePositioning','action':'post','id':$(this).parent().attr('id'),'position':$(':selected',this).val()}, function(feedback){	 if(feedback=='Posted!'){ocb=$(':selected[value='+val+']').parent(); /*ocb.hide(); */$('.post_feedback',ocb.parent()).text(''); $('.post_feedback',cb.parent()).text(feedback); $(".frontCheck",ocb.parent()).removeAttr('checked'); $(".frontCheck",cb.parent()).attr('checked','checked'); cb.show();  }																																																																						 });
																																																																								  
																																																																								  })
	
	
	
	
	$(".newsletterSelector").unbind().change(function(){
var id2;
var dd=$(this);
$(".newsletterSelector").each(function(){
									   if($(this).val()==$(':selected',dd).val()){
										   if($(this).attr('id')!=dd.attr('id'))id2=$(this).attr('id');
										
										   }
									   })

$(".feedback",$(this).parent()).load("includes/ajaxFuncs.php",{'function':'doNewslettering','action':'post','id':$(this).attr('id'),'position':$(':selected',this).val()}, function(){
																																									$(".newsletter #"+id2).attr("selectedIndex",0);
$('.feedback',$(".newsletter #"+id2).parent()).text('');
																																									
																																									});

													  });
	
	
	
	
	
	
	
	
	}

jSlide_init=function(){
	$('.jSlide_page').css('color','#999999').css('border','#FFFFFF 1px solid');
	slideShows=$('.jSlide_container');
	slideShows.each(function(i, el) {	$('.jSlide_page:first',el).css('color','#000000').css('border','#000000 1px solid'); 
																							  });	


	$('.jSlide_prev').click(function(){ 

						$('.jSlide_page[n='+$(this).parent().parent().attr('currentP')+']',$(this).parent().parent()).css('color','#999999').css('border','#FFFFFF 1px solid');
					var cp=Number($(this).parent().parent().attr('currentP')); 
					if(cp==1){cp=Number($(this).parent().parent().attr('totalP'));$(this).parent().parent().attr('currentP',cp); } else 
					$(this).parent().parent().attr('currentP',cp-1); 
						$('.jSlide_page[n='+$(this).parent().parent().attr('currentP')+']',$(this).parent().parent()).css('color','#000000').css('border','#000000 1px solid');
									 
 $('.jSlide_pics',$(this).parent().parent().parent()).animate({left:-$(this).parent().parent().attr('width')*($(this).parent().parent().attr('currentP')-1)},300);

									
																																					   });	

$('.jSlide_next').click(function(){ 

						$('.jSlide_page[n='+$(this).parent().parent().attr('currentP')+']',$(this).parent().parent()).css('color','#999999').css('border','#FFFFFF 1px solid');
					var cp=Number($(this).parent().parent().attr('currentP'));
					if(cp==$(this).parent().parent().attr('totalP'))cp=0;
					$(this).parent().parent().attr('currentP',cp+1);
						$('.jSlide_page[n='+$(this).parent().parent().attr('currentP')+']',$(this).parent().parent()).css('color','#000000').css('border','#000000 1px solid');
								 
									 
 $('.jSlide_pics',$(this).parent().parent().parent()).animate({left:-$(this).parent().parent().attr('width')*(cp)},300);

									
																																					   });	


$('.jSlide_page').click(function(){ 
									 									 
						$('.jSlide_page[n='+$(this).parent().attr('currentP')+']',$(this).parent()).css('color','#999999').css('border','#FFFFFF 1px solid');
					$(this).parent().attr('currentP',$(this).attr('n'));
							$(this).css('color','#000000').css('border','#000000 1px solid');
 $('.jSlide_pics',$(this).parent().parent()).animate({left:-$(this).parent().attr('width')*(Number($(this).text())-1)},300);

									
																																					   });

// content slider
$('.jContentSlide_next').click(function(){
										var cp=Number($(this).parent().attr('currentP'));
								if((cp)<$(this).parent().attr('totalP'))cp++;else cp=1;
								$(this).parent().attr('currentP',cp);
								$('.jSlide_content',$(this).parent()).animate({left:-$(this).parent().attr('width')*(cp-1)},300);
										})
$('.jContentSlide_prev').click(function(){ 
										var cp=Number($(this).parent().attr('currentP'));
								if((cp-1)>0)cp--;else cp=$(this).parent().attr('totalP');
								$(this).parent().attr('currentP',cp);
								$('.jSlide_content',$(this).parent()).animate({left:-$(this).parent().attr('width')*(cp-1)},300);
										})

	}
	
	setNewsPage=function(){
		setUpMostReadRated();
		setUpWeatherBlogs();
		jSlide_init();
		}


switchTabs=function(img,src1,src2,map1,map2){
	
if(img.attr('src')==src1){
img.attr('src',src2);	img.attr('usemap',map2);	
	}else{
img.attr('src',src1);	img.attr('usemap',map1);	
		}

	}
	
setHomePage=function(){
	setUpMostReadViewed();
	setUpWeatherBlogs();
	jSlide_init();
}

setUpContactPage=function(){
	click=false;
	$("#feedback").click(function(){if(!click){$(this).val('');click=true; $(this).css('color','#000000');}});
	$("#submit").click(function(){
								st='';
								
								st=((((!$("#form #feedback").val())||($("#form #feedback").val()=='Provide your feedback here'))||(!$("#form #name").val())||(!$("#form #subject").val()))?'Please fill all the fields in the contact form'+((!checkemail($("#form #email").val()))?' and provide a valid email':''):((!checkemail($("#form #email").val()))?'Please provide a valid email':''));
								
								if(st) alert(st); else {
									 var values ={};	   var inputs = $('#form input,#form :selected, textarea');
									inputs.each(function(i, el) {values[el.id] = $(el).val();});	
									values['function']='contactUs';
									$.post("includes/ajaxFuncs.php",values, function(data){alert(data); location.href='index.php';});
									};
								
								});
	}


setUpArchivePage=function(){
	setUpWeatherBlogs();
	setUpMostReadRated();
	jSlide_init();
	
	search=function(){
		var	values ={};
		var inputs = $('#archiveSearchControls input,#archiveSearchControls  :selected');
		inputs.each(function(i, el) {values[el.id] = $(el).val();});	
		values['dateRange']=$('#archiveSearchControls  :checked').val();
		values['function']='getArchive';
		$('#archiveContainer').load('includes/ajaxFuncs.php',values,function(){parseAttr();})
	}
	
	$('#archiveAdvancedOptions').hide();
	$('#archiveAdvancedToggle').click(function(){$('#archiveAdvancedOptions').toggle()})
	$('input:radio').css('position','relative').css('top','3px');
	$('input:radio').click(function(){$('#customDate').hide();})
	$('#archiveCustomDateToggle').click(function(){ $('#customDate').show();})
	$('#customDate').hide();
	
	$('#searchBut').click(function(){search();})
	//search automatically no matter how you get to archive page
	search();
	//////////////////////////////
	if($('#cat')[0].selectedIndex==0)$('#cat').css('color','#AAAAAA'); else $('#subCatContainer').load('includes/ajaxFuncs.php',{'function':'getSubCatsDrop','id':$('#cat').val()},function(){$(this).show(); 

if($('#presubcat').val())$("[value='"+$('#presubcat').val()+"']",this).attr('selected','selected');

$('#subcat').change(function(){
	if((this.selectedIndex)&&($('#cat').val()==15))$('#sub2CatContainer').load('includes/ajaxFuncs.php',{'function':'getSub2CatsDrop','id2':$(this).val()},function(){$(this).show();});else $('#sub2CatContainer').hide();							 
							 })

   if($('#presub2cat').val()){
	   $('#sub2CatContainer').load('includes/ajaxFuncs.php',{'function':'getSub2CatsDrop','id2':$('#presubcat').val()},function(){$(this).show(); $("[value='"+$('#presub2cat').val()+"']",this).attr('selected','selected'); });
	   }
																																																	   
																																																		   search();});
	
	$('#cat').click(function(){$(this).css('color','#000000');}).blur(function(){if(this.selectedIndex==0){$(this).css('color','#AAAAAA');}}).change(function(){
																																							  		if(this.selectedIndex==0){ $('#subCatContainer').hide(); 	$(this).css('color','#AAAAAA');}
		else{ $('#subCatContainer').load('includes/ajaxFuncs.php',{'function':'getSubCatsDrop','id':$(':selected',this).val()},function(){$(this).show();
		
		$('#subcat').change(function(){
									 		
	if((this.selectedIndex)&&($('#cat').val()==15))
	{

		$('#sub2CatContainer').load('includes/ajaxFuncs.php',{'function':'getSub2CatsDrop','id2':$(this).val()},function(){$(this).show();})}
	else $('#sub2CatContainer').hide();							 
							 })
																																																																																																				   });}
		
		$('#sub2CatContainer').html('');
		
		})
	
	
	if($('#searchWord').val())search();
	}
setUpTravelPage=function(){
	setUpMostReadRated();
	setUpWeatherBlogs();
};
setUpArticlePage=function(){
	setUpMostReadRated();
	setUpWeatherBlogs();
	//comments setup
	setUpComments=function(){

		setUpCommentsAuth=function(){
			//loginToComment=true;
			/*loginToComment=false;
			$("#authentication #comments_register").hide();
			$("#authentication #reg").css('cursor','pointer').click(function(){$("#authentication #comments_register").show(); $("#authentication #comments_login").hide(); loginToComment=false;});
			$("#authentication #log").css('cursor','pointer').click(function(){$("#authentication #comments_register").hide(); $("#authentication #comments_login").show(); loginToComment=true;});*/
		}
		$("#article_comments_area .comment_toggler").click(function(){
			 if($(this).attr('clicked')!='true'){		
			 //alert('test');
			 $(this).attr('clicked','true');
			 $(this).next().load('/eng/includes/ajaxFuncs.php',{'function':'loadComment','id':this.id},function(){
			 	$(".comment_back").click(function(){
					var comback=$(this);
					/*$.post("includes/ajaxFuncs.php",{'function':'isLoggedIn'}, function(loggedIn){
						if(loggedIn){comback.unbind();		
							var parent_id=comback.attr('id');
						} else alert('You need to log in to post reply!')});*/										  
						});
					$("#article_comments_area img").css('cursor','pointer');
				   });	 } else $(this).next().slideToggle('normal');
			 });
		//$("#article_comments_addnew_area").slideUp(1);	
		$(".addComment").unbind();
	};
	
	$("#article_comments_area").load('/eng/includes/ajaxFuncs.php',{'function':'buildCommentsSection','id':$('#articleId').attr('value')},setUpComments);
	//alert('4');
	
	// qtip 
	
	$("#authorLink").qtip({
   content: '<span style="font-size:10px">Click here to see other articles by this author</span>',
   style: { 
   width:300,
      background: '#FFFFFF',
      color: 'black',
      textAlign: 'center',
      border: {
         width: 4,
         radius: 3,
         color: '#1EA4D8'
      },
      tip: 'topLeft'
     
   }
});
$("#authorLink").css('cursor','pointer').click(function(){$('#authorForm').submit();});
	
	
	
	}

setUpCulturePage=function(){
setUpMostReadRated();
setUpWeatherBlogs();
jSlide_init();	
//if(loadTG==true){
	$(".tgSwitch").click(function(){alert('Sorry, still loading the guide. Please try again in a second')});
	$('#TGContent').load('includes/ajaxFuncs.php',{'function':'getTG'},function(results){ 
																				$(".tgSwitch").unbind();
																				$(".tgSwitch").click(function(){
																				
																				$("#standartContent").hide();
																				$("#TGContent").show();
																				
																				
																								$(".tgSwitch").click(function(){
																				
																								$("#standartContent").show();
																								$("#TGContent").hide();
																								});
								 												
																				});
																				
																				})
	
	//}
	

	
	
	//$("#items_list div").css('border','#003388 1px solid');
	
		$(".accordion .element").slideUp(1);
		 $("#items_list").fadeIn("slow");
		var lastToggled=$(".bla");
		$(".accordion .toggler").click( 
										 function(){ 
																					 
										 
										 if(lastToggled.next().next().attr('id')!=$(this).next().next().attr('id')){
											 
											 lastToggled.next().slideToggle("normal"); 
										 jQuery(".img", lastToggled).attr('src',((jQuery(".img",  lastToggled).attr('src')=='images/little_green_arrow_down.gif')?'images/little_green_arrow_up.gif':'images/little_green_arrow_down.gif'));
										 lastToggled=$(this); 
										 }else{ lastToggled=$(".bla");}
										 
										 $(this).next().slideToggle("slow");

										 jQuery(".img", this).attr('src',((jQuery(".img", this).attr('src').indexOf('images/little_green_arrow_down.gif')!=-1)?'images/little_green_arrow_up.gif':'images/little_green_arrow_down.gif')); 
										 //this.unbind();
										 });	
		
		$("#guide_sorter").change(function(){
										 
	 $("#items_list").fadeOut(100).load("includes/culture_ajax.php", {'date' : $("#change_week1").val(), 's':$("#s").val(), 'sc':$("#sc").val(), 'c':$("#c").val(), 'p':1,'sort':$(':selected',this).val()},setUpCulturePage);
										   });
	//setUpGMap();
	
	
	//$("#accordion .gMapLink").mouseover(function(){ alert('yo');});

	$(".pager_item").click(function() {
	$("#items_list").fadeOut(100).load("includes/culture_ajax.php", {'date' : $("#change_week1").val(), 's':$("#s").val(), 'sc':$("#sc").val(), 'c':$("#c").val(), 'p':this.rel,'sort':$("#guide_sorter :selected").val()},setUpCulturePage);
});	
$(".pager_item_week").click(function() {
	$("#items_list").fadeOut(100).load("includes/culture_ajax.php", {'date' : $("#change_week1").val(), 's':$("#s").val(), 'sc':$("#sc").val(), 'c':$("#c").val(), 'p':$("#").val(),'d':$("#d").val(),'pw':this.rel,'sort':$("#guide_sorter :selected").val()},setUpCulturePage);
});
$(".weeks").click(function() {
	$("#items_list").fadeOut(100).load("includes/culture_ajax.php", {'date' : $("#change_week1").val(), 's':$("#s").val(), 'sc':$("#sc").val(), 'c':$("#c").val(), 'd':this.rel},setUpCulturePage);
});
$(".cities").click(function() {
	$("#items_list").fadeOut(100).load("includes/culture_ajax.php", {'date' : $("#change_week1").val(), 's':$("#s").val(), 'sc':$("#sc").val(), 'c':this.rel},setUpCulturePage);
	
});	
$(".cities").click(function() {
	$("#cities_block").fadeOut(100).load("includes/culture_ajax.php", {'show_cities': true, 'c':this.rel},setUpCulturePage);
	
});
$(".ratingblock").click(function(){

$(".logindiv").toggle("slow");
});
$(".close").click(function(){

$(".logindiv").toggle("slow");
});

	}

function loginForm1() {
username = document.getElementById('user_rating').value;
    pass = document.getElementById('login_pass_rating').value;
    JsHttpRequest.query(
        '/eng/includes/login_ajax.php',
        {
            'do':'login',
            'username':username,
            'pass'    :pass
        },
        function(result, errors) {
             if (result["login"] == '')
             {
                document.getElementById('login_error1').innerHTML = result["login_error"];
		document.getElementById('login_error').innerHTML = result["login_error"];
             }
             else
             {
                document.getElementById('account_login').innerHTML = result["login"];
                $(".logindiv").toggle("slow");
                //document.getElementById('login_error').innerHTML = '';
                //document.getElementById('login_error').display = "none";
             }
        },
        false
    );
}

setUpGMap=function(){
		
		
// gmap stuff
initialize=function() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("gMapContainer"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        geocoder = new GClientGeocoder();
		
		 var mapTypeControl = new GMapTypeControl();
        var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
        map.addControl(mapTypeControl, bottomRight);
        GEvent.addListener(map, "dblclick", function() {
//          map.removeControl(mapTypeControl);
  //        map.addControl(new GMapTypeControl(), bottomRight);
        });
        map.addControl(new GSmallMapControl());
				
      }
    }
 
    showAddress=function(address,title) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml(title+'<br/>'+address,{noCloseOnClick:true});
            }
          }
        );
      }
    }



 
var lastAddress='';

$("#accordion .gMapLink").mouseover(function(){
									
				var element=$(this).parent();
				while(element.attr('class')!="element"){ element=element.parent();}
					
					
//$(".gMapRow", element).append("<div class='gMapContainer' id='gMapContainer'></div>");
//$(".gMapRow", element).append("<div class='gMapCloser'></div>");

//alert($(".gMapRow:first-child", $element).attr('class'));
var gMapContainer=$(".gMapContainer",element);
var gMapCloser=$(".gMapCloser",element);



var map = null;
    var geocoder = null;
 
	initialize();
	


gMapCloser.click(function(){
					//	gMapContainer.slideUp();
						 // gMapCloser.hide();
						  });

					
					if($('.address',element).text()!=lastAddress)showAddress($('.address',element).text(),$('.pagesTitle',element.prev()).text()+'<br/>'+$('.contactInfo',element).text());
			//	gMapContainer.slideDown();
//				gMapCloser.show();
				lastAddress=$('.address',element).text();
				//gMapContainer.css({opacity:1, display:"none"}).fadeIn(400);
				
		//	var t = $(".gMapLink",$element).offset().top;
    //		var l = $(".gMapLink",$element).offset().left;

				//gMapContainer.css({left:l-205+((location.href.indexOf("culture.php")  !=  -1)?+215:0), top:t-420+$('#content').scrollTop()});
				//gMapCloser.css({left:l+210+((location.href.indexOf("culture.php")  !=  -1)?+215:0), top:t-415+$('#content').scrollTop()});
		}).mousemove(function(kmouse){
			
		}).mouseout(function(){
				//gMapContainer.fadeOut(400);
		}).click(function(){
			// gMapContainer.hide();  gMapCloser.hide();
			window.open('http://maps.google.com/maps?q='+$('.address',element).text());
			});

	}


setUpShalomPages=function(){


setUpMostReadRated();
setUpWeatherBlogs();
$("#searchKeyword").keyup(function(){
	$("#search_ajax_box").show();
	$("#search_ajax_box").load('/eng/includes/ajaxFuncs.php', {'function':'shalomPagesSearch','search':$("#searchKeyword").val()},function(){ajax_search_func()});
});
function ajax_search_func()
{

$(".ajax_search").change(function(){
	$("#searchKeyword").attr('value',($(this).val()));
	$("#search_ajax_box").hide();
});
}
	$(".imgButton").mouseout(function(){$(this).attr('src',$(this).attr('out'))}).mouseover(function(){$(this).attr('src',$(this).attr('over'))});
	
	//if(location.href.indexOf("shalompageslist.php")  !=  -1)setUpGalleries();
	
	}
//-------------------  galleries funcs begin

setUpGalleries=function(){
	
		$("#accordion > .element").slideUp(1);
		var lastToggled=$("#rightSkyBanner");
		$("#accordion > .toggler").click( 
										 function(){ 
										// $(".gMapContainer").hide();  $(".gMapCloser").hide();
											 
										jQuery(".img", this).attr('src',((jQuery(".img", this).attr('src')=='images/expand.gif')?'images/collapse.gif':'images/expand.gif'));  
										 if($(".galleryContainer",lastToggled).attr('id')!=$(".galleryContainer",$(this).next()).attr('id')){lastToggled.slideToggle("normal"); jQuery(".img", lastToggled.prev()).attr('src',((jQuery(".img",  lastToggled.prev()).attr('src')=='images/expand.gif')?'images/collapse.gif':'images/expand.gif')); lastToggled=$(this).next(); }else{ lastToggled=$("#rightSkyBanner");}
										 
										 $(this).next().slideToggle("normal");});
		
		var galleries=$(".galleryContainer");
		galleries.each(function(i, el) {
	
	var id=el.id;
	var pic=jQuery(".sPagesPic", this);
	
	pic.load('ajaxPic.php',{s:'pics/shalompages/'+id+'/'+jQuery(".sPagesPic", this).next().next().text()+'.jpg',w:286,h:214});	 
	thumbs=jQuery(".sPagesThumb", this);
	
	thumbs.each(function(i2, el2) {
						 el2.pic=$(this).text();
						 $(this).load('ajaxPic.php',{s:'pics/shalompages/'+id+'/'+el2.pic+'.jpg',w:90,h:68},function(){
																
																$(this).click(function(){pic.load('ajaxPic.php',{s:'pics/shalompages/'+id+'/'+el2.pic+'.jpg',w:286,h:214});	 });
																$(this).mouseover(function(){$(this).css("border-color","#777777");});
																$(this).mouseout(function(){$(this).css("border-color","#CCCCCC");});
																
																});	 
						 	});

								});
		
	
//setUpGMap();


$("#accordion .gMapLink").click(function(){
										 var element=$(this).parent();
while(element.attr('class')!="element"){ element=element.parent();}
										 window.open('http://maps.google.com/maps?q='+$('.address',element).text());});
	
	}



//-------------------  galleries funcs end

//-------------------  accordion funcs begin
setUpSaveButton=function(){
	 

var inputs = $('#myAccordion input');
var selectInputs = $('#ajaxLocator :selected');
var hiddenInputs = $('#myAccordion :hidden');
   
var	initValues ={};

inputs.each(function(i, el) {initValues[el.id] = $(el).val();});
selectInputs.each(function(i, el) {initValues[el.id] = $(el).val();});

	 $("span.save").click(function(){		
		
	   var values = {};								 

var inputs = $('#myAccordion input');
var selectInputs = $('#ajaxLocator :selected');
var hiddenInputs = $('#myAccordion :hidden');

    inputs.each(function(i, el) { 		 if(initValues[el.id]!=$(el).val())values[el.id] = $(el).val();});
	selectInputs.each(function(i, el) { values[el.id] = $(el).val();});
	hiddenInputs.each(function(i, el) { values[el.id] = $(el).val();});
	

	
$('#accContainer').load('updateProfile.php',values);	
this.unbind();
										});
	 }
 
 setUpLocatorDrops=function(){
 //$("#myAccordion input").css('width','200px');  $("select").css('width','200px');
 $("#regionDrop").change(function(){   $("#myAccordion  #ajaxLocator").load('ajaxLocator.php',{region_id: $("#regionDrop :selected").val()},setUpLocatorDrops); });
 $("#provinceDrop").change(function(){   $("#myAccordion  #ajaxLocator").load('ajaxLocator.php',{region_id: $("#regionDrop :selected").val(),province_id: $("#provinceDrop :selected").val()},setUpLocatorDrops); });
		
		 setUpSaveButton();
}
   
   setUpAccordion=function(){
	   
		$("#myAccordion  #ajaxLocator").load('ajaxLocator.php',{},setUpLocatorDrops);
		
		
		
		$("#myAccordion > .acc_element").slideUp(1);
		$("#myAccordion > .acc_toggler").click(function(){
												 var expandBut=jQuery(".acc_expandBut", this);
												 if(expandBut.text()=="+"){expandBut.text('-')}else{expandBut.text('+')};
												 $(this).next().slideToggle("normal");
										  
												  });
		
		$(".updateStatusMsg").fadeTo(5000, 1).fadeOut(2000);
		
	   }
   
//-------------------  accordion funcs end   
   
   resizeContent=function(){
	   $('#content').css('height',(Number(document.body.clientHeight)-Number($('#head').css('height').substr(0,$('#head').css('height').length-2))+45)+'px');

/*var x=document.getElementById('headerContainerTable').rows;
	
	
	
	  if(Number($('#content').css('width').substr(0,$('#content').css('width').length-2))<1125){
x[0].align="left";
		   $('#headerTable').css('left','18px');

		   }else{		
x[0].align="center";
		   $('#headerTable').css('left','-54px');
		   
		   if(location.href.indexOf("blogs")  !=  -1)$('#headerTable').css('left','12px');
}*/

//alert($('#headerTable').css('left'));
	//	  alert($('#headerContainerTable').css('text-align')+' | '+$('#headerTable').css('left'));		    
	   }
	   
   
function checkemail(str){
var testresults;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true
else{
testresults=false
}
return (testresults)
}

function checkShalompagesForm(){
	var st="";

if(($('#business_name').val()=='')||($('#phone_number').val()=='0')||($('#state_select').val()=='0')||($('#city_select').val()=='0')||($('#postal_code').val()=='')||($('#street').val()==0)||($('#country_select').val()==0)) st+="\n* Please fill in all the fields";
if ($('#email').val()!=''&&!checkemail(form.email.value)) st+="\n* The email you provided is not valid";
if ($('#pass').val()!=$('#passc').val()) st+="\n* The password and confirmation password do not match";
if(st!=""){st="The following problems were encountered:"+st; alert(st); return false;}else{return true;}
	}
function checkForm(form){
	var st="";

if(($('#username').val()=='')||($('#email').val()=='')||($('#pass').val()=='')||($('#passc').val()=='')) st+="\n* Please fill in all the fields";
if(st!=""){st="The following problems were encountered:"+st; alert(st); return false;}else{return true;}
	}
 function checkShalompageCategoryForm(form){
    var st="";

if($('#category1').val()==0 || $('#subcategory_select1').val()==0) st="\n* Please choose category and subcategory!";
if(st!=""){st="The following problems were encountered:"+st; alert(st); return false;}else{return true;}
    }

/*function checkShalompagesStep1Form()
var st="";

if($('#category_select').val()==0 || $('#subcategory_select1').val()==0) st="\n* Please choose a period!";
if(st!=""){st="The following problems were encountered:"+st; alert(st); return false;}else{return true;}
    }*/
   
   	function parseAttrs(i,el){
				   
				   var classes=$(el).attr('class').split(" ");
				   for (key in classes) {switch(classes[key]){
					   
					   case "cell":
					   
					   $(el).css('float','left');
					   					   
					 //  alert($(el).attr('w'));
					   break;
					   
					   case "spacer":
					   $(el).css('width',(($(el).attr('w'))?$(el).attr('w'):'100%'));
					   $(el).css('height',(($(el).attr('h'))?$(el).attr('h'):'100%'));
					   break;
					   
					   }
					   
					   if($(el).attr('a')) {switch($(el).attr('a')){
						   case 'l': $(el).css('text-align','left'); break;
						   case 'c': $(el).css('text-align','center'); break;
						   case 'r': $(el).css('text-align','right'); break;
						   }}
					   
					   if($(el).attr('w'))$(el).css('width',$(el).attr('w'));
					   if($(el).attr('h'))$(el).css('height',$(el).attr('h'));
					   
					   if($(el).attr('c'))$(el).css('color',$(el).attr('c'));
					   if($(el).attr('fs'))$(el).css('font-size',$(el).attr('fs'));
					   if($(el).attr('b'))$(el).css('border',(($(el).attr('bc'))?$(el).attr('bc'):'#000000')+' solid '+$(el).attr('b')+'px');
					   if($(el).attr('lh'))$(el).css('line-height',$(el).attr('lh'));
					   
					   if($(el).attr('x')){$(el).css('position','relative');$(el).css('left',$(el).attr('x'));}
					   if($(el).attr('y')){$(el).css('position','relative');$(el).css('top',$(el).attr('y'));}
					   
					   if($(el).attr('p'))$(el).css('padding',$(el).attr('p'));
					   if($(el).attr('pl'))$(el).css('padding-left',$(el).attr('pl'));
					   if($(el).attr('pr'))$(el).css('padding-right',$(el).attr('pr'));
   					   if($(el).attr('pt'))$(el).css('padding-top',$(el).attr('pt'));
					   if($(el).attr('pb'))$(el).css('padding-bottom',$(el).attr('pb'));
					   
  					   if($(el).attr('m'))$(el).css('margin',$(el).attr('m'));
					   
					   if($(el).attr('fl'))$(el).css('float',(($(el).attr('fl')=='l')?'left':'right'));
					   
					   if($(el).attr('bold'))$(el).css('font-weight','bold');
   					   if($(el).attr('block'))$(el).css('display','block');
					    if($(el).attr('cursor'))$(el).css('cursor',$(el).attr('cursor'));
						 if($(el).attr('u'))$(el).css('text-decoration','underline');
						 if($(el).attr('bgc'))$(el).css('background-color',$(el).attr('bgc'));
					   
					      //if($(el).attr('over'))$(el).mouseover(function(){$(this).attr('src',$(this).attr('over'))}).mouseout(function(){$(this).attr('src',$(this).attr('out'))});
					   
					   }
				   }
 
   function parseAttr(){
   	var divs=$("div");

	divs.each(parseAttrs);
	   }
   
setUpArchivePageAdmin=function(){
    search=function(){
       var  values ={};    var inputs = $('#archiveSearchControls input,#archiveSearchControls  :selected');
    inputs.each(function(i, el) {values[el.id] = $(el).val();});    
                   values['dateRange']=$('#archiveSearchControls  :checked').val();
    

                                   
                                   }
    
	$('#searchBut').click(function(){
	$('#article_search').submit();
	});
    $('#archiveAdvancedOptions').hide();
    $('#archiveAdvancedToggle').click(function(){$('#archiveAdvancedOptions').toggle()})
    $('input:radio').css('position','relative').css('top','3px');
    $('input:radio').click(function(){$('#customDate').hide();})
    $('#archiveCustomDateToggle').click(function(){ $('#customDate').show();})
    $('#customDate').hide();
    $('#searchBut').click(function(){search();})
    
    if($('#cat')[0].selectedIndex==0)$('#cat').css('color','#AAAAAA'); else $('#subCatContainer').load('../includes/ajaxFuncs.php',{'function':'getSubCatsDropAdmin','id':$('#cat').val()},function(){$(this).show(); if($('#presubcat').val())$("[value='"+$('#presubcat').val()+"']",this).attr('selected','selected'); search();});
    
    $('#cat').click(function(){$(this).css('color','#000000');}).blur(function(){if(this.selectedIndex==0){$(this).css('color','#AAAAAA');}}).change(function(){if(this.selectedIndex==0){ $('#subCatContainer').hide();    $(this).css('color','#AAAAAA');}else{ $('#subCatContainer').load('../includes/ajaxFuncs.php',{'function':'getSubCatsDropAdmin','id':$(':selected',this).val()},function(){$(this).show();})}})
    
    
//     if($('#searchWord').val())search();
//     }
//     }
    };      



   $(document).ready(function(){
	
	if((location.href.indexOf("products.php") == -1) && (location.href.indexOf("cultureCat.php") == -1)) {
		resizeContent();		
		$('#content').scroll(function(){}); 
		$(window).resize(resizeContent);
	} else if((location.href.indexOf("products.php") == -1) && (location.href.indexOf("cultureCat.php") != -1)) {
		resizeContent();		
		//$('#content').scroll(function(){
			//document.getElementById('adContainer').style.height = window.document.getElementById('adCell').offsetHeight-30+"px";
			//var newPadding = document.getElementById('content').scrollTop-480;
			//$(".advertisementDiv").animate({"paddingTop": newPadding}, "fast");
		//}); 
		$(window).resize(resizeContent);
	}
	
	if(location.href.indexOf("products.php")  !=  -1){setUpProductsPage();}
	if(location.href.indexOf("home_page.php")  !=  -1){setUpAccordion();}
	if(location.href.indexOf("shalompages.php")  !=  -1){ setUpShalomPages();}
	if(location.href.indexOf("shalompageslist.php")  !=  -1){ setUpShalomPages();}
	if(location.href.indexOf("shalompages/")  !=  -1){ setUpShalomPages();}
	if(location.href.indexOf("culture.php")  !=  -1){ setUpCulturePage();}
	if(location.href.indexOf("cultureCat.php")  !=  -1){ setUpCulturePage();}
	if(location.href.indexOf("article.php")  !=  -1){	setUpArticlePage();}
	if(location.href.indexOf("travel.php")  !=  -1){	setUpTravelPage();}

	if(location.href.indexOf("unsubscribe.php")  !=  -1){	setUpArticlePage();}
	//2 lines below check for new MOD_REWRITE address of the article page
	var patternForArticlePage = /\/eng\/\d{1,}\//;
	if(patternForArticlePage.test(location.href) == true){	setUpArticlePage();}
	if(location.href.indexOf("archive.php")  !=  -1){	setUpArchivePage();}
	if(location.href.indexOf("contact.php")  !=  -1){	setUpContactPage();}
	if((location.href.indexOf("news.php")  !=  -1)||(location.href.indexOf("economics.php")  !=  -1)||(location.href.indexOf("contest.php")  !=  -1)||(location.href.indexOf("contestStep2.php")  !=  -1)){		setNewsPage();}
	if(location.href.indexOf("blogs")  !=  -1){setUpBlogs();}

	if((location.href.indexOf("index.php")  !=  -1)||(location.href=="http://www.shalomlife.com/eng/")||(location.href=="http://shalomlife.com/eng/")||(location.href=="http://www.shalomlife.com/eng/?type=register")||(location.href=="http://shalomlife.com/eng/#")||(location.href=="http://www.shalomlife.com/eng/#")||(location.href=="http://97.74.86.156/eng/")||(location.href=="http://97.74.86.156/eng/#")){	setHomePage();}

parseAttr();
		
});
function openPopup(sUrl,sOptions)
{
    sName = 'discount';
    if (sOptions == '')
    {
        sOptions = 'location=0,resizable=no,scrollbars=yes,status=0,width=600,height=700,top=40,left=150';
    }
    window.open(sUrl, sName, sOptions);
    return false;
}  
   


