// JavaScript Document
// JavaScript Document
//<!--<script language="javascript">
/**
 * COMMON DHTML FUNCTIONS
 * These are handy functions I use all the time.
 *
 * By Seth Banks (webmaster at subimage dot com)
 * http://www.subimage.com/
 *
 * Up to date code can be found at http://www.subimage.com/dhtml/
 *
 * This code is free for you to use anywhere, just keep this comment block.
 */

/**
 * X-browser event handler attachment and detachment
 * TH: Switched first true to false per http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html
 *
 * @argument obj - the object to attach event to
 * @argument evType - name of the event - DONT ADD "on", pass only "mouseover", etc
 * @argument fn - function to call
 */
function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, false);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
}
function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
}

/**
 * Code below taken from - http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/
 *
 * Modified 4/22/04 to work with Opera/Moz (by webmaster at subimage dot com)
 *
 * Gets the full width/height because it's different for most browsers.
 */
function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 
	return window.undefined; 
}
function getViewportWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
	return window.undefined; 
}

/**
 * POPUP WINDOW CODE v1.1
 * Used for displaying DHTML only popups instead of using buggy modal windows.
 *
 * By Seth Banks (webmaster at subimage dot com)
 * http://www.subimage.com/
 *
 * Contributions by Eric Angel (tab index code) and Scott (hiding/showing selects for IE users)
 *
 * Up to date code can be found at http://www.subimage.com/dhtml/subModal
 *
 * This code is free for you to use anywhere, just keep this comment block.
 */

// Popup code
var gPopupMask = null;
var gPopupContainer = null;
var gPopFrame = null;
var gReturnFunc;
var gPopupIsShown = false;

var gHideSelects = false;


var gTabIndexes = new Array();
// Pre-defined list of tags we want to disable/enable tabbing into
var gTabbableTags = new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME","JAVASCRIPT","OBJECT");	

// If using Mozilla or Firefox, use Tab-key trap.
if (!document.all) {
	document.onkeypress = keyDownHandler;
}



/**
 * Initializes popup code on load.	
 */
function initPopUp() {
	// Add the HTML to the body
	body = document.getElementsByTagName('body')[0];
	popmask = document.createElement('div');
	popmask.id = 'popupMask';
	popcont = document.createElement('div');
	popcont.id = 'popupContainer';
	popcont.innerHTML =
		'<div id="popupInner">' +
			'<div id="popupTitleBar">' +
			'<div id="popupTitle"></div>' +
				'<div id="popupControls">' +
				'<img src="/images/naadmin/cross.gif" title="Close" alt="Close" width="15" height="15" border="0" onClick=" hidePopWin(false);" />' +
				 '</div>' +
			'<span class="body_grey">AdjustTheVote.org</span></div>' +
			'<iframe src="/loading.html" scrolling="auto" frameborder="0" allowtransparency="true" class="ltbox_border" id="popupFrame" name="popupFrame" width="100%" height="100%"></iframe>' +
		'</div>';
	body.appendChild(popmask);
	body.appendChild(popcont);
	
	gPopupMask = document.getElementById("popupMask");
	gPopupContainer = document.getElementById("popupContainer");
	gPopFrame = document.getElementById("popupFrame");	
	
	// check to see if this is IE version 6 or lower. hide select boxes if so
	// maybe they'll fix this in version 7?
	var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
	if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
		gHideSelects = true;
	}
	
	// Add onclick handlers to 'a' elements of class submodal or submodal-width-height
	var elms = document.getElementsByTagName('a');
	for (i = 0; i < elms.length; i++) {
		if (elms[i].className.indexOf("submodal") == 0) { 
			// var onclick = 'function (){showPopWin(\''+elms[i].href+'\','+width+', '+height+', null);return false;};';
			// elms[i].onclick = eval(onclick);
			elms[i].onclick = function(){
				// default width and height
				var width = 600;
				var height = 100;
				// Parse out optional width and height from className
				params = this.className.split('-');
				if (params.length == 3) {
					width = parseInt(params[1]);
					height = parseInt(params[2]);
				}
				showPopWin(this.href,width,height,null); return false;
			}
		}
	}
}
addEvent(window, "load", initPopUp);

 /**
	* @argument width - int in pixels
	* @argument height - int in pixels
	* @argument url - url to display
	* @argument returnFunc - function to call when returning true from the window.
	*/

function showPopWin(url, width, height, returnFunc) {
	gPopupIsShown = true;
	disableTabIndexes();
	gPopupMask.style.display = "block";
	window.top.body.id="body0";
	gPopupContainer.style.display = "block";
	// calculate where to place the window on screen
	centerPopWin(width, height);
	
	var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);
	
	gPopupContainer.style.width = width + "px";
	gPopupContainer.style.height = (height+titleBarHeight) + "px";
	// need to set the width of the iframe to the title bar width because of the dropshadow
	// some oddness was occuring and causing the frame to poke outside the border in IE6
	gPopFrame.style.width = parseInt(document.getElementById("popupTitleBar").offsetWidth, 10) + "px";
	gPopFrame.style.height = (height) + "px";
	
	// set the url
	gPopFrame.src = url;
	
	gReturnFunc = returnFunc;
	// for IE
	if (gHideSelects == true) {
		hideSelectBoxes();
	}
	
	window.setTimeout("setPopTitle();", 10);
}

