/***********************************************************************************************
	
	Copyright (c) 2007 - catoen.com
	
***********************************************************************************************/
	
function checkUncheckAll(theElement) {
 var theForm = theElement.form, z = 0;
 for(z=0; z<theForm.length;z++){
  if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
  theForm[z].checked = theElement.checked;
  }
 }
}
	
function checkUncheckSome(controller,theElements) {	
 var formElements = theElements.split(',');
 var theController = document.getElementById(controller);
 for(var z=0; z<formElements.length;z++){
  theItem = document.getElementById(formElements[z]);
  if(theItem){
  if(theItem.type){
	if(theItem.type == 'checkbox' && theItem.id != theController.id){
	 theItem.checked = theController.checked;
	}
  } else {

	var nextArray = '';
	 for(var x=0;x <theItem.childNodes.length;x++){
	  if(theItem.childNodes[x]){
		if (theItem.childNodes[x].id){
		  nextArray += theItem.childNodes[x].id+',';
		}
	  }
	 }
	 checkUncheckSome(controller,nextArray);   
   }  
  }
 }
}

function jOnMouseOut(objID){
	document.getElementById(objID).style.cursor = 'pointer'; 
	document.getElementById(objID).style.color = '#6E6E6E';
}

function jOnMouseOver(objID){	
	document.getElementById(objID).style.cursor = 'hand'; 
	document.getElementById(objID).style.color = '#E00000';
}

function jSetBigPicture(obj){	
	document.getElementById("imUser").src = "includes/photo/photoShow.asp?p=" + obj.name; 
	document.getElementById("imSelected").value = obj.name;
}

function switchMain()
{

	if (document.getElementById("harita").checked)
	{
		document.getElementById("a2").style.display = "none";
		document.getElementById("a3").style.display = "none";
		document.getElementById("a4").style.display = "block";
	}

	if (document.getElementById("new").checked)
	{
		document.getElementById("a4").style.display = "none";
		document.getElementById("a2").style.display = "block";
		document.getElementById("a3").style.display = "none";
	}

	if (document.getElementById("fav").checked)
	{
		document.getElementById("a4").style.display = "none";
		document.getElementById("a2").style.display = "none";
		document.getElementById("a3").style.display = "block";
	}	
	
	
}

function switchSubMenu(actdiv)
{
	document.getElementById("submenu_1").style.visibility = "hidden";
	document.getElementById("submenu_2").style.visibility = "hidden";
	document.getElementById("submenu_3").style.visibility = "hidden";
	document.getElementById("submenu_4").style.visibility = "hidden";

	document.getElementById("a4").style.display = "none";
	document.getElementById("a2").style.display = "none";
	document.getElementById("a3").style.display = "none";


	document.getElementById(actdiv).style.visibility = "visible";
	if  (actdiv == 'submenu_1')
	{
		switchMain();
	}
	//document.location = document.location;
 }

 function jDeleteSelectedRecords(theElement, rURL)
 {

	var theForm = document.forms[0], z = 0;
	UIDs = "";
	for(z=0; z < theForm.length; z++)
	{
		if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkAll' && theForm[z].checked == true)
		{
			UIDs = UIDs + theForm[z].value  + ",";
		}
	}
	if (UIDs != "" && confirm(jStr[1]))
	{
		document.location = rURL + UIDs.substring(0, UIDs.length-1);
	}
 }

 function jDeleteSelectedRecord(rURL)
 {
	if (confirm(jStr[0]))
	{
		document.location = rURL;
	}
 }
 
 
function textCounter(field, countfield, maxlimit) {
 
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update '' counter
	else
		countfield.value = maxlimit - field.value.length;
		
}

// Example: obj = findObj("image1");

function findObj(theObj, theDoc)

{

  var p, i, foundObj;

  

  if(!theDoc) theDoc = document;

  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)

  {

    theDoc = parent.frames[theObj.substring(p+1)].document;

    theObj = theObj.substring(0,p);

  }

  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];

  for (i=0; !foundObj && i < theDoc.forms.length; i++) 

    foundObj = theDoc.forms[i][theObj];

  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 

    foundObj = findObj(theObj,theDoc.layers[i].document);

  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

  

  return foundObj;

}


// * Dependencies * 

// this function requires the following snippets:

// JavaScript/readable_MM_functions/findObj

//

// Accepts a variable number of arguments, in triplets as follows:

// arg 1: simple name of a layer object, such as "Layer1"

// arg 2: ignored (for backward compatibility)

// arg 3: 'hide' or 'show'

// repeat...

//

// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');

function showHideLayers()

{ 

  var i, visStr, obj, args = showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3)

  {

    if ((obj = findObj(args[i])) != null)

    {

      visStr = args[i+2];

      if (obj.style)

      {

        obj = obj.style;

        if(visStr == 'show') visStr = 'visible';

        else if(visStr == 'hide') visStr = 'hidden';

      }

      obj.visibility = visStr;

    }

  }
}

function jPopMessage(pType, pMessage){
	if (pMessage){
		pClass = (pType == "i") ? "mac_os_x2" : "mac_os_x";
	  pTitle = (pType == "i") ? mTtlArr[0] : mTtlArr[1];
	  win = new Window({className: pClass, title: pTitle, width:400, height:150, destroyOnClose: true, recenterAuto:false});
	  win.getContent().update("<table height='100%' width='100%'><tr><td valign='middle' class='byz' style=' font-size: 14px;'><center>" + pMessage + "</center></td></tr></table>");
	  win.showCenter();
	}
}  
