


// JavaScript Document
	

	var SITE_ROOT = "http://share.mysourcefor.org/";
	//var SITE_ROOT = document.site_root;
	
/*
	curr_location = window.location.href;
	//alert(curr_location);


	
	if(curr_location.indexOf("?")>0){
		//alert("Got a QS");
		var link = curr_location + "&";
	}else{
		var link = curr_location + "?";
	}
	//alert(document.getElementById('search_link'));
	//document.getElementById('search_link').href = link + document.getElementById('search_link').href;
*/



	
	
//**************************************************************************************************************
//**************************************************************************************************************
//**************************************************************************************************************

	function callModule(org_id, broadcast_id, start_page, xtra_params, div_id, no_font){
		
		
		if(div_id!=null){
				div_id = div_id;
			}else{
				div_id = "ikshare_dyn_div";
			}
			
			
			if(start_page==null){
					start_page = 0;					
				};
			var params = ("&org_id="+org_id+"&broadcast_id="+broadcast_id+"&page="+start_page+"&agent="+navigator.userAgent + "&" + xtra_params + "&div_id=ikshare_dyn_content&referer=" + window.location) +"&"+ location.search.substring(1);
			document.write('<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4abd04526186b36a"></script>');
			document.write("<link href='"+SITE_ROOT+"inc_ikshare.css' rel='stylesheet' type='text/css'/>");
			document.write("<div class='ikshare_dyn_content' id='ikshare_dyn_content'></div>"); // Added this so Netscape 7.2 would work
			var html_str = '<script type="text/javascript" language="javascript" src="'+SITE_ROOT+'inc_ikshare_handler.php?'+params+'"></script>';
			document.write(html_str);
			document.write('<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script><script type="text/javascript">_uacct="UA-3986641-1";urchinTracker();</script>');
	};
	

	
//**************************************************************************************************************
//**************************************************************************************************************
//**************************************************************************************************************


	
	function popUp(center,url,winName,width,height,features) {
		//'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes'
		
		if (center) {
			x = (640 - width)/2, y = (480 - height)/2;
			if (screen) {
				y = (screen.availHeight - height)/2;
				x = (screen.availWidth - width)/2;
			}
		}
		var newWin = window.open(url,winName,'scrollbars=no,width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+','+features);
		newWin.focus();
	}
	




	
//**************************************************************************************************************
//**************************************************************************************************************
//**************************************************************************************************************






	

	function MM_jumpMenu(targ,selObj,restore){ //v3.0
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
	}	
		
	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_validateForm() { //v4.0
	  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
		if (val) { nm=val.name; if ((val=val.value)!="") {
		  if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
			if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
		  } else if (test!='R') { num = parseFloat(val);
			if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
			if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
			  min=test.substring(8,p); max=test.substring(p+1);
			  if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
		} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
	  } if (errors) alert('The following error(s) occurred:\n'+errors);
	  document.MM_returnValue = (errors == '');
	}
	function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
	}
	
	
	
//function Validate_String(string, return_invalid_chars)
//         {
//         valid_chars = '1234567890-_.^~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
//         invalid_chars = '';
//         
//         if(string == null || string == '')
//            return(true);
//         
//         //For every character on the string.   
//         for(index = 0; index < string.length; index++){
//            char = string.substr(index, 1);                        
//            
//            //Is it a valid character?
//            if(valid_chars.indexOf(char) == -1){
//              //If not, is it already on the list of invalid characters?
//              if(invalid_chars.indexOf(char) == -1){
//                //If it's not, add it.
//                if(invalid_chars == ''){
//                   invalid_chars += char;
//				}else{
//                   invalid_chars += ', ' + char;
//                }
//              }
//            }                     
//            
//         //If the string does not contain invalid characters, the function will return true.
//         //If it does, it will either return false or a list of the invalid characters used
//         //in the string, depending on the value of the second parameter.
//         if(return_invalid_chars == true && invalid_chars != '')
//           {
//           last_comma = invalid_chars.lastIndexOf(',');
//           
//           if(last_comma != -1)
//              invalid_chars = invalid_chars.substr(0, $last_comma) + 
//              ' and ' + invalid_chars.substr(last_comma + 1, invalid_chars.length);
//                      
//           return(invalid_chars);
//           }
//         else
//           return(invalid_chars == ''); 
//         }


