/***********************************************/
/*insert archive magazine article*/
function checkInsertMagezineArticleForm()
{		
	if (document.insertMagArc.headline.value == '')
 	{   
    	alert("You have not filled in the headline field");
		document.insertMagArc.headline.focus();
    	return false;
   	}
	if (document.insertMagArc.content.value == '')
    {
       alert("You have not filled in the content field");
	   document.insertMagArc.content.focus();
       return false;
    }
	
	if (document.insertMagArc.mon.value == 0)
	{
		alert("You have not choose the magazine month");
		document.insertMagArc.mon.focus();
       	return false;
    }
	
	if (document.insertMagArc.year.value == 0)
	{
		alert("You have not choose the magazine year");
		document.insertMagArc.year.focus();
       	return false;
    }
	
	document.insertMagArc.effective_date.value = document.insertMagArc.mon.value + "/" + document.insertMagArc.year.value;		
} 

function showAssist(content, form) 
{
	if (content && content.isSelected) 
	{
		var str=content.selected.text;
		if (str=="") str=" ";
		if(str.indexOf(" ")!=-1)
			str = str.replace(" ","&nbsp;");
		if(str.indexOf("'")!=-1)
			str = str.replace("'","&rsquo;");
		if(str.indexOf("'")!=-1)
			str = str.replace("'","&rsquo;");		
		
		var str1=browserOcx1.showDialog (str,"\\\\file-srv\\utils\\tmassist\\configuration.xml");
		
		content.selected.text=str1;
		document.insertMagArc.content.focus();
	}
	else
	{
		sh=form.selected.value = '';
		sh1=browserOcx1.showDialog();
		document.form.callout.value=(document.form.callout.value+sh1);
	}
}

function getContent (textInput) 
{
	cont = new Object();
	if (document.selection) 
	{
		var selectedRange = document.selection.createRange();
		if (selectedRange.parentElement() == textInput) 
		{
			cont.isSelected = true;
			cont.selected = selectedRange.duplicate();
			cont.selected = selectedRange.duplicate();
			cont.beforeSelection = selectedRange.duplicate();
			cont.beforeSelection.moveToElementText(textInput);
			cont.beforeSelection.setEndPoint('EndToStart', selectedRange);
			cont.afterSelection = selectedRange.duplicate();
			cont.afterSelection.moveToElementText(textInput);
			cont.afterSelection.setEndPoint('StartToEnd', cont.selected);
		}
	}
	else 
	{
		cont = null;
	}
	return cont;
	document.insertMagArc.content.focus();
}

/*******************************************************/


/*check the value to search in the themarker archive*/
function checkSearchArticle()
{	
	if (document.searchArticle.searchText.value.length < 3){
		alert("חיפוש בארכיון חייב להכיל לפחות 3 אותיות");
		document.searchArticle.searchText.focus();	
		return false;		
	}
}

/********************************************************/
function bannerNew(noPosition,l1,l2,l3,l4,posSrcs,positionStr)
{
	var params = document.location.search.split("&");
	var pos = 0,sectionLayer="",check=false;
	for(var i=0;i<params.length;i++){
		if(params[i].split("=")[0] == "layer" || params[i].split("=")[0] == "?layer"){
			pos = i;
			check=true;
			break;
		}
	}	
	if(check)
		sectionLayer = params[pos].split("=")[1];
	else
		sectionLayer = "hp";
	var site = "themarker";
	var now = new Date();
	var RND = now.getSeconds();
	var frameUrl = "http://dclk"
	var domainName = new String(self.location);
	frameUrl += ".themarker.com/html.ng/site=" + site + "&sectionLayer=" + sectionLayer + "&adsize=" + posSrcs + "&" + (l1=="none"?"":"layer="+l1+"&") + (l2=="none"?"":"layer2="+l2+"&") + (l3=="none"?"":"layer3="+l3+"&") + (l4=="none"?"":"layer4="+l4+"&") + "adtype=hp&page_position=" + noPosition + "&Rnd=" + RND;
	document.write("<IFRAME " + positionStr + " MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR=000000 SRC=\"" + frameUrl + "\"></IFRAME>");
}

/**************************************************/
/*invite a magazine*/
function inviteMagSubmitForm()
{		
	if (inviteMagCheckMandatory())
    	document.inviteMag.submit()
	else
		return false;
}
 