//
var gi = 0;
function centerPopWin(width, height) {
	if (gPopupIsShown == true) {
		if (width == null || isNaN(width)) {
			width = gPopupContainer.offsetWidth;
		}
		if (height == null) {
			height = gPopupContainer.offsetHeight;
		}
		
		var fullHeight = getViewportHeight();
		var fullWidth = getViewportWidth();
		
		var theBody = document.documentElement;
		
		var scTop = parseInt(theBody.scrollTop,10);
		var scLeft = parseInt(theBody.scrollLeft,10);
		
		gPopupMask.style.height = fullHeight + "px";
		gPopupMask.style.width = fullWidth + "px";
		gPopupMask.style.top = scTop + "px";
		gPopupMask.style.left = scLeft + "px";
		
		window.status = gPopupMask.style.top + " " + gPopupMask.style.left + " " + gi++;
		var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);
		
		gPopupContainer.style.top = (10) + "px";
		gPopupContainer.style.left =  (scLeft + ((fullWidth - width) / 2)) + "px";
		//alert(fullWidth + " " + width + " " + gPopupContainer.style.left);
	}
}
addEvent(window, "resize", centerPopWin);
//addEvent(window, "scroll", centerPopWin);
window.onscroll = centerPopWin;

/**
 * @argument callReturnFunc - bool - determines if we call the return function specified
 * @argument returnVal - anything - return value 
 */
function hidePopWin(callReturnFunc) {
	//alert(callReturnFunc);
	gPopupIsShown = false;
	restoreTabIndexes();
	if (gPopupMask == null) {
		return;
	}

	gPopupMask.style.display = "none";

	gPopupContainer.style.display = "none";
	
if (callReturnFunc == true && gReturnFunc != null) {
		gReturnFunc(window.frames["popupFrame"].returnVal);
	}
	gPopFrame.src = 'loading';
	// display all select boxes
	if (gHideSelects == true) {
		displaySelectBoxes();
	}
	if(document.getElementById('flash'))document.getElementById('flash').style.display="inline";
	window.top.body.id="";
	window.parent.location=window.top.location;
}
function OpenWin(redirect)
{
//alert(window.top.location);
	if(redirect=="blank")
	window.top.location.href=window.top.location;
	else
	window.top.location.href=redirect;
}
function scrollbars11()
{
	
}
/**
 * Sets the popup title based on the title of the html document it contains.
 * Uses a timeout to keep checking until the title is valid.
 */
function setPopTitle() {
	if (window.frames["popupFrame"].document.title == null) {
		window.setTimeout("setPopTitle();", 10);
	} else {
		//document.getElementById("popupTitle").innerHTML = window.frames["popupFrame"].document.title;
	}
}

// Tab key trap. iff popup is shown and key was [TAB], suppress it.
// @argument e - event - keyboard event that caused this function to be called.
function keyDownHandler(e) {
    if (gPopupIsShown && e.keyCode == 9)  return false;
}

// For IE.  Go through predefined tags and disable tabbing into them.
function disableTabIndexes() {
	if (document.all) {
		var i = 0;
		for (var j = 0; j < gTabbableTags.length; j++) {
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			for (var k = 0 ; k < tagElements.length; k++) {
				gTabIndexes[i] = tagElements[k].tabIndex;
				tagElements[k].tabIndex="-1";
				i++;
			}
		}
	}
	if(document.getElementById('flash')) document.getElementById('flash').style.display="none";
}

// For IE. Restore tab-indexes.
function restoreTabIndexes() {
	if (document.all) {
		var i = 0;
		for (var j = 0; j < gTabbableTags.length; j++) {
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			for (var k = 0 ; k < tagElements.length; k++) {
				tagElements[k].tabIndex = gTabIndexes[i];
				tagElements[k].tabEnabled = true;
				i++;
			}
		}
	}
}


/**
* Hides all drop down form select boxes on the screen so they do not appear above the mask layer.
* IE has a problem with wanted select form tags to always be the topmost z-index or layer
*
* Thanks for the code Scott!
*/
function hideSelectBoxes() {
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if(document.forms[i].elements[e].tagName == "SELECT") {
				document.forms[i].elements[e].style.visibility="hidden";
			}
		}
	}
}

/**
* Makes all drop down form select boxes on the screen visible so they do not reappear after the dialog is closed.
* IE has a problem with wanted select form tags to always be the topmost z-index or layer
*/
function displaySelectBoxes() {
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if(document.forms[i].elements[e].tagName == "SELECT") {
			document.forms[i].elements[e].style.visibility="visible";
			}
		}
	}
}

