// JavaScript Document
	var SITE_ROOT = "http://storyshare.mysourcefor.org/";


		function init(join_org_broadcast_id, page){
			page = (page==null) ? page = 0 : page = page ;
			var params = ("join_org_broadcast_id="+join_org_broadcast_id+"&page="+page+"&div_id=share_dyn_content&"+ location.search.substring(1));
			$('head').append('<script type="text/javascript" language="javascript" src="'+SITE_ROOT+'assets/php/inc_share_handler.php?header=0&div_id=share_dyn_content&'+params+'"></script>');
			document.write("<div id='share_dyn_content'></div>");
			$('head').append('<script type="text/javascript" language="javascript" src="'+SITE_ROOT+'assets/php/inc_share_handler.php?header=1&'+params+'&div_id=share_head"></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 checkFormPage5(site_root){
	allGood=true;
		if(document.formPage5.checkbox.checked==false){
			MM_swapImage('required01','',site_root+'assets/img/page_parts/white_required_arrow.gif',1);
			document.formPage5.required01.width = 10;
			allGood=false;
			}else{
			MM_swapImage('required01','',site_root+'assets/img/page_parts/white_required_blank.gif',1);
			document.formPage5.required01.width = 1;
			};
		if(document.formPage5.submission_name.value==''){
			MM_swapImage('required02','',site_root+'assets/img/page_parts/white_required_arrow.gif',1);	
			document.formPage5.required02.width = 10;
			allGood=false;
			}else{
			MM_swapImage('required02','',site_root+'assets/img/page_parts/white_required_blank.gif',1);	
			document.formPage5.required02.width = 1;
			};
		if(document.formPage5.submission_location.value==''){
			MM_swapImage('required03','',site_root+'assets/img/page_parts/white_required_arrow.gif',1);	
			document.formPage5.required03.width = 10;
			allGood=false;
			}else{
			MM_swapImage('required03','',site_root+'assets/img/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+'assets/img/page_parts/white_required_arrow.gif',1);	
			document.formPage5.required04.width = 10;
			allGood=false;
			}else{
			MM_swapImage('required04','',site_root+'assets/img/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+'assets/img/page_parts/white_required_arrow.gif',1);	
			document.formPage6.required01.width = 10;
			allGood=false;
			}else{
			MM_swapImage('required01','',site_root+'assets/img/page_parts/white_required_blank.gif',1);	
			document.formPage6.required01.width = 1;
			};
		if(document.formPage6.submission_short_desc.value==''){
			MM_swapImage('required02','',site_root+'assets/img/page_parts/white_required_arrow.gif',1);	
			document.formPage6.required02.width = 10;
			allGood=false;
			}else{
			MM_swapImage('required02','',site_root+'assets/img/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+'assets/img/page_parts/white_required_arrow.gif',1);	
				document.formPage6.required03.width = 10;
				allGood=false;
				}else{
				MM_swapImage('required03','',site_root+'assets/img/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+'assets/img/page_parts/white_required_arrow.gif',1);	
				document.formPage6.required04.width = 10;
				allGood=false;
				}else{
				MM_swapImage('required04','',site_root+'assets/img/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+'assets/img/page_parts/white_required_arrow.gif',1);	
				document.formPage7.required01.width = 10;
				allGood=false;
				}else{
				MM_swapImage('required01','',site_root+'assets/img/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;
		}
	}		
	
	
//**************************************************************************************************************
//**************************************************************************************************************
//**************************************************************************************************************
