
$(function(){
$('#send_msg').submit(function(){
	var stop = true;
	$(':input',this).filter('.required').each(function(){
		
			if(this.value == ''){
				$(this).css('border','1px solid #f90');
				stop = false;
			}else{
				$(this).css('border','1px solid #777');			
			}
			if($(this).is('.email')){
				if(this.value != '' && !/.+@.+\.[a-zA-Z]{2,4}$/
											.test(this.value)){
					$(this).css('border','1px solid #f90');			
					stop = false;								
				}else if(this.value != ''){
					$(this).css('border','1px solid #777');
				}
			}	
		
		})
		
		if(!stop){
			return false;	
		}
});
});
var ajax = new sack();

function showPopup(){
var IpopLeft = (document.body.clientWidth - document.getElementById("out_body").offsetWidth)/2;
document.getElementById("out_body").style.left = IpopLeft+"px";
}



function doit(song_id,song_type){
	
	ajax.setVar("song_id", song_id); // recomended method of setting data to be parsed.
	ajax.setVar("song_type", song_type);
	ajax.requestFile = "addclick.php";
	ajax.method = 'GET';
	ajax.runAJAX();
}

var play = 0;
var old_sound=-1;
var sound3Embed = null;
function playSound(soundfile,num,song_id,song_type) {
	//alert(song_id+"/"+song_type);
	//alert('old:'+old_sound+'; now:'+num);	
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		if((soundfile == document.all['BGSOUND_ID'].src) && (play == 1))
		{
			play = 0;
			stopSound();
			document.getElementById("sound_"+num).innerHTML="<img src = 'http://tzilum.co.il/vortex_site/img/play.jpg' alt='' />";
		}
		else
		{
			play = 1;
			if(old_sound>0) document.getElementById("sound_"+old_sound).innerHTML="<img src = 'http://tzilum.co.il/vortex_site/img/play.jpg' alt='' />";	
			document.all['BGSOUND_ID'].src=soundfile;
			document.getElementById("sound_"+num).innerHTML="<img src = 'http://tzilum.co.il/vortex_site/img/stop.jpg' alt='' />";	
			doit(song_id,song_type);
			
		}
			
	}
	else
	{
	
		if((soundfile == document.getElementById("mysound").src) && (play == 1))
		{
			play = 0;
			document.getElementById("dummy").innerHTML="<embed id='mysound' enablejavascript='true'></embed>";
			document.getElementById("sound_"+num).innerHTML="<img src = 'http://tzilum.co.il/vortex_site/img/play.jpg' alt='' />";
		}
		else
		{ 
				play = 1;
				if(old_sound>0) document.getElementById("sound_"+old_sound).innerHTML="<img src = 'http://tzilum.co.il/vortex_site/img/play.jpg' alt='' />";	
				document.getElementById("dummy").innerHTML="<embed src='"+soundfile+"' id='mysound' hidden='true' autostart='true' loop='false' enablejavascript='true' />";
				document.getElementById("sound_"+num).innerHTML="<img src = 'http://tzilum.co.il/vortex_site/img/stop.jpg' alt='' />";	
				doit(song_id,song_type);
				
		}
	
	}
	old_sound = num;
}

function stopSound()
{	
	document.all['BGSOUND_ID'].src="";
}

// carousel




$(document).ready(function(){

	//showPopup();

	//hide message_body after the first one

	$(".message_list .message_body:gt(0)").hide();

	

	//hide message li after the 101th

	$(".message_list li:gt(100)").hide();



	

	//toggle message_body

	$(".message_head").click(function(){

		$(this).next(".message_body").slideToggle(500)

		return false;

	});



	//collapse all messages

	$(".collpase_all_message").click(function(){

		$(".message_body").slideUp(500)

		return false;

	});



	//show all messages

	$(".show_all_message").click(function(){

		$(this).hide()

		$(".show_recent_only").show()

		$(".message_list li:gt(100)").slideDown()

		return false;

	});



	//show recent messages only

	$(".show_recent_only").click(function(){

		$(this).hide()

		$(".show_all_message").show()

		$(".message_list li:gt(100)").slideUp()

		return false;

	});



});

function showPic (whichpic) {  

	if (document.getElementById) { 

		document.getElementById('placeholder').src = whichpic.href; 

		

		if (whichpic.title) { 

			document.getElementById('desc').childNodes[0].nodeValue = whichpic.title; 

		} 

		return false; 

	} else { 

		return true; 

	} 

}
