// JavaScript Document

var loginOut = 0;
function toggleLogin() {
	
	if (loginOut == 0){
		
		if (document.getElementById) {
			eval("document.getElementById('loginFly').style.display = 'block'");
		} else {
			if (document.layers) {
				document.layers['loginFly'].display = 'block';
			} else {
				if (document.all) {
					eval("document.all.loginFly.style.display = 'block'");
				}
			}
		}
		loginOut = 1;
		
	} else {
		
		
		if (document.getElementById) {
			eval("document.getElementById('loginFly').style.display = 'none'");
		} else {
			if (document.layers) {
				document.layers['loginFly'].display = 'none';
			} else {
				if (document.all) {
					eval("document.all.loginFly.style.display = 'none'");
				}
			}
		}
		loginOut = 0;
		
	}	
}

var memberBoxOut = 0;
function toggleMemberBox() {
	if (memberBoxOut == 0){
	
		if (document.getElementById) {
			eval("document.getElementById('memberBoxFly').style.display = 'block'");
		} else {
			if (document.layers) {
				document.layers['memberBoxFly'].display = 'block';
			} else {
				if (document.all) {
					eval("document.all.memberBoxFly.style.display = 'block'");
				}
			}
		}
		memberBoxOut = 1
		
	} else {
		
		
		if (document.getElementById) {
			eval("document.getElementById('memberBoxFly').style.display = 'none'");
		} else {
			if (document.layers) {
				document.layers['memberBoxFly'].display = 'none';
			} else {
				if (document.all) {
					eval("document.all.memberBoxFly.style.display = 'none'");
				}
			}
		}
		memberBoxOut = 0
		
	}	
}

function switch_password_field(f)
{
	var ua=navigator.userAgent.toLowerCase();
	f.value="";
	f.VALUE="";
	f.onfocus="";
	f.onFocus="";
	f.ONFOCUS="";
	if(ua.indexOf("msie")==-1)
	{
		var copyf=document.createElement("input");
		numAttributes=f.attributes.length;
		for(i=0;i<numAttributes;i++)
		{
			if((f.attributes[i].name=="type") || (f.attributes[i].name.toLowerCase()=="type"))
			{
				copyf.type="password"
			}
			else
			{
				if((f.attributes[i].name=="value") || (f.attributes[i].name.toLowerCase()=="value"))
				{
					copyf.value="";copyf.VALUE=""
				}
				else
				{
					if((f.attributes[i].name=="onfocus")||(f.attributes[i].name.toLowerCase()=="onfocus"))
					{
						copyf.onfocus="";
						copyf.onFocus="";
						copyf.ONFOCUS=""
					}
					else
					{
						if(ua.indexOf("msie")!=-1)
						{
							copyf.attributes[i].name=f.attributes[i].name;
							copyf.attributes[i].value=f.attributes[i].value
						}
						else
						{
							copyf.setAttribute(f.attributes[i].name,f.attributes[i].value)
						}
					}
				}
			}
		}
		f.parentNode.replaceChild(copyf,f);
		window.passInput=copyf
	}
	else
	{
		var c=f.cloneNode(true);
		c.type="password";
		f.parentNode.replaceChild(c,f);
		window.passInput=c
	}
	setTimeout("window.passInput.hasFocus=true; window.passInput.focus();",1)
}

function closePhotoUpload(uploadDiv){
    $("#" + uploadDiv).hide();
    return false;
}

function openPhotoUpload(uploadDiv){
    $("#" + uploadDiv).show();
    return false;
}

function showSaveSearchName(hideButton, showDiv, txtSaveName){
    $("#" + hideButton).hide();
    $("#" + showDiv).show();
    $("#" + txtSaveName).focus();    
}

function openFullComment(hideAbbreviated, showFullComment){
    $("#" + showFullComment).show();
    $("#" + hideAbbreviated).hide();       
}

//Trim the input text
function Trim(input)
{
var lre = /^\s*/; 
var rre = /\s*$/; 
input = input.replace(lre, ""); 
input = input.replace(rre, ""); 
return input; 
}

// filter the files before Uploading  
function CheckForImageFile(file, error) 
{
    var fileName=file.value;        
    //Checking for file browsed or not 
    if (Trim(fileName) =='' )
    {            
        return false;
    }

   //Setting the extension array for diff. type of text files 
   var extArray = new Array(".jpg", ".gif", ".png", ".jpeg", ".img");       

   //getting the file name
   while (fileName.indexOf("\\") != -1)
     fileName = fileName.slice(fileName.indexOf("\\") + 1);

   //Getting the file extension                     
   var ext = fileName.slice(fileName.indexOf(".")).toLowerCase();

   //matching extension with our given extensions.
   for (var i = 0; i < extArray.length; i++) 
   {
     if (extArray[i] == ext) 
     { 
       $("#" + error).hide();  
       return true;
     }
   }   
   $("#" + error).show();       
   return false;                
}