/***********************************************
* Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com)
* Copyright 2002-2007 by Sharon Paine
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* IMPORTANT: Put script after tooltip div or 
	 put tooltip div just before </BODY>. */

var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;

var origWidth, origHeight;

// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }

///////////////////////  CUSTOMIZE HERE   ////////////////////
// settings for tooltip 
// Do you want tip to move when mouse moves over link?
var tipFollowMouse= true;	
// Be sure to set tipWidth wide enough for widest image
var tipWidth= 160;
var offX= 20;	// how far from mouse to show tip
var offY= 12; 
var offz= 1; 
var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
var tipFontSize= "8pt";
// set default text color and background color for tooltip here
// individual tooltips can have their own (set in messages arrays)
// but don't have to
var tipFontColor= "#000000";
var tipBgColor= "#ffffff"; 
var tipBorderColor= "#ffffff";
var tipBorderWidth= 1;
var tipBorderStyle= "ridge";
var tipPadding= 4;

// tooltip content goes here (image, description, optional bgColor, optional textcolor)
//var messages = new Array();
// multi-dimensional arrays containing: 
// image and text for tooltip
// optional: bgColor and color to be sent to tooltip
/*messages[0] = new Array('Please give a real email address as we need to email you to confirm your account.',"");
messages[1] = new Array('Must be at least 6 characters long.',"");
messages[2] = new Array('Please give your first name.','');
messages[3] = new Array('Please give your high school name.','');
messages[4] = new Array('Please give a valid zip code.','');
messages[5] = new Array('Please mention your graduation year.','');*/

////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

// preload images that are to appear in tooltip
// from arrays above
/*if (document.images) {
	var theImgs = new Array();
	for (var i=0; i<messages.length; i++) {
  	theImgs[i] = new Image();
		theImgs[i].src = messages[i][0];
  }
}*/

// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
var startStr = '<table width="' + tipWidth + '">';
var midStr = '<tr><td valign="top">';
var endStr = '</td></tr></table>';

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip. 
//		Set styles
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
	if (nodyn) return;
	tooltip = (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = tooltip.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tipcss.width = tipWidth+"px";
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
	}
	if (tooltip&&tipFollowMouse) {
		document.onmousemove = trackMouse;
	}
}

window.onload = initTip;

/////////////////////////////////////////////////
//  doTooltip function
//			Assembles content for tooltip and writes 
//			it to tipDiv
/////////////////////////////////////////////////
var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
/*function doTooltip(evt,num) {
	if (!tooltip) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	// set colors if included in messages array
	if (messages[num][2])	var curBgColor = messages[num][2];
	else curBgColor = tipBgColor;
	if (messages[num][3])	var curFontColor = messages[num][3];
	else curFontColor = tipFontColor;
	if (ie4||ie5||ns5) {
		var tip = startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}*/

var mouseX, mouseY;
function trackMouse(evt) {
	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
	//mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	if (tipOn) positionTip(evt);
}