function Validate_Email_Address(email_address)
         {
//         //Assumes that valid email addresses consist of user_name@domain.tld
//         at = email_address.indexOf('@');
//         dot = email_address.indexOf('.');
//         
//         if(at == -1 || 
//            dot == -1 || 
//            dot <= at + 1 ||
//            dot == 0 || 
//            dot == email_address.length - 1)
//            return(false);
//            
//         user_name = email_address.substr(0, at);
//         domain_name = email_address.substr(at + 1, email_address.length);                  
//         
//         if(Validate_String(user_name) === false || 
//            Validate_String(domain_name) === false)
//            return(false);                     
//         
//         return(true);



   return (email_address.indexOf(".") > 2) && (email_address.indexOf("@") > 0);
 




         }	
	
	
	function checkFormPage5(site_root){
	allGood=true;
		if(document.formPage5.checkbox.checked==false){
			MM_swapImage('required01','',site_root+'images/page_parts/white_required_arrow.gif',1);
			document.formPage5.required01.width = 10;
			allGood=false;
			}else{
			MM_swapImage('required01','',site_root+'images/page_parts/white_required_blank.gif',1);
			document.formPage5.required01.width = 1;
			};
		if(document.formPage5.submission_name.value==''){
			MM_swapImage('required02','',site_root+'images/page_parts/white_required_arrow.gif',1);	
			document.formPage5.required02.width = 10;
			allGood=false;
			}else{
			MM_swapImage('required02','',site_root+'images/page_parts/white_required_blank.gif',1);	
			document.formPage5.required02.width = 1;
			};
		if(document.formPage5.submission_location.value==''){
			MM_swapImage('required03','',site_root+'images/page_parts/white_required_arrow.gif',1);	
			document.formPage5.required03.width = 10;
			allGood=false;
			}else{
			MM_swapImage('required03','',site_root+'images/page_parts/white_required_blank.gif',1);	
			document.formPage5.required03.width = 1;
			};
		if(!Validate_Email_Address(document.formPage5.submission_email.value)){
			MM_swapImage('required04','',site_root+'images/page_parts/white_required_arrow.gif',1);	
			document.formPage5.required04.width = 10;
			allGood=false;
			}else{
			MM_swapImage('required04','',site_root+'images/page_parts/white_required_blank.gif',1);	
			document.formPage5.required04.width = 1;
			};
		// INIT STRING - - - - - - - - >
		message_str = ""; 
		if(allGood==true){
			return true;
		}else{
			alert("Some of the required fields in this page were not filled out."+message_str);
			return false;		
		};
	};
	
	function checkFormPage6(site_root){
	allGood=true;
		if(document.formPage6.submission_title.value==''){
			MM_swapImage('required01','',site_root+'images/page_parts/white_required_arrow.gif',1);	
			document.formPage6.required01.width = 10;
			allGood=false;
			}else{
			MM_swapImage('required01','',site_root+'images/page_parts/white_required_blank.gif',1);	
			document.formPage6.required01.width = 1;
			};
		if(document.formPage6.submission_short_desc.value==''){
			MM_swapImage('required02','',site_root+'images/page_parts/white_required_arrow.gif',1);	
			document.formPage6.required02.width = 10;
			allGood=false;
			}else{
			MM_swapImage('required02','',site_root+'images/page_parts/white_required_blank.gif',1);	
			document.formPage6.required02.width = 1;
			};
		if(document.formPage6.submission_type_id.value==1){
			if(document.formPage6.submission_full_story.value==''){
				MM_swapImage('required03','',site_root+'images/page_parts/white_required_arrow.gif',1);	
				document.formPage6.required03.width = 10;
				allGood=false;
				}else{
				MM_swapImage('required03','',site_root+'images/page_parts/white_required_blank.gif',1);	
				document.formPage6.required03.width = 1;
				};
		};
		if(document.formPage6.submission_type_id.value==4){
			if(document.formPage6.submission_vid_embed.value==''){
				MM_swapImage('required04','',site_root+'images/page_parts/white_required_arrow.gif',1);	
				document.formPage6.required04.width = 10;
				allGood=false;
				}else{
				MM_swapImage('required04','',site_root+'images/page_parts/white_required_blank.gif',1);	
				document.formPage6.required04.width = 1;
				};
		};
		// INIT STRING - - - - - - - - >
		message_str = ""; 
		if(allGood==true){
			return true;
		}else{
			alert("Some of the required fields in this page were not filled out."+message_str);
			return false;		
		};
	};
	
	
	function checkFormPage7(site_root){
	allGood=true;
	message_str="";
	
	var img1 = new Image();
  	img1.src = document.formPage7.browse_image.value;
  	var img1width = parseInt(img1.width);
  	var img1height = parseInt(img1.height);
  
	//alert("This is image Test \n Width : " + img1width + "\n Height : " + img1height );

	if(document.formPage7.browse_image.value!=''){	
			
			//alert("document.formPage7.browse_image.value!=''");
			
			if(document.formPage7.browse_image.value.indexOf(".jpg", 0) == -1){
				message_str += "\n\nAdditionally your digital photo must be a Jpeg with a lowercase '.jpg' file extension."; 
				allGood=false;
				};
			
			if(document.formPage7.privacy.checked==false){
				MM_swapImage('required01','',site_root+'images/page_parts/white_required_arrow.gif',1);	
				document.formPage7.required01.width = 10;
				allGood=false;
				}else{
				MM_swapImage('required01','',site_root+'images/page_parts/white_required_blank.gif',1);	
				document.formPage7.required01.width = 1;
				};
		};

			
		// INIT STRING - - - - - - - - >
		//message_str = ""; 
		if(allGood==true){
			return true;
		}else{
			alert("Some of the required fields in this page were not filled out."+message_str);
			return false;		
		};
	};	
	
	
	function checkFormResources() {
		alert_pcs = new Array;
		alert_items = new Array;
		if (document.form1.resource_status[0].checked == false && document.form1.resource_status[1].checked == false) {
			alert_pcs[alert_pcs.length] = "- Enable";
			alert_items[alert_items.length] = 'resource_title_1'; //focus near radio
		}  			
		if (document.form1.resource_title_1.value == "") {
			alert_pcs[alert_pcs.length] = "- Linked name (line 1)";
			alert_items[alert_items.length] = 'resource_title_1';
		}	
		if (alert_pcs.length > 0) {
			alert("Your information has NOT been submitted. \n\nPlease provide information for the following fields:\n\n" + alert_pcs.join("\n"));
			document.form1[alert_items[0]].focus();
			return false;
		}
	}
	
	function checkFormResources() {
		alert_pcs = new Array;
		alert_items = new Array;
		if (document.form1.resource_status[0].checked == false && document.form1.resource_status[1].checked == false) {
			alert_pcs[alert_pcs.length] = "- Enable";
			alert_items[alert_items.length] = 'resource_title_1'; //focus near radio
		}  			
		if (document.form1.resource_title_1.value == "") {
			alert_pcs[alert_pcs.length] = "- Linked name (line 1)";
			alert_items[alert_items.length] = 'resource_title_1';
		}	
		if (alert_pcs.length > 0) {
			alert("Your information has NOT been submitted. \n\nPlease provide information for the following fields:\n\n" + alert_pcs.join("\n"));
			document.form1[alert_items[0]].focus();
			return false;
		}
	}
	
	function checkFormSubmissions() {
		alert_pcs = new Array;
		alert_items = new Array;
		if (document.form1.submission_vetted[0].checked == false && document.form1.submission_vetted[1].checked == false && document.form1.submission_vetted[2].checked == false) {
			alert_pcs[alert_pcs.length] = "- State";
			alert_items[alert_items.length] = 'submission_title'; //focus near radio
		}  			
		if (document.form1.submission_title.value == "") {
			alert_pcs[alert_pcs.length] = "- Story Title";
			alert_items[alert_items.length] = 'submission_title';
		}	
		if (alert_pcs.length > 0) {
			alert("Your information has NOT been submitted. \n\nPlease provide information for the following fields:\n\n" + alert_pcs.join("\n"));
			document.form1[alert_items[0]].focus();
			return false;
		}
	}	
	
	function checkFormComments() {
		alert_pcs = new Array;
		alert_items = new Array;
		if (document.form1.comment_vetted[0].checked == false && document.form1.comment_vetted[1].checked == false && document.form1.comment_vetted[2].checked == false) {
			alert_pcs[alert_pcs.length] = "- State";
			alert_items[alert_items.length] = 'comment_date'; //focus near radio
		}  			
		if (document.form1.comment_name.value == "") {
			alert_pcs[alert_pcs.length] = "- Name";
			alert_items[alert_items.length] = 'comment_name';
		}	
		if (document.form1.comment_comment.value == "") {
			alert_pcs[alert_pcs.length] = "- Comment";
			alert_items[alert_items.length] = 'comment_comment';
		}			
		if (alert_pcs.length > 0) {
			alert("Your information has NOT been submitted. \n\nPlease provide information for the following fields:\n\n" + alert_pcs.join("\n"));
			document.form1[alert_items[0]].focus();
			return false;
		}
	}		
	
	
