// JavaScript Document
	/*
	# eLuminous Technologies - Copyright (C)  http://eluminoustechnologies.com 
	# This code is written by eLuminous Technologies, Its a sole property of 
	# eLuminous Technologies and cant be used / modified without license.  
	# Any changes/ alterations, illegal uses, unlawful distribution, copying is strictly
	# prohibhited 
	# Name: Comman_function.js
	# Usage: included the file to use comman javascript funcation that required in all the pages. ( WRITE USAGE DETAILS ) 
	   -- comman funcation of javascript
	# Created : Rupal Pinge & Sham Shriwastav (30-05-2007)
	# Update  : 30-05-2007 Sham Shriwastav 
	# Status  : open
	# Purpose : make javascript code seprate from other coding
	*/


function getKeyCode(e)
{
	if (window.event)
		return window.event.keyCode;
	else if (e)
		return e.which;
	else
		return null;
}
function keyRestrict(e, validchars,target)
{
	var key='', keychar='';
	key = getKeyCode(e);
	if (key == null) return true;
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	validchars = validchars.toLowerCase();
	if (validchars.indexOf(keychar) != -1)
	{
		if (keychar == '.' && target.value.indexOf(keychar) != -1) {return false;}
		else {return true;}
	}
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
		return true;
	return false;
}

function expand_collapse(dest_id)
{
  if (document.getElementById(dest_id).style.display=="") //collapse the collapse  destionation div
  {
   document.getElementById(dest_id).style.display="none";
  }
 else
  {
   document.getElementById(dest_id).style.display="";
  }
}

function expand_div(div_id)
{
	var show_div_obj = document.getElementById(div_id);
	
	if(show_div_obj && show_div_obj != 'undefined')
	{
		show_div_obj.style.visibility = 'visible';
	}
}



function get_PressKeyCode(e) {
	
	var nav4 = window.Event ? true : false;

	var whichCode = "";
  if (nav4 && e.which) // Navigator 4.0x
  {
	whichCode = e.which
  }
  else // Internet Explorer 4.0x
    if (e.type == "keypress") // the user entered a character
	{
      whichCode = e.keyCode
	}
    else
	{
      whichCode = e.button;
	}
 	return whichCode;
  /*if (e.type == "keypress")
    alert("kepress: code=" + whichCode + 
                    ", character=" + String.fromCharCode(whichCode))
  else
    alert("click: code=" + whichCode);*/
}

function switchImages(id1)
{
	var currimg=document.getElementById("show_plus_"+id1).src;
	imgname = "show_plus_"+id1;
	imgname2 = "show_close_"+id1;
	
	if(currimg.indexOf("images/tree_minus.gif") != -1)
	{
		document.getElementById(imgname).src="images/tree_plus.gif";
		document.getElementById(imgname2).src="images/ic_folderc.gif";
	}
	else
	{
		document.getElementById(imgname).src="images/tree_minus.gif";
		document.getElementById(imgname2).src="images/ic_folder_open.gif";
	}
}

function switchAdminImages(id1)
{
	var currimg=document.getElementById("show_plus_"+id1).src;
	imgname = "show_plus_"+id1;
	imgname2 = "show_close_"+id1;
	
	if(currimg.indexOf("images/tree_minus.gif") != -1)
	{
		document.getElementById(imgname).src="../images/tree_plus.gif";
		document.getElementById(imgname2).src="../images/ic_folderc.gif";
	}
	else
	{
		document.getElementById(imgname).src="../images/tree_minus.gif";
		document.getElementById(imgname2).src="../images/ic_folder_open.gif";
	}
}

function validatedates(frm, to, frm_Default, to_Default)
{
	clear_error_border();
	
	obj_FDate = document.getElementById(frm);
	obj_TDate = document.getElementById(to);

	if(obj_FDate.value != "" && obj_FDate.value != frm_Default && obj_TDate.value != "" && obj_TDate.value != to_Default)
	{
		var month = new Array();
		month['01'] = "January";
		month['02'] = "February";
		month['03'] = "March";
		month['04'] = "April";
		month['05'] = "May";
		month['06'] = "June";
		month['07'] = "July";
		month['08'] = "August";
		month['09'] = "September";
		month['10'] = "October";
		month['11'] = "November";
		month['12'] = "December";
		
		// -- get from date time stamp.
		arr_fd = obj_FDate.value.split("-");
		var strMonthfd = month[arr_fd[1]];
		var myDate = new Date(strMonthfd+' '+arr_fd[2]+', '+arr_fd[0]+' 00:00:00');
		var timestampFD = myDate.getTime()/1000.0;
		//alert(strMonthfd+' '+arr_fd[2]+', '+arr_fd[0]+' 00:00:00 ======== ' + timestampFD);
		
		// -- get to date time stamp.
		arr_td = obj_TDate.value.split("-");
		var strMonthtd = month[arr_td[1]];
		var myDate1 = new Date(strMonthtd+' '+arr_td[2]+', '+arr_td[0]+' 00:00:00');
		var timestampTD = myDate1.getTime()/1000.0;
		//alert(strMonthtd+' '+arr_td[2]+', '+arr_td[0]+' 00:00:00 ======== ' + timestampTD);
		
		if(timestampFD > timestampTD)
		{
			alert(document.getElementById("hid_msg").value)
			obj_FDate.focus();
			obj_FDate.value="";
			obj_FDate.style.border = "1px solid #FF0000";
			return false;
		}
	}
	return true;
}

function copy_clip(meintext)
	{
	   if (window.clipboardData) 
	   {
		window.clipboardData.setData("Text", meintext);
	   }
	   else if (window.netscape) 
	   { 
			netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
			var clip = Components.classes['@mozilla.org/widget/clipboard;1']
					  .createInstance(Components.interfaces.nsIClipboard);
			if (!clip) return;
		
			var trans = Components.classes['@mozilla.org/widget/transferable;1']
					   .createInstance(Components.interfaces.nsITransferable);
			if (!trans) return;
		
			trans.addDataFlavor('text/unicode');
		
			var str = new Object();
			var len = new Object();
			
			var str = Components.classes["@mozilla.org/supports-string;1"]
						 .createInstance(Components.interfaces.nsISupportsString);
			
			var copytext=meintext;
		
			str.data=copytext;
		   
			trans.setTransferData("text/unicode",str,copytext.length*2);
			
			var clipid=Components.interfaces.nsIClipboard;
			
			if (!clip) return false;
			
			clip.setData(trans,null,clipid.kGlobalClipboard);
	   	}
		else
	 	{
			//for opera
		   //alert ("inside");
		   //Copied = meintext.createTextRange();
		   //Copied.execCommand("Copy");
		}
	   //alert("Following info was copied to your clipboard:\n\n" + meintext);
	   return false;
	}  


	function ClipBoard() 
	{
			document.frm_custom_ad_step4.cust_ad_code.focus();
			document.frm_custom_ad_step4.cust_ad_code.select();
			var text_to_copy = document.frm_custom_ad_step4.cust_ad_code.value;

			copy_clip(text_to_copy);
	}	