function nominate( issue_id, issue_data ) {
// initialize some stuff
defined(window.nominations) ? null : window.nominations = [];
defined(window.origdivs) ? null : window.origdivs = [];
var f = document.forms.nominees ;
// check a few things
if (isNaN(issue_id))
{ alert('Error(nominate): issue_id is not a number!'); return; }
if ( in_array( issue_id, window.nominations ) )
{ alert('You already have nominated this issue. Please pick a different one!'); return; }
if ( f.length >= 5 )
{ alert('You have reached your limit for nominations!\nPlease press submit to continue.'); return; }
// Okay lets go!
var nextpick = next_free_nomination() ;
window.nominations[nextpick] = issue_id ;
var el = document.createElement('INPUT');
el.type = 'hidden'; el.name = 'nominee['+issue_id+']'; el.value = issue_data ;
f.appendChild(el);
var nominee_div = document.getElementById('nominee'+nextpick);
img = document.getElementById('IMG'+issue_id).cloneNode(true) ;
title = document.getElementById('TITLE'+issue_id).cloneNode(true);
img.style.border = '1px solid #cccccc';
window.origdivs[issue_id] = {
img_div: nominee_div.replaceChild( img, nominee_div.getElementsByTagName('IMG')[0] ) ,
title_div: nominee_div.replaceChild( title, nominee_div.getElementsByTagName('DIV')[0] )
}
}
function drop_nominee() {
// get issue_id from IMG element
var nom_div = this.parentNode;
var img_id = nom_div.getElementsByTagName('IMG')[0].id ;
var issue_id = parseInt( img_id.match(/(\d+)/) );
// remove nominee from from and restore original default stuff
var f = document.forms.nominees, f_elements = f.getElementsByTagName('INPUT') ;
var nom_id = 'nominee['+issue_id+']' ;
for ( var i in f_elements )
if ( f_elements[i].name == nom_id ) {
f.removeChild( f_elements[i] ); // remove from form
for ( var j in window.nominations ) // remove from nominations list
if ( window.nominations[j] == issue_id )
{ delete window.nominations[j]; break; }
// remove visually
nom_div.replaceChild( window.origdivs[issue_id].img_div, nom_div.getElementsByTagName('IMG')[0] );
nom_div.replaceChild( window.origdivs[issue_id].title_div, nom_div.getElementsByTagName('DIV')[0] );
break;
}
}
// find next available nominee slot
function next_free_nomination() {
if ( !defined(window.nominations) ) return null;
var ret = -1 ;
for ( var i=0; i<5 && ret<0; i++ )
ret = ( !window.nominations[i] ) ? i : -1 ;
return ret;
}
// submit the nominations
function submit_nominations(limit) {
var len = document.forms.nominees.length ;
if ( len == 0 )
{ alert('Sorry, but you have not nominated any covers yet!'); return false; }
if ( len < limit )
{ alert('Sorry, but you have not finished your nominations!'); return false; }
document.forms.nominees.submit();
}
function iehack_toggle_display(e) {
if ( typeof e == 'object' && defined(browser) && browser.isIE )
e.style.display = ( e.style.display == 'none' ) ? 'block' : 'none' ;
}
// for showing coty rules popup
function show_coty_rules() {
var eID = 'coty_rules', e = document.getElementById( eID );
var footer = document.getElementById('shoe').getElementsByTagName('div')[2]; // this part of the footer bleeds into rules popup
if ( e ) {
//var _y = getPageScroll()[1];
//var pgScroll = (defined(browser) && browser.isIE && _y > 330 ) ? 330 : _y ; // IE hack
e.style.top = (100 + getPageScroll()[1]) + 'px' ;
iehack_toggle_display( footer ) ;
showMe(eID);
}
}
// disable the enter key
function kH(e) {
var pK = e ? e.which : window.event.keyCode;
(pK == 13) ? sub_search() : void(0) ;
return (pK == 13 && defined(document.search_covers)) ? false : true ; // ignore enter key on nomination page
}
document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);
// PETER's coty stuff
document.onmousemove = mouseMove;
function mouseMove(ev){
ev = ev || window.event;
mousePos = mouseCoords(ev);
}
function mouseCoords(ev){
var _body = ( browser.isIE ) ? document.documentElement : document.body ;
if(ev.pageX || ev.pageY){
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + _body.scrollLeft - _body.clientLeft,
y:ev.clientY + _body.scrollTop - _body.clientTop
};
}
function activate(id) {
//capturemouse();
if (typeof mousePos != 'undefined' ) {
document.getElementById(id).style.display = 'block';
document.getElementById(id).style.left = (mousePos.x+10)+'px';
document.getElementById(id).style.top = mousePos.y+'px';
}
}
function vote(flight_id,issue_id) {
var el = document.getElementById('flight_votes-'+flight_id);
if( !el ) {
el = document.createElement('input');
el.setAttribute('type','hidden');
el.setAttribute('id','flight_votes-'+flight_id);
el.setAttribute('name','flight_votes['+flight_id+']');
document.getElementById('main_form').appendChild(el);
}
el.setAttribute('value',issue_id);
var asp_ratio = ( flight_id==25 ) ? 1.5 : 1 ;
var w = ( flight_id==25 ) ? document.getElementById('imgs'+issue_id).width : 100 ;
var h = ( flight_id==25 ) ? document.getElementById('imgs'+issue_id).height : 150 ;
document.getElementById('flight-'+flight_id).innerHTML = '
';
//document.getElementById('flight-'+flight_id).appendChild( document.getElementById('title'+issue_id).cloneNode(true) );
document.getElementById('flight-title'+flight_id).innerHTML = document.getElementById('title'+issue_id).innerHTML ;
}
// ajax helper functions
function sub_search_cb() {
document.getElementById('search_contents').innerHTML = this.responseText ;
document.forms.search_covers.sc.select();
}
function sub_search() {
if (!defined( document.forms.search_covers )) return;
if ( !document.search_covers.sc.value )
{ alert('Please enter what you are looking for under search covers\nor use the cover browser under one of the tabs.'); return ; }
var sval = document.search_covers.sc.value ;
document.getElementById('search_contents').style.display= 'block' ;
showLoadingImage('search_contents');
if ( sval ) makeCBRequest('/i/2008/php/ajax_coty.php?browse_by=S&sc='+escape(sval), sub_search_cb );
}
function show_sr(qstring,el) {
var str, d = ( el == 'letter_contents' ) ? 'none' : 'block' ;
document.getElementById('search_contents').style.display= d ;
if (defined(this.innerHTML) && this != window ) {
str = escape(this.innerHTML.truncate(40,'...')) + ' Covers' ;
document.getElementById('search_cover_title').innerHTML
= "
" ;
}
showLoadingImage(el);
makeRequest('/i/2008/php/ajax_coty.php?'+qstring,el);
}