//**************************************************************************************************************
//**************************************************************************************************************
//**************************************************************************************************************





/*********************************************************************************
  dw_cookies.js - cookie functions for www.dyn-web.com
  Recycled from various sources 
**********************************************************************************/
	
	// Modified from Bill Dortch's Cookie Functions (hidaho.com) 
	// (found in JavaScript Bible)
	function setCookie(name,value,days,path,domain,secure) {
	  var expires, date;
	  if (typeof days == "number") {
		date = new Date();
		date.setTime( date.getTime() + (days*24*60*60*1000) );
			expires = date.toGMTString();
	  }
	  document.cookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	}
	
	// Modified from Jesse Chisholm or Scott Andrew Lepera ?
	// (found at both www.dansteinman.com/dynapi/ and www.scottandrew.com/junkyard/js/)
	function getCookie(name) {
	  var nameq = name + "=";
	  var c_ar = document.cookie.split(';');
	  for (var i=0; i<c_ar.length; i++) {
		var c = c_ar[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
	  }
	  return null;
	}
	
	// from Bill Dortch's Cookie Functions (hidaho.com) 
	function deleteCookie(name,path,domain) {
	  if (getCookie(name)) {
		document.cookie = name + "=" +
		  ((path) ? "; path=" + path : "") +
		  ((domain) ? "; domain=" + domain : "") +
		  "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	  }
	}
	
	
	
	function toggle_link_type(input) {
		var row_url = document.getElementById('row_resource_link_type_url');
		var row_pdf = document.getElementById('row_resource_link_type_pdf');
		if (input.id == "input_link_type_url") {
			row_pdf.style.display='';
			row_url.style.display='none';
		} else {
			row_pdf.style.display='none';
			row_url.style.display='';
		}
	}	
	