function inviteMagCheckMandatory()
{
 	if (document.inviteMag.address.value=="")
 	{
  		alert("הזן שם פרטי בבקשה");
  		document.inviteMag.address.focus();
		return false;
 	}
 	else if (document.inviteMag.general.value=="")
 	{
  		alert("הזן שם משפחה בבקשה");
  		document.inviteMag.general.focus();
  		return false;
 	}
 	else if (document.inviteMag.phone.value=="")
 	{
  		alert("הזן מס' טלפון בבקשה");
  		document.inviteMag.phone.focus();
  		return false;
 	} 	
 	else if (document.inviteMag.phone1.value=="")
 	{
  		alert("הזן את קידומת הטלפון בבקשה");
  		document.inviteMag.phone1.focus();
  		return false;
 	} 	 	
  	else if(isNaN(document.inviteMag.phone.value) || document.inviteMag.phone.value.length<7 )
 	{
 		alert("אנא הזן מספר טלפון");
		document.inviteMag.phone.focus();
		return false;
 	}
	
	else if (document.inviteMag.email.value=="")
   	{ 
    	alert("הזן כתובת דואר אלקטרוני בבקשה");
		document.inviteMag.phone.focus();
	    return false;
	}
	else
	{
		var e=document.inviteMag.email.value;
	    ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
		for(i=0; i < e.length ;i++)
		{
			if(ok.indexOf(e.charAt(i))<0) 
			{ 
				alert("נא למלא כתובת דואר אלקטרוני תקני");
				return false;
			}	
		} 
		if (document.inviteMag.email.value.indexOf("@") == -1)
 		{
    		alert("נא למלא כתובת דואר אלקטרוני תקני");
		    return false;
   		}
		if (document.inviteMag.email.value.indexOf(".") == -1)
 		{
    		alert("נא למלא כתובת דואר אלקטרוני תקני");
    		return false;
   		}   
		return true;
	}
}

/*******************/
function waitLoadPage()
{	
	window.setInterval("load()", 360000);
}

function load()
{	
	document.location.reload();
}

function showMessageSoon(divName, num,isOver)
{	
	var par;
	var def;
	if (divName == 'msgSecFoot'){//footer
		par = 60;		
		if(screen.width == 800)
			def = 190;			
		else if(screen.width == 1024)
			def = 300; 
 
 		else if(screen.width == 1280)
	   		def = 430; 		
		else
			def = 0;
	}
	else{//header
		par = 70;
		def = 0;
	}
	if (isOver == true){		
		document.getElementById(divName).style.display='inline';				
		document.getElementById(divName).style.marginLeft=(5-num)*par+def;		
	}
	else{
		document.getElementById(divName).style.display='none';	
	}
}

function mouseOverSection(idName, num,isOver)
{
	if (isOver == true){		
		document.getElementById(idName+num).className = 'redBackSectionsMouseOver';
	}
	else{
		document.getElementById(idName+num).className = 'redBack';		
	}
}


function mouseOverButton(num,isOver)
{
	if (isOver == true)		
		document.getElementById("but"+num).className = 'redButtonMouseOver';
	else
		document.getElementById("but"+num).className = 'redButton';		
}

function mouseOverSearchArc(isOver)
{
	if (isOver == true)		
		document.getElementById("searchArc").className = 'redBack';
	else
		document.getElementById("searchArc").className = 'redBackSectionsMouseOver';		
}

/*  popup functions*/
 var scrollspeed = 0;
var speed, currentpos=0,curpos1=0,alt=1,curpos2=-1;
var maxScroll;
var oInterval="";


	
/* start scrolling pictures */ 								
function initialize()
{
	if (scrollspeed!=0)
	{
		speed=scrollspeed;
		scrollwindow();
	}
}

function changeScrollSpeed(theSpeed)
{
	scrollspeed=theSpeed;
	oInterval=setInterval("initialize()",25);	
}

