// JavaScript Document

function resizePNG(){
	var CBox_R = document.getElementById("CBox_R");
	var CBox_L = document.getElementById("CBox_L");
	CBox_R.style.height="100%";
	CBox_L.style.height="100%";
//	alert("resized")
}
var message = "function disabled"; 
////disable right click
function clickIE4(){
	if (event.button==2){
		//alert(message);
		return false;
	}
}

function clickNS4(e){
	if (document.layers||document.getElementById&&!document.all){
		if (e.which==2||e.which==3){
			//alert(message);
			return false;
		}
	}
}

if (document.layers){
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
	document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false")
/////end disable right clickalert(message);

function CheckFrame(){
	if (parent.location.href == self.location.href){
		top.location.href = 'default.asp';
	}
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
	//alert(unescape(document.cookie.substring(c_start,c_end)))
    } 
  }
return ""
}

function setCookie(c_name,value,expiredays){
//alert(c_name + "=" + value)
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+ 
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function ResetCookie(){
	setCookie('userName',"",-1)
	setCookie('password',"",-1)
	setCookie('uID',"",-1)
	top.location.href = "default.asp"
}

function checkCookie(CheckType,cType,FID)
{
userName=getCookie('userName')
password=getCookie('password')
uID=getCookie('uID')
	if(CheckType == 1){
		if (userName!=null && userName!=""){
			document.LogIn.UserName.value = userName;
			document.LogIn.Password.value = password;
			document.LogIn.uID.value = uID;
			document.LogIn.submit();
		}
	}else if(CheckType == 2){
		if (userName!=null && userName!=""){
			document.FolderName.location.href = "FolderName.asp?cType="+cType+"&uID=" + uID;
			//document.FolderContent.location.href = "FolderContent.asp?cType="+cType+"&FID="+FID+"&uID=" + uID;
		}else{
			alert("עליך להירשם קודם")
			top.location = "Register.asp"
		}
	}else if(CheckType == 3){
		if (userName!=null && userName!=""){
			document.LogInIFR.location.href = "UserAvatar.asp?uID=" + uID;
			document.Folders.location.href = "UserFolders.asp?uID=" + uID;
		}else{
			alert("עליך להירשם קודם")
			top.location = "Register.asp"
		}
	}
}

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
function alertPNG(){
	for(var i=0; i<document.images.length; i++){
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
			//alert(i)
			fixPNG(img)
		}
	}	
}
function fixPNG(myImage) 
{
    
	
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
/*function resizeIframe(FrameName,Height,Width)
{
	var FrameItem = document.getElementById(""+FrameName+"");
	if(Height <> 0){
		FrameItem.style.height=Height;
	}
	if(Width <> 0){
		FrameItem.style.width=Width;
	}
}*/
function SendFR(uName,fName){
	window.open("about:blank","SendFR","height=350,width=270,left=30,top=30");
	SendToForm.target		= "SendFR"
	SendToForm.action		= "SendToFriend.asp"
	SendToForm.userName.value	= uName;
	SendToForm.folderName.value	= fName;
	SendToForm.submit()
}
function showAlert()
{
	document.all.error.innerHTML = "&nbsp;";
}
function checkForm()
{
document.all.error.innerHTML = "&nbsp;";
fname = document.RegisterForm.fname.value
lname = document.RegisterForm.lname.value
email = document.RegisterForm.email.value
phoneT = document.RegisterForm.phoneT.value
phoneK = document.RegisterForm.phoneK.value
address = document.RegisterForm.address.value
birthDate = document.RegisterForm.birthDate.value
age = document.RegisterForm.age.value
userName = document.RegisterForm.userName.value
RePassword = document.RegisterForm.RePassword.value
Password = document.RegisterForm.Password.value

	
	if(userName.length < 2){
		document.all.error.innerHTML = "אנא מלא שם משתמש";
		window.setTimeout('showAlert()',3000);
		document.RegisterForm.userName.focus();
		return false;
	}
	else if(Password.length < 2){
		document.all.error.innerHTML = "אנא מלא סיסמא";
		window.setTimeout('showAlert()',3000);
		document.RegisterForm.Password.focus();
		return false;
	}
	else if(Password != RePassword){
		document.all.error.innerHTML = "הקש סיסמא שנית";
		window.setTimeout('showAlert()',3000);
		document.RegisterForm.RePassword.value = "";
		document.RegisterForm.Password.value = "";
		return false;
	}
	else if(email.length < 6 || email.indexOf('@')<1){
		document.all.error.innerHTML = "אנא מלא דוא''ל חוקי";
		window.setTimeout('showAlert()',3000);
		document.RegisterForm.email.focus();
		return false;
	}
	
}
function CheckUserName(ItemName){
	MyObj = eval("document.RegisterForm."+ItemName)
	document.AJAXFR.location.href = "Serv/CheckUserExist.asp?"+ItemName+"=" + MyObj.value;
}

function CheckPass(){
	if(document.RegisterForm.RePassword.value != ""){
		if(document.RegisterForm.Password.value != document.RegisterForm.RePassword.value){
			document.all.error.innerHTML = "הקש סיסמא שנית";
			window.setTimeout('showAlert()',3000);
//			document.RegisterForm.RePassword.value = "";
//			document.RegisterForm.Password.value = "";
		}
	}
}

function CheckedUser(ItemType){
	if(ItemType == 1){
		alert("שם משתמש שבחרת קיים כבר במערכת")
		document.RegisterForm.userName.value = "";
	}else{
		alert("כתובת דוא''ל קיימת כבר במערכת")
		document.RegisterForm.email.value = "";

	}
}
var WindowObjectReference;
var poganiWindow;
function Terms(){
  WindowObjectReference = window.open("EventTakanon.html", "Terms", "width=730,height=500,menubar=no,location=no,resizable=yes,scrollbars=yes,status=yes");
}

function OpenInCenter(fileName,wName,width,height){
	poganiWindow=window.open(fileName, wName, "width="+width+",height="+height+",menubar=no,location=no,resizable=no,scrollbars=no,status=no");
}
function CloseInCenter(wName, timeout){if(isNaN(timeout)) timeout=3000;setTimeout("CloseInCenterHelper()", timeout)}
function CloseInCenterHelper(){poganiWindow.close();}
function SetSelectedAvatar(aID){
	document.AvatarFrame.location.href = "Avatar.asp?src=" + aID
	document.RegisterForm.avatarID.value = aID;
}
function SetShowLast(){
	if(document.RegisterForm.showLast.checked){
		document.RegisterForm.LastView.value = 1
	}else{
		document.RegisterForm.LastView.value = 0
	}
}
function SetShowAge(){
	if(document.RegisterForm.showAge.checked){
		document.RegisterForm.AgeView.value = 1
	}else{
		document.RegisterForm.AgeView.value = 0
	}
}
function SetViewLink(){
	if(document.LinkForm.viewLink.checked){
		document.LinkForm.viewStatus.value = 1
	}else{
		document.LinkForm.viewStatus.value = 0
	}
}

function SaveFolderName(param){
	if(param == 1){
		if(document.FolderForm.FolderName.value == ""){
			alert("אנא מלא שם תיקיה")
			document.FolderForm.FolderName.focus();
			return false;
		}
	}
	document.FolderForm.DoIT.value = param;
	document.FolderForm.submit();
}
function SaveLink(param){

	if(param == 1){
//	alert(document.LinkForm.LinkTag.value)
		linkName = document.LinkForm.linkName.value
		LinkURL = document.LinkForm.LinkURL.value
		LinkDesc = document.LinkForm.LinkDesc.value
//		LinkTag = document.LinkForm.LinkTag.value
		if(linkName.length < 2){
			alert("אנא מלא שם האתר")
			document.LinkForm.linkName.focus();
			return false;
		}
		else if(LinkURL.length < 2){
			alert("אנא מלא כתובת האתר")
			document.LinkForm.LinkURL.focus();
			return false;
		}
		else if(LinkDesc.length < 2){
			alert("אנא מלא תיאור האתר")
			document.LinkForm.LinkDesc.focus();
			return false;
		}
/*		else if(LinkTag.length < 2){
			alert("אנא מלא תגית אחת לפחות")
			document.LinkForm.LinkTag.focus();
			return false;
		}*/
	}
	if(LinkURL.substring(0,7) != "http://"){
		tempLink = document.LinkForm.LinkURL.value;
		document.LinkForm.LinkURL.value = "http://" + tempLink;
	}
	document.LinkForm.DoIT.value = param;
	document.LinkForm.submit();
}

function ViewLinkContent(){
	var LeftButtons = document.getElementById("LeftButtons");
	var LinkTR = document.getElementById("LinkTR");
	LeftButtons.style.display = "inline";
	LinkTR.style.display = "inline";
}
function SetAvatar(PicSTR){
	window.opener.top.SetSelectedAvatar(PicSTR);
	window.close();
}

function EditTag(LinkID,TagID,FID){
	var EditTags = document.getElementById("EditTags");
	EditTags.style.display = "inline";
	document.TagEditor.location.href = "TagEditor.asp?linkID="+LinkID+"&tagID="+TagID+"&FID="+FID+""
}
function ViewTag(TagName){

	document.SearchForm.sString.value = TagName;
	document.SearchForm.submit();
}