/////////////////////////////////////////////////////////////
//  positionTip function
//		If tipFollowMouse set false, so trackMouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position, 
//		offset amounts and tooltip width to position
//		tooltip within window.
/////////////////////////////////////////////////////////////
function positionTip(evt) {
	if (!tipFollowMouse) {
		mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
		//mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	}
	// tooltip width and height
	var tpWd = (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	// document area in view (subtract scrollbar width for ns)
	var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
	//var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
	// check mouse position against tip and window dimensions
	// and position the tooltip 
	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = mouseX-(tpWd+offX)+"px";
	else tipcss.left = mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = winHt-(tpHt+offY)+"px";
	else tipcss.top = mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}

document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>')




function popup_share()
{
	window.scroll(0,0);
	document.exampleForm.ajax_num.value = "0";
	showPopWin('/naadmin/newprintmat/',800,600, null);
	return false;
}

function popup_share_edit(id)
{
	
	window.scroll(0,0);
	//document.exampleForm.ajax_num.value = "0";
	document.getElementById("ajax_num").value = "0";
	showPopWin('/naadmin/editprintmat/'+id,800,600, null);
	//return false;
}
function popup_share_view(id)
{
	window.scroll(0,0);
	showPopWin('/naadmin/viewprintmat/'+id,800,600, null);
	//return false;
}
function popup_tomail_view(id)
{
	window.scroll(0,0);
	showPopWin('/naadmin/viewtomail/'+id,570,350, null);
	//return false;
}
function popup_alertmail_view(id)
{
	window.scroll(0,0);
	showPopWin('/naadmin/viewalertmail/'+id,570,350, null);
	//return false;
}
function orderemail(id)
{
	window.scroll(0,0);
	showPopWin('/naadmin/orderemail/'+id,656,570, null);
	//return false;
}
function viewnewsletter(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/viewnewsletter/'+id,670,570, null);
	//return false;
}
function forgetpassword()
{
	window.scroll(0,0);
	showPopWin('/cdd/forgetpassword',550,285, null);
	//showPopWin('/cdd/viewnewsletter/1',670,570, null);
	//return false;
}
function viewprintformdetails(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/viewprintformdetails/'+id,457,190, null);
	//showPopWin('/cdd/viewnewsletter/1',670,570, null);
	//return false;
}
function viewpartialdetails()
{
	window.scroll(0,0);
	showPopWin('/cdd/viewpartialdetails/',457,190, null);
	//showPopWin('/cdd/viewnewsletter/1',670,570, null);
	//return false;
}

// parser for cdd section

function address_valid()
{
	
	var addr = document.getElementById("naadmin_add1").value;
	var city = document.getElementById("naadmin_city").value;
	var state = document.getElementById("state").value;
	var zip = document.getElementById("naadmin_zip").value;
	var latlon = document.getElementById("latlon").value;
	//alert(state);
	if (addr == ""){
	alert("Please enter currect address");
	document.getElementById("naadmin_add1").focus();
	return false;
	}
	else if (zip==""){
	alert("please enter currect zip code");	
	document.getElementById("naadmin_zip").focus();
	return false;
	}
	else{
	
	window.scroll(0,0);
	showPopWin('/cdd/parser/?id2='+state+'&id3='+zip+'&city='+city+'&page=home1&latlon='+latlon+'&id4='+addr,700,550, null);
	return true;
	}
}
// for work address 
function workaddr_valid()
{
	
	var addr = document.getElementById("naadmin_work_add1").value;
	var city = document.getElementById("naadmin_work_city").value;
	var state = document.getElementById("work_state").value;
	var zip = document.getElementById("naadmin_work_zip").value;
	var latlon = document.getElementById("latlon").value;
	//alert(state);
	if (addr == ""){
	alert("Please enter currect address");
	document.getElementById("naadmin_work_add1").focus();
	return false;
	}
	else if (zip==""){
	alert("please enter currect zip code");	
	document.getElementById("naadmin_work_zip").focus();
	return false;
	}
	else{
	
	window.scroll(0,0);
	showPopWin('/cdd/parser/?id2='+state+'&id3='+zip+'&city='+city+'&page=work&latlon='+latlon+'&id4='+addr,700,550, null);
	return true;
	}
}
function gensub_address_valid()
{
	
	addr = document.getElementById("doctor_home_add").value;
	city = document.getElementById("doctor_home_city").value;
	state = document.getElementById("doctor_home_state").value;
	zip = document.getElementById("doctor_home_zip").value;
	latlon = document.getElementById("latlon").value;
	//alert(state);
	if (addr == ""){
	alert("Please enter currect address");
	document.getElementById("doctor_home_add").focus();
	return false;
	}
	else if (zip==""){
	alert("please enter currect zip code");	
	document.getElementById("doctor_home_zip").focus();
	return false;
	}
	else{
	
	window.scroll(0,0);
	showPopWin('/cdd/parser/?id2='+state+'&id3='+zip+'&city='+city+'&page=home1&latlon='+latlon+'&id4='+addr,700,550, null);
	return true;
	}
}
function memdetail(id)
{
	window.scroll(0,0);
	
	showPopWin('/cdd/memdetail/'+id,750,550, null);
	//return false;
}
function myofficial(id)
{
	window.scroll(0,0);
	
	showPopWin('/cdd/myofficial/'+id,750,550, null);
	//return false;
}
function vp()
{
	window.scroll(0,0);
	
	showPopWin('/cdd/vp_myofficial/',750,550, null);
	//return false;
}
function pre()
{
	window.scroll(0,0);
	
	showPopWin('/cdd/pr_myofficial/',750,550, null);
	//return false;
}
function genvp()
{
	window.scroll(0,0);
	
	showPopWin('/gen_subscriber/vp_myofficial/',750,550, null);
	//return false;
}
function genpre()
{
	window.scroll(0,0);
	
	showPopWin('/gen_subscriber/pr_myofficial/',750,550, null);
	//return false;
}
function genmyofficial(id)
{
	window.scroll(0,0);
	
	showPopWin('/gen_subscriber/myofficial/'+id,750,550, null);
	//return false;
}
function genmemdetail(id)
{
	window.scroll(0,0);
	
	showPopWin('/gen_subscriber/genmemdetail/'+id,750,550, null);
	//return false;
}
function address_valid_edit()
{
	
	var addr = document.getElementById("doctor_home_add").value;
	var city = document.getElementById("doctor_home_city").value;
	var state = document.getElementById("na_home_state").value;
	var zip = document.getElementById("doctor_home_zip").value;
	var latlon = document.getElementById("latlon").value;
	//alert(state);
	if (addr == ""){
	alert("Please enter currect address");
	document.getElementById("doctor_home_add").focus();
	return false;
	}
	else if (zip==""){
	alert("please enter currect zip code");	
	document.getElementById("doctor_home_zip").focus();
	return false;
	}
	else{
	
	window.scroll(0,0);
	showPopWin('/cdd/parser/?id2='+state+'&id3='+zip+'&city='+city+'&page=home1&latlon='+latlon+'&id4='+addr,600,550, null);
	return true;
	}
}

function workaddr_valid_edit()
{
	
	var addr = document.getElementById("doctor_office_add").value;
	var city = document.getElementById("doctor_city").value;
	var state = document.getElementById("na_state").value;
	var zip = document.getElementById("doctor_zip").value;
	var latlon = document.getElementById("latlon").value;
	//alert(state);
	if (addr == ""){
	alert("Please enter currect address");
	document.getElementById("doctor_office_add").focus();
	return false;
	}
	else if (zip==""){
	alert("please enter currect zip code");	
	document.getElementById("doctor_zip").focus();
	return false;
	}
	else{
	
	window.scroll(0,0);
	showPopWin('/cdd/parser/?id2='+state+'&id3='+zip+'&city='+city+'&page=work&latlon='+latlon+'&id4='+addr,600,550, null);
	return true;
	}
}
function commdetails(id)
{
	window.scroll(0,0);
	showPopWin('/naadmin/commdetails/'+id,455,290, null);
	
}
function view_history(id,type)
{
	window.scroll(0,0);
	showPopWin('/naadmin/view_history/'+id+"?id3="+type,595,350, null);	
}
function comm_details(id)
{
	window.scroll(0,0);
	
	showPopWin('/naadmin/oldcomm/'+id,750,550, null);
	//return false;
}

//function popup_share()
//{
//	window.scroll(0,0);
//	document.exampleForm.ajax_num.value = "0";
//	showPopWin('/naadmin/newprintmat',455,435, null);
//	return false;
//}

function popup_more(id)
{
	window.scroll(0,0);
	document.exampleForm.ajax_more.value = "0";
	
	showPopWin('/naadmin/moreinformation/'+id,455,350, null);
	return false;
}
function popup_other(id)
{
	window.scroll(0,0);
	document.exampleForm.ajax_other.value = "0";
	
	showPopWin('/naadmin/otherinformation/'+id,455,350, null);
	return false;
}
function comm_printmail(id,field)
{
		
	
		var legmem="";
		if(field.checked == true ){
			legmem =field.value;
			
		}
	else{
		for (i = 0; i < field.length; i++){
			if(field[i].checked == true ){
				if (legmem==""){
				legmem =field[i].value;
				}
				
			}
		}
	}
	
        if (legmem ==""){
               alert("Please check one recipient");
               return false;
         }else{
	var val = legmem.split(":");
	window.scroll(0,0);
	showPopWin('/cdd/comm_printmail/'+id+'?id2='+val[0]+'&email='+val[1],847,550, null);
         }
	
		//window.location.href ='/cdd/comm_printmail/'+id+'?id2='+val[0]+'&email='+val[1];
			
}

function gen_comm_printmail(id,field)
{
		
	
		var legmem="";
		if(field.checked == true ){
			legmem =field.value;
			
		}
	else{
		for (i = 0; i < field.length; i++){
			if(field[i].checked == true ){
				if (legmem==""){
				legmem =field[i].value;
				}
				
			}
		}
	}
	
        if (legmem ==""){
               alert("Please check one recipient");
               return false;
         }else{
	var val = legmem.split(":");
	window.scroll(0,0);
	showPopWin('/gen_subscriber/comm_printmail/'+id+'?id2='+val[0]+'&email='+val[1],847,550, null);
         }
	
		//window.location.href ='/cdd/comm_printmail/'+id+'?id2='+val[0]+'&email='+val[1];
			
}
function legmemdetails(id)
{
	window.scroll(0,0);
	
	showPopWin('/naadmin/legmemdetails/'+id,750,550, null);
	//return false;
}

function candidate_address_valid()
{
	
	var addr = document.getElementById("campn_addr_1").value;
	var city = document.getElementById("city").value;
	var state = document.getElementById("state").value;
	var latlon = document.getElementById("latlon").value;
	//zip = (document.getElementById("candidate_zip").value)+(document.getElementById("zip_last").value);
	var zip = document.getElementById("candidate_zip").value;
	if (addr == ""){
	alert("Please enter currect address");
	document.getElementById("campn_addr_1").focus();
	return false;
	}
	else if (zip==""){
	alert("please enter currect zip code");	
	document.getElementById("candidate_zip").focus();
	return false;
	}
	else{
	
	window.scroll(0,0);
	showPopWin('/cdd/parser/?id2='+state+'&id3='+zip+'&city='+city+'&page=candidate&latlon='+latlon+'&id4='+addr,700,550, null);
	return true;
	}
}
function enews_NA_address_valid()
{
	
	var addr = document.getElementById("news_add").value;
	var city = document.getElementById("news_city").value;
	var state = document.getElementById("news_state").value;
	var latlon = document.getElementById("latlon").value;
	//zip = (document.getElementById("candidate_zip").value)+(document.getElementById("zip_last").value);
	var zip = document.getElementById("news_zip").value;
	if (addr == ""){
	alert("Please enter currect address");
	document.getElementById("news_add").focus();
	return false;
	}
	else if (zip==""){
	alert("please enter currect zip code");	
	document.getElementById("news_zip").focus();
	return false;
	}
	else{
	
	window.scroll(0,0);
	showPopWin('/naadmin/parser/?id2='+state+'&id3='+zip+'&city='+city+'&page=enews&latlon='+latlon+'&id4='+addr,700,550, null);
	return true;
	}
}
function candidate_questionnaire(id2,id3)
{
	window.scroll(0,0);
	showPopWin('/cdd/candidate_questionnaire/'+id2+'?id3='+id3,900,550, null);
}

function question_send_email()
{
	window.scroll(0,0);
	showPopWin('/cdd/candidate_questionnaire_send',900,550, null);
	
}

function candidate_certificate_doc(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/candidate_certified_doc/'+id,850,550, null);
}
function candidate_certified_doc_edit(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/candidate_certified_doc_edit/'+id,850,550, null);
}
function campaign_banner(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/campaign_banner/'+id+"?id2=1",850,550, null);	
}

function campaign_flier(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/campaign_flier/'+id,850,550, null);	
}
function membership_certificate()
{
	window.scroll(0,0);
	showPopWin('/cdd/membership_certificate',910,550, null);	
}

function member_certificate_pcpa(field)
{
	var newlegmem = document.getElementById('idprintnew').value;
	//window.scroll(0,0);
	/*var legmem="";
	if(field.checked == true ){
		//alert(field.value);
			legmem =field.value;
			
		}
	else{
		for (i = 0; i < field.length; i++){
			if(field[i].checked == true ){
				
				if (legmem==""){
				legmem =field[i].value;
				}
				else{
				legmem =legmem+","+field[i].value;
				}
			}
		}
	}*/
	
        //if (legmem ==""){
        if(document.getElementById('idprintnew').value==""){
               alert("Please check one subscriber");
              // return false;
         }else{
		
	window.location.href = "/cdd/member_certificate_pcpa/"+newlegmem;
	//showPopWin('/cdd/member_certificate_pcpa/'+newlegmem,910,550, null);	
         }
	
}

function membership_certificate_edit()
{
	window.scroll(0,0);
	showPopWin('/cdd/membership_certificate_edit',850,550, null);
}

function member_certificate_pcpa_edit(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/member_certificate_pcpa_edit/'+id,850,550, null);
}
function campaign_flier_edit(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/campaign_flier_edit/'+id,850,550, null);
}
function start_balance_edit(id)
{
	window.scroll(0,0);
	showPopWin('/naadmin/editstartbalance/'+id,595,350, null);
}
function start_balance_delete(id)
{
   if(confirm("Are you sure to delete this record?"))	
   {
	window.scroll(0,0);
	showPopWin('/naadmin/deletestartbalance/'+id,595,350, null);
   }
   
}

function campaign_pcpa_sign(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/campaign_pcpa_sign_up/'+id,800,550, null);	
}
function announce_email(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/announce_email/'+id,845,550, null);	
}
function announce_email_edit(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/announce_email_edit/'+id,845,550, null);	
}
function announce_fax(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/announce_fax/'+id,845,550, null);	
}
function announce_fax_edit(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/announce_fax_edit/'+id,845,550, null);		
}
function announce_letter(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/announce_letter/'+id,845,550, null);	
}
function announce_letter_edit(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/announce_letter_edit/'+id,845,550, null);	
}
function candidate_certified_pat(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/candidate_certified_pat/'+id,900,550, null);
}
function candidate_certified_pat_edit(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/candidate_certified_pat_edit/'+id,900,550, null);
}
function ph_script_primary(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/ph_script_primary/'+id+"?id2=1",847,550, null);
}
function ph_script_general(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/ph_script_general/'+id+"?id2=1",847,550, null);		
}
function post_card(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/post_card/'+id+"?id2=1",847,550, null);		
}
function nauploadlogo(sid,lid)
{
   window.scroll(0,0);
   showPopWin('/naadmin/uploadlogo/'+lid+"?sid="+sid,455,235, null);
}
function uploadlogo(sid,lid)
{
   window.scroll(0,0);
   showPopWin('/saadmin/uploadlogo/'+lid+"?sid="+sid,455,235, null);
}
function uploadpage()
{
   window.scroll(0,0);
   showPopWin('/cdd/uploadpage/',445,245, null);
}
function uploadpagesa()
{
   window.scroll(0,0);
   showPopWin('/saadmin/uploadpage/',445,245, null);
}
function uploadpagena()
{
   window.scroll(0,0);
   showPopWin('/naadmin/uploadpage/',445,245, null);
}
function checksal()
{

document.getElementById('salut').style.display='block'
}

function nonechecksal()
{

document.getElementById('salut').style.display='none'
}


function announce_email_gensub(id)
{
   
	window.scroll(0,0);
	showPopWin('/gen_subscriber/announce_email/'+id,845,550, null);	
}

function announce_letter_gensub(id) {
     window.scroll(0,0);
	showPopWin('/gen_subscriber/announce_letter/'+id,845,550, null);	
}

function announce_fax_gensub(id) {
    window.scroll(0,0);
	showPopWin('/gen_subscriber/announce_fax/'+id,845,550, null);	
}

/* ************ saadmin communique section javascript ************************************************/

function comm_detailssa(id)
{
	window.scroll(0,0);
	//alert(id);
	showPopWin('/saadmin/oldcomm/'+id,750,550, null);
	//return false;
}

function popup_othersa(id)
{
	window.scroll(0,0);
	document.exampleForm.ajax_other.value = "0";
	
	showPopWin('/saadmin/otherinformation/'+id,455,350, null);
	return false;
}

function popup_moresa(id)
{
	window.scroll(0,0);
	document.exampleForm.ajax_more.value = "0";
	
	showPopWin('/saadmin/moreinformation/'+id,455,350, null);
	return false;
}

function popup_sharesa()
{
	window.scroll(0,0);
	document.exampleForm.ajax_num.value = "0";
	showPopWin('/saadmin/newprintmat',800,600, null);
	return false;
}

function popup_share_editsa(id)
{
	
	window.scroll(0,0);
	//document.exampleForm.ajax_num.value = "0";
	document.getElementById("ajax_num").value = "0";
	showPopWin('/saadmin/editprintmat/'+id,800,600, null);
	//return false;
}

function popup_alertmail_view_new(id)
{
       
	window.scroll(0,0);
        //alert('rrr');
        var alertSub = document.getElementById('alert_subject').value;
        var greetings1 = document.getElementById('greeting1').value;
        var greetings2 = document.getElementById('greeting2').value;
        var greetings3 = document.getElementById('greeting3').value;
        if(document.getElementById('statusfor').value == 'saadmins') {
                        showPopWin('/saadmin/viewalertmail/'+id+'?greeting1='+greetings1+'&greeting2='+greetings2+'&greeting='+greetings3+'&alert_subject='+alertSub+'&popupclosechk=0',570,360, null);
			//new Ajax.Updater('checkin','/saadmin/checkmaterial/'+id);
	 } else if(document.getElementById('statusfor').value == 'naadmins') {
                      showPopWin('/naadmin/viewalertmail/'+id+'?greeting1='+greetings1+'&greeting2='+greetings2+'&greeting='+greetings3+'&alert_subject='+alertSub+'&popupclosechk=0',570,360, null);
			//new Ajax.Updater('checkin','/naadmin/checkmaterial/'+id);
	 }
	//showPopWin('/naadmin/viewalertmail/'+id+'?greeting1='+greetings1+'&greeting2='+greetings2+'&greeting='+greetings3+'&alert_subject='+alertSub+'&popupclosechk=0',570,360, null);
	//return false;
}


function popup_share_viewsa(id)
{
	window.scroll(0,0);
	showPopWin('/saadmin/viewprintmat/'+id,800,600, null);
	//return false;
}

function popup_tomail_viewsa(id)
{
	window.scroll(0,0);
        if(document.getElementById('statusfor').value == 'saadmins') {
                       showPopWin('/saadmin/viewtomail/'+id,570,360, null);
			//new Ajax.Updater('checkin','/saadmin/checkmaterial/'+id);
	 } else if(document.getElementById('statusfor').value == 'naadmins') {
                      showPopWin('/naadmin/viewtomail/'+id,570,360, null);
			//new Ajax.Updater('checkin','/naadmin/checkmaterial/'+id);
	 }
	//showPopWin('/naadmin/viewtomail/'+id,570,360, null);
	//return false;
}

function commdetailssa(id)
{
	window.scroll(0,0);
	showPopWin('/saadmin/commdetails/'+id,455,290, null);
	
}

function legmemdetailssa(id)
{
	window.scroll(0,0);
	
	showPopWin('/saadmin/legmemdetails/'+id,750,550, null);
	//return false;
}

function uploadpagenadonation()
{
   window.scroll(0,0);
   showPopWin('/naadmin/uploadpagedonation/',445,245, null);
}


function view_membership_history(id,type,searchcriteria)
{
   //alert('/naadmin/view_membership_history/'+id+"?id3="+type+"&searchcriteria="+searchcriteria);
	window.scroll(0,0);
	showPopWin('/naadmin/view_membership_history/'+id+"?id3="+type+"&searchcriteria="+searchcriteria,595,350, null);	
}


function start_here(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/start_here/'+id,845,550, null);	
}

function start_here_edit(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/start_here_edit/'+id,845,550, null);		
}




function print_envelope_chk(id) {
   // var fname = document.getElementById('first_name').value;
   // var lname = document.getElementById('last_name').value;
   // var candoffposition = document.getElementById('candidate_office_position').value;
   // var campn_addr_1 = document.getElementById('campn_addr_1').value;
   // var campn_addr_2 = document.getElementById('campn_addr_2').value;
   // var city = document.getElementById('city').value;
   // var state = document.getElementById('state').value;
   // var candidate_zip = document.getElementById('candidate_zip').value;
   window.scroll(0,0);
   if(document.getElementById('chkPrintEnvelope').checked==true) {
      // var canimg = parent.document.getElementById('envelopephoto').value;
  //path = "/cdd/print_envelope_from_createcandidate/?fname="+fname+"&lname="+lname+"&candoffposition="+candoffposition+"&campn_addr_1="+campn_addr_1+"&campn_addr_2"+campn_addr_2+"&city="+city+"&state="+state+"&candidate_zip="+candidate_zip+"&canimg="+canimg;
  path = "/cdd/print_envelope_from_createcandidate/"+id;
			/*width = 900;
			height = 750;
			window.open(path,'mywindow',"width="+width+",height="+height+",resizable=yes,scrollbars=yes");*/
	
         window.location.href=path;
   }
  
   
   
}

function print_envelope_chk_edit(e) {
   //alert(e);
   var fname = document.getElementById('first_name').value;
   var lname = document.getElementById('last_name').value;
   var candoffposition = document.getElementById('candidate_office_position').value;
   var campn_addr_1 = document.getElementById('campn_addr_1').value;
   var campn_addr_2 = document.getElementById('campn_addr_2').value;
   var city = document.getElementById('city').value;
   var state = document.getElementById('state').value;
   var candidate_zip = document.getElementById('candidate_zip').value;
   //window.scroll(0,0);
   var canimg = document.getElementById('envelopephoto').value;
   if(document.getElementById('chkPrintEnvelope').checked==true) {
        path = "/cdd/print_envelope_from_editcandidate/"+e+"?fname="+fname+"&lname="+lname+"&candoffposition="+candoffposition+"&campn_addr_1="+campn_addr_1+"&campn_addr_2"+campn_addr_2+"&city="+city+"&state="+state+"&candidate_zip="+candidate_zip+"&canimg="+canimg;
   
  
                       window.location.href=path;
   }
      
	
   
   
}
function candidate_endorsement_announcement_old(id,id2,id3)
{
	window.scroll(0,0);
	//alert('/cdd/candidate_announcement_endorsement/'+id+'?id2='+id2+'&id3='+id3);
	showPopWin('/cdd/candidate_announcement_endorsement/'+id+'?id2='+id2+'&id3='+id3,900,550, null);
}
function endorsement_edit_old(id,id2,id3)
{
	window.scroll(0,0);
	//alert('/cdd/candidate_endorsement_edit/'+id+'?id2='+id2+'&id3='+id3);
	showPopWin('/cdd/candidate_endorsement_edit/'+id+'?id2='+id2+'&id3='+id3,900,550, null);
}
function candidate_endorsement_announcement(id,id2)
{
	window.scroll(0,0);
	//alert('/cdd/candidate_announcement_endorsement/'+id+'?id2='+id2+'&id3='+id3);
	showPopWin('/cdd/candidate_announcement_endorsement/'+id+'?id2='+id2,900,550, null);
}
function endorsement_edit(id,id2)
{
	window.scroll(0,0);
	//alert('/cdd/candidate_endorsement_edit/'+id+'?id2='+id2+'&id3='+id3);
	showPopWin('/cdd/candidate_endorsement_edit/'+id+'?id2='+id2,900,550, null);
}
function cand_stat(id)
{
	window.scroll(0,0);
	showPopWin('/cdd/candidate_stat/'+id,455,290, null);
	
}
/* added on 17.06.2010 for lagislative director link */
function legislator_printmail(legisid, field, user)
{		
	//alert(legisid);
	//alert(field);
	var x = 0;
	var legmem="";
	if(field.checked == true )
	{
		legmem =field.value;
		var x = x + 1;
	}
	else
	{	
		for (i = 0; i < field.length; i++)
		{
			if(field[i].checked == true)
			{
				var x = x + 1;
				if (legmem=="")
				{
					legmem =field[i].value;					
				}				
			}
		}
	}
	
	//alert(legmem);
    if (legmem =="")
	{
        alert("Please check one recipient");
        return false;
    }
	else if(x > 1)
	{
		alert("Please check only one recipient");
        return false;
	}
	else if(user == 'c')
	{
		var val = legmem.split(":");
        //window.location.href = "/cdd/comm_printmail/"+id+"?id2="+val[0]+"&email="+val[1];
		window.scroll(0,0);
		showPopWin('/cdd/legislator_printmail/?legisid='+legisid+'&id2='+val[0]+'&email='+val[1],847,550, null);
    }
	else
	{
		var val = legmem.split(":");
        //window.location.href = "/cdd/comm_printmail/"+id+"?id2="+val[0]+"&email="+val[1];
		window.scroll(0,0);
		showPopWin('/gen_subscriber/legislator_printmail/?legisid='+legisid+'&id2='+val[0]+'&email='+val[1],847,550, null);
    }	
}