
// this function shows a popup window for an offer
function popOffer(offer_link, offer_title){

	var win_height = 350;//window.screen.height/2;
	var win_width = 1000;//(window.screen.width/4)*3;

	// set width and heights if not already set
	if ( !( win_height ) ) {
			win_height = 500;
	}

	if ( !( win_width ) ) {
			win_width = 500;
	}

  // show the popup window
  var popup_window =  window.open(
		offer_link,
		'popupWindow'+Math.floor(Math.random()*1111),'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+win_width+',height='+win_height+',screenX=50,screenY=50,top=50,left=50'
);

//  popup_window.title = "OptimizeRx - " + offer_title;
  return false;
}

var linkylink = 'none';
// show the offer link
function setPopupOffers(){
	offer_links = getElementsByClass('offer_link',null,'a');
	for ( offer in offer_links ) {

		offer_links[offer].onclick = function () {
			popOffer(this.href,this.title);
			return false;
		}

	}
}
// show the offer link
function setLoggedOutPopupOffers(){ 
	offer_links = getElementsByClass('offer_link',null,'a');
	for ( offer in offer_links ) {

		offer_links[offer].onclick = function () { 
			//popOffer(this.href,this.title);
                    linkylink = this.href;
                    document.getElementById('linkylinkylink').value=this.href;
                        document.getElementById('shadowdiv').style.display='block';
                      //  document.getElementById('shadowdiv_inside').style.display='block';
			return false; 
		}
	}
}

// sets the "tell a friend" window
function popupTellFriend(){

	var win_height = 463;
	var win_width = 375;
	var popup_link = '/tell-a-friend/';
	var popup_title = 'Tell a Friend';

  var popup_window =  window.open(
		popup_link,
		'popupWindow',	'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+win_width+',height='+win_height+',screenX=150,screenY=150,top=150,left=150'
);
  
}

// sets the "tell a friend" window
function popupFeedback(){

	var win_height = 463;
	var win_width = 375;
	var popup_link = '/feedback/';
	var popup_title = 'Submit Feedback';

  var popup_window =  window.open(
		popup_link,
		'popupWindow',	'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+win_width+',height='+win_height+',screenX=150,screenY=150,top=150,left=150'
);
  
}

// sets up a generic popup window
function popup(popup_link, popup_title){

	var win_height = 500;
	var win_width = 500;

  var popup_window =  window.open(
		popup_link,
		'popupWindow',	'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+win_width+',height='+win_height+',screenX=150,screenY=150,top=150,left=150'
);

  //popup_window.title = "OptimizeRx - " + popup_title;
  return false;
}

// sets different popups for big or small popup windows
function setPopups(){
	popup_links = getElementsByClass('popup',null, 'a');
	for ( popups in popup_links ) {

		popup_links[popups].onclick = function () {
			popup(this.href,this.title);
			return false;
		}
		
	}

	popup_links = getElementsByClass('big_popup',null, 'a');
	for ( popups in popup_links ) {

		popup_links[popups].onclick = function () {
			popOffer(this.href,this.title);
			return false;
		}
		
	}
}


function offerLinkDropdown(link) {

  linkylink = link;
  document.getElementById('linkylinkylink').value=this.href;
  document.getElementById('shadowdiv').style.display='block';

}

