function CheckSurveyType1Form(sSurveyId, bSubmit)
{
	var oForm = $("#Form" + sSurveyId);
	var oCheckedRadio = $("#Form" + sSurveyId + " input[type=radio]:checked");
	var oQuestions = $("#Form" + sSurveyId + " input[name=QuestionID]");
	
	if (oCheckedRadio.length == oQuestions.length){
		if (bSubmit) oForm[0].submit();
		return true;
	}
	else {
		return false;
	}
}
	 
function CheckSurveyType2Form(sSurveyId)
{
	var bFormValid = true;
	var oSurveyError = $("#SurveyError" + sSurveyId);
	var oForm = $("#Form" + sSurveyId);
	
	oSurveyError.html("")
	
	if (CheckSurveyType1Form(sSurveyId, false))
	{	
		if ($("#FirstName" + sSurveyId)[0].value == '' || $("#LastName" + sSurveyId)[0].value == '' || $("#Address" + sSurveyId)[0].value == '' || $("#Email" + sSurveyId)[0].value == '') 
		{	
			oSurveyError.append("* נא למלא את כל השדות המסומנים בכוכבית<br/>");
			bFormValid = false;
		}
		else { 
			if (!(new Input(document.getElementById("Email" + sSurveyId)).CheckEmail())) {
				oSurveyError.append("* שדה דואר אלקטרוני לא תקין<br/>");
				bFormValid = false;
			}
		}
	}
	else {
		oSurveyError.html("* אנא השב על כל השאלות.");
		bFormValid = false;
	}
	
	if (bFormValid){
		oSurveyError.hide();		
		oForm[0].submit();		
	}
	else {
		oSurveyError.show();		
		return false;
	}
}
function frmSend2Friend_onclick()
		{
			if (VerifyForm()==true)
			{
				frmSend2Friend.submit();
			}
		}
		
		function toggleSend2Friend()
		{
			TabToggle('ShareSendTab1','ShareSendTab2','ShareSendTab3','SendByMailDiv','SendByCellDiv','ShareDiv');
			if (document.getElementById('divSend2Friend').style.display != '')
				document.getElementById('divSend2Friend').style.display = '';
			else
				document.getElementById('divSend2Friend').style.display = 'none';
		}
		 
		function TabToggle(CurrentTab,tabtohide1,tabtohide2,DivToDisplay,DivTohide1,DivTohide2)
		{
			
			if(document.getElementById(DivToDisplay).style.display != '')
				{
					document.getElementById(DivToDisplay).style.display = '';  
				}
			if(document.getElementById(DivTohide1).style.display != 'none')
				{
					document.getElementById(DivTohide1).style.display = 'none';  
					
				}
			if(document.getElementById(DivTohide2).style.display != 'none')
				{
					document.getElementById(DivTohide2).style.display = 'none';  
				}
			
			document.getElementById(CurrentTab).style.backgroundColor= '#4d4d4d';
			document.getElementById(CurrentTab).style.borderBottom ="none";
			
			document.getElementById(tabtohide1).style.backgroundColor= '#3c3c3c';
			document.getElementById(tabtohide2).style.backgroundColor= '#3c3c3c';
			
			document.getElementById(tabtohide1).style.borderBottomColor ="#8E8D89";
			document.getElementById(tabtohide1).style.borderBottomStyle ="solid";
			document.getElementById(tabtohide1).style.borderBottomWidth ="2px"
			
			document.getElementById(tabtohide2).style.borderBottomColor ="#8E8D89";
			document.getElementById(tabtohide2).style.borderBottomStyle ="solid";
			document.getElementById(tabtohide2).style.borderBottomWidth ="2px"
		}
	
		function CopyToClipBoard2(textboxId) 
		{ 
			eval("document.frmSend2Friend."+textboxId).select();
			eval("document.frmSend2Friend."+textboxId).focus();
			textRange = eval("document.frmSend2Friend."+textboxId).createTextRange(); 
			textRange.execCommand("RemoveFormat"); 
			textRange.execCommand("Copy");
		
		}
		 
		function shareService(servicename,title,url)
		{
			encTitle = encodeURIComponent(title);
			encURL = encodeURIComponent(url);

			share_facebook=({url:"http://www.facebook.com/sharer.php?src=bm&amp;;v=4&amp;i=1178045648&amp;u="+encURL+"&amp;t="+encTitle,width:600,height:500});
			share_delicious=({url:"http://del.icio.us/post?v=4;url="+encURL+";title="+encTitle,width:600,height:500});
			share_twitter=({url:"http://twitthis.com/twit?url="+encURL+"&amp;title="+encTitle,width:650,height:500});
			share_stumbleupon=({url:"http://www.stumbleupon.com/submit?url="+encURL+"&amp;title="+encTitle,width:650,height:500});
			share_shaveh=({url:"http://shaveh.co.il/submit.php?url="+encURL+"&amp;title="+encTitle,width:650,height:500});
			share_hadashot=({url:"http://www.hadash-hot.co.il/submit?url="+encURL+"&amp;title="+encTitle,width:800,height:500});
			share_technorati=({url:"http://www.technorati.com/faves?add="+encURL+"&amp;title="+encTitle,width:800,height:500});

			serviceObj = this["share_"+servicename];
			popup (serviceObj.url,serviceObj.width,serviceObj.height);
		}

		function popup(url,width,height) 
		{
			width = (width==undefined)?500:width;
			height = (height==undefined)?500:height;
			popupFunc=function(){
				if(!window.open(url,'popup','toolbar=0,status=0,resizable=0,width='+width+',height='+height)){
					document.location.href=url;
				}
			}
			if(/Firefox/.test(navigator.userAgent))
				setTimeout(popupFunc,0);
			else
				popupFunc();
		}

		function CopyToClipBoard(elementID) 
		{	
			object=document.getElementById(elementID);
			text2copy=object.value;
			if (window.clipboardData) 
			{
				window.clipboardData.setData("Text",text2copy);
			} 
			else 
			{
				var flashcopier = 'flashcopier';
				if(!document.getElementById(flashcopier)) 
				{
					var divholder = document.createElement('div');
					divholder.id = flashcopier;
					document.body.appendChild(divholder);
				}
		
    			document.getElementById(flashcopier).innerHTML = '';
    			var divinfo = '&lt;embed src="<xsl:value-of select="$naIMAGES_NANA_URL"></xsl:value-of>_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;';
    			document.getElementById(flashcopier).innerHTML = divinfo;
			}
		}

	/*Start Send by cell functions*/
	function SendToMoblin(articleID)
	{
		var sMoblinUrl = "http://www.moblin.com/textCropper/textcropper.aspx?cli=";
		var sArticleUrl = 'http://news.nana10.co.il/Article/?ArticleID=' + articleID;
		
		var sSenderPhone = document.getElementById("ctl00$body$PhoneBox").value;
		var sSenderName = document.getElementById("ctl00$body$NameBox").value;
		var sSenderMessage = document.getElementById("ctl00$body$MessageBox").value;
				
		var sGetUrl = sMoblinUrl + sSenderPhone + "&amp;name=" + sSenderName + "&amp;msg=" + sSenderMessage + "&amp;partnerid=2312&amp;enc=utf-8&amp;url=" + sArticleUrl;
		
		$(function(){
			$.xhr({
				"url": sGetUrl,			
				"onSuccess":function(request)
							{
								/*alert( "Data Saved: " + request.responseText );*/
								ParseXml(request.responseText);
							},
				"onerror":onError
			});
		});		
	}
	
	/*Parse Recieved XML*/
	function ParseXml(sXml)
	{
		try //Internet Explorer
		{
			xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async="false";
			xmlDoc.loadXML(sXml);
			showDataToUser(xmlDoc);
		}
		catch(e)
		{
			try //Firefox, Mozilla, Opera, etc.
			{
				parser=new DOMParser();
				xmlDoc=parser.parseFromString(sXml,"text/xml");
				showDataToUser(xmlDoc);
			}
			catch(e)
			{
				alert("הדפדפן שברשותך אינו תומך בפעולה זו");
			}
		}
	}
	
	/*Show XML data to the user*/
	function showDataToUser(oXMLDoc)
	{
		document.getElementById("sSenderPhone").innerHTML = document.getElementById("ctl00$body$PhoneBox").value;
		document.getElementById("cellCode").innerHTML = oXMLDoc.getElementsByTagName("code")[0].firstChild.nodeValue;
		document.getElementById("cellNumberToSend").innerHTML = oXMLDoc.getElementsByTagName("phone")[0].firstChild.nodeValue;
		document.getElementById("cellPrice").innerHTML = oXMLDoc.getElementsByTagName("price")[0].firstChild.nodeValue;

		document.getElementById("SendByCellDiv").style.display = "none";
		document.getElementById("SendByCellDiv_Approve").style.display="block";
	}
	
	function onError(request, error, ex)
	{
		alert("הדפדפן שברשותך אינו תומך בפעולה זו");
		//alert("Error:" + request.responseText + ", " + error + ", " + ex);
	}
	
	/*User pressed back..*/
	function TuggleSendByCell()
	{
		document.getElementById("SendByCellDiv_Approve").style.display="none";
		document.getElementById("SendByCellDiv").style.display="block";		
	}
	
	function PopMoblinTakanon()
	{
		window.open("http://www.moblin.com/takanon/mobitext.aspx","MoblinTermsOfUse","toolbar=no,scrollbars=yes,width=550,height=450,sizable=yes");
	}
	
	/*End Send by cell functions*/