var state=1;
var flagRight=0;
var flagLeft=0;
function scrollwindow()
{
	maxScroll = document.getElementById("galleries").scrollLeft;			
	document.getElementById("galleries").scrollLeft=document.getElementById("galleries").scrollLeft+speed;	
	
	switch(state)
	{  
	  //initialized state: < - white  > - light white
	  case 1:	  
	    if(speed<0) //going left
		{
		  state=2;
		  document.getElementById("arrowL").src='/i/Nav_But_Left_Over.gif'; //paint left arrow in red
		  document.getElementById("arrowR").src='/i/Nav_But_Right.gif'; //paint right arrow in white
		  document.getElementById("arrowR").filters.item("DXImageTransform.Microsoft.Alpha").opacity = 100;
		  document.getElementById("arrowR").style.cursor='Hand'; 
		  //alert("in case 1 - going left");
		}
	  break;
	  case 2: //state: < - red  > - white	  
	    if(speed==0)
		{ 
		  state=4;
		  document.getElementById("arrowL").src='/i/Nav_But_Left.gif'; //paint left arrow in white
		}
		else if (speed>0) //going right
		{
		   state=3;
		   document.getElementById("arrowL").src='/i/Nav_But_Left.gif'; //paint left arrow in white
		   document.getElementById("arrowR").src='/i/Nav_But_Right_Over.gif'; //paint right arrow in red
		}
		else //going left
		{
		  if(document.getElementById("galleries").scrollLeft == 0)  //if reached the end of left side of  the scroll
		  {
		  	window.clearInterval(oInterval);
		   state=5;
		   document.getElementById("arrowL").src='/i/Nav_But_Left.gif';  //paint left arrow in light white
		   document.getElementById("arrowL").filters.item("DXImageTransform.Microsoft.Alpha").opacity = 25;
		   document.getElementById("arrowL").style.cursor='default';
		  }
		}
	  break;
	  case 3: // <-white >-red	  
	    if(speed==0)
		{ 
		  state=4;
		  document.getElementById("arrowR").src='/i/Nav_But_Right.gif'; //paint right arrow in white
		}
		else if (speed>0) //going right
		{
			
		   	if(maxScroll == document.getElementById("galleries").scrollLeft && maxScroll != 0) //if reached the end of right side of  the scroll
		    {
				window.clearInterval(oInterval);								
			 state=1;
			 document.getElementById("arrowR").style.cursor='default';
			 document.getElementById("arrowR").src='/i/Nav_But_Right.gif';
			 document.getElementById("arrowR").filters.item("DXImageTransform.Microsoft.Alpha").opacity = 25;
			 //alert ("in case 3 going right end");
   			 }
		}
		else //going left
		{
		  state=2;
		  document.getElementById("arrowL").src='/i/Nav_But_Left_Over.gif'; //paint left arrow in red
		  document.getElementById("arrowR").src='/i/Nav_But_Right.gif'; //paint right arrow in white
		 } 
	  break;
	  case 4: //onmouseout	  
	   if (speed==0)
	    return;
		else if (speed>0) //going right
		{
		   	state=3;
		    document.getElementById("arrowR").src='/i/Nav_But_Right_Over.gif'; //paint right arrow in red
			
		}
		else //going left
		{
		 state=2;
		 document.getElementById("arrowL").src='/i/Nav_But_Left_Over.gif'; //paint left arrow in red
		}
	  break;
	  case 5: //<-light white >-white	  
	   	if (speed>0) // going right  
		{
			state=3;
		    document.getElementById("arrowR").src='/i/Nav_But_Right_Over.gif'; //paint right arrow in red
			document.getElementById("arrowL").filters.item("DXImageTransform.Microsoft.Alpha").opacity = 100;
			document.getElementById("arrowL").style.cursor='Hand';
		}		
	  break;//end case 5
    }//end switch
			
}
function stopScroll()
{ 
	window.clearInterval(oInterval);
  switch(state)
	{  
	  //initialized state: < - white  > - light white
	  case 1:
	  {	    
		return;		
	  }
	  case 2: //state: < - red  > - white
	  {
	      state=4;
		  document.getElementById("arrowL").src='/i/Nav_But_Left.gif'; //paint left arrow in white
	  }
	  case 3: // <-white >-red
	  {
	      state=4;
		  document.getElementById("arrowR").src='/i/Nav_But_Right.gif'; //paint right arrow in white
	  }
	  case 4: //onmouseout
	  {	   
	    return;		
	  }
	  case 5: //<-light white >-white
	  {	
	    return;
	  }//end case 5
    }//end switch

}

/* change magazine details */
function changeMagazineDetails(number,date,title,subTitle)
{
	document.getElementById("magazineNumber").innerHTML=" מגזין מס&rsquo; " + number + " | " + date;
	document.getElementById("magazineTitle").innerHTML=title;
	document.getElementById("magazineSubTitle").innerHTML=subTitle;
}

/*print article*/	
function printDoc()
{
	window.print()
}

function changeSize()
{
 	window.resizeTo(730,620);	
}