// Collarity BIGPICTURE part

function ToggleBPElements()
{
	$("#BP_Column2,#BP_Column3,#OpenImage,#CloseImage").toggle();
}

function ShowBigPictureBanner(){
	var oBigPictureBanner = $("#N360_BigPictureBanner");
	
	if (oBigPictureBanner.attr("bHasBanner") != "true" ){
		//oBigPictureBanner.html(DisplayAdsInIFrame("www.nana.co.il/FrontPageNana", "x07", 115, 130,true));
		oBigPictureBanner.html("<div id='ads.nana.1'></div>");
		dcMakeDCCall("ads.nana.1")
		oBigPictureBanner.attr("bHasBanner","true"); 
	}
	else {
		oBigPictureBanner.html("");
		oBigPictureBanner.attr("bHasBanner","false");
	}
}

function N360_WidgetReady(bResult){
	
	if (bResult) {
		$("#BP_Column1").css("display","block");
		
		$("#CloseImage").click(function(){
			$("#block360").animate( {width:"140px"}, 500, "swing", function(){ShowBigPictureBanner();ToggleBPElements();} );
			$(".N360_NavDivBottom").hide();
		});

		$("#OpenImage").click(function(){
			ToggleBPElements();
			$("#block360").animate( {width:"440px"}, 500, "swing", ShowBigPictureBanner );
			$(".N360_NavDivBottom").show();
		});	
	}
}

top.$(function(){
	try
	{
		dcMakeDCCall("ads.talkback.1");
	}
	catch(ex){}
});

//*************************************************************************************
//                      OLD FUNCTIONS
//*************************************************************************************
	
function VerifyForm()
{
	
	if (document.getElementById('SenderName').value == '')
	{
		alert ('נא להכניס את שם השולח');
		return false;
	}
	
	if (!(new Input(document.getElementById('SenderEmail')).CheckEmail()))
	{
		alert ('כתובת השולח שגויה או חסרה');
		return false;
	}

	if (document.getElementById('RecipientName').value == '')
	{
		alert ('נא להכניס את שם הנמען');
		return false;
	}

	if (!(new Input(document.getElementById('RecipientEmail')).CheckEmail()))
	{
		alert ('כתובת הנמען שגויה או חסרה');
		return false;
	}

	return true;
}
  