
/************************************
123RF.com Global Javascript Functions
************************************/

// Scripts used in Main Page
function search_text_onfocus(obj, def_value) {
    if (obj.value == def_value) {
      obj.value = '';
    }

    // else obj.select();
}

function search_text_onblur(obj, def_value) {
    if (obj.value == '' || obj.value == def_value) {
      obj.value = def_value;
    }
}

function hover_thumb(status, coord) {
    var thumb = 'thumb' + coord;

    if (status == 0) document.getElementById(thumb).style.opacity = 1;
    else if (status == 1) document.getElementById(thumb).style.opacity = 0.8;
}
// Scripts used in Main Page

function toggle_search_options(id, id_caption) {
    if (document.getElementById(id) != null) {

        if (document.getElementById(id).style.display == 'block') {
            document.getElementById(id).style.display = 'none';
            if (document.getElementById(id_caption) != null) document.getElementById(id_caption).innerHTML = '&#9660;';
            remembersearchbar(0);
        }

        else {
            document.getElementById(id).style.display = 'block';
            if (document.getElementById(id_caption) != null) document.getElementById(id_caption).innerHTML = '&#9650;';
            remembersearchbar(1);
        }
    }
}


// advanced search options functions
function searchsubmit(form) {
    var search = form.search_text;
    
    if(search.value.length == 0 || search.value == "Enter keywords or image code") {
        alert("Please enter a keyword.");
        search.focus();
        // search.select();
        // search.value = "Enter keywords or image code";
        return false;
    }
    
    // so that the browser does not submit the X and Y coordinates
    document.getElementById("search_button").disabled = true;

    return;
}

function searchagain_submit() {
    var form = document.searchform;
    var search = form.search_text;

    if(search.value.length == 0 || search.value == "Enter keywords or image code") {
        alert("Please enter a keyword.");
        search.focus();
        // search.select();
        // search.value = "Enter keywords or image code";
        return false;
    }

    form.submit();
}

// global $thispage, $word, $match, $itemsperpage, $cka, $exclude, $imgtype, $exppl, $orderby, $cko;
function resetsearch() {
    var form = document.searchform;
    
    if (searchform.search_text != null) searchform.search_text.value = '';
    if (searchform.match != null) searchform.match[0].checked = true;
    // if (searchform.itemsperpage != null) searchform.itemsperpage[1].checked = true;
    if (searchform.exclude != null) searchform.exclude.value = '';
    if (searchform.cka != null) searchform.cka.checked = false;
    if (searchform.imgtype != null) searchform.imgtype[0].checked = true;
    if (searchform.cko != null) searchform.cko[0].checked = true;
    if (searchform.orderby != null) searchform.orderby[2].checked = true;
    if (searchform.exppl != null) searchform.exppl[0].checked = true;
    if (searchform.nonudity != null) searchform.nonudity.checked = false;
    if (searchform.colorrange != null) searchform.colorrange[0].checked = true;
}
// advanced search options functions


// overlib functions
// required variables: $supplier_name, $cd_code, $file_name
// new items: photograher's name, image description
// magnify('$supplier_name', '$cd_code', '$file_name', '$image_desc_uc');
function magnify_old(supplier_name, cd_code, file_name, image_desc, width, height) {

    var imgsrc = 'http://sg.123rf.com/400nwm/' + supplier_name + '/' + cd_code + '/' + file_name + '.jpg';

    if (width == 0 || height ==0) var imgdiv = '<img src="' + imgsrc + '" style="min-width: 200px; min-height: 200px;" class="loading">';
    else var imgdiv = '<img src="' + imgsrc + '" style="width: ' + width + '; height: ' + height + '"; class="loading">';

    var imgdesc = '<div style="font-size: 1.1em; margin-top: 2px; margin-bottom: 1px; color: #FFF;">' + image_desc + '</div>';
    var imgphotog = '<div style="font-size: 1.1em; color: #DDD;"><img src="/images/v2/icon_photog.gif" style="margin-bottom: -1px; margin-right: 3px;" title="Photographer" alt="Photographer" border="0">' + supplier_name + '</div>';

    return overlib(imgdiv + imgdesc + imgphotog, ABOVE, HAUTO, VAUTO, BGCOLOR, '#888888', FGCOLOR, '#888888');

    // if (width == 0 || height == 0) return overlib('<img src="' + imgsrc + '" style="min-width: 200px; min-height: 200px;" class="loading">' + image_desc, ABOVE, HAUTO, VAUTO, BGCOLOR, '#888888', FGCOLOR, '#888888');
    // else return overlib('<img src="' + imgsrc + '" style="width: ' + width + '; height: ' + height + '"; class="loading">' + image_desc, ABOVE, HAUTO, VAUTO, BGCOLOR, '#888888', FGCOLOR, '#888888');

    // return overlib('<img src="' + imgsrc + '" style="min-height: 150px;" class="loading">', HAUTO, VAUTO, BGCOLOR, '#AAAAAA', FGCOLOR, '#AAAAAA');
}

function magnifysmall_old(supplier_name, cd_code, file_name, width, height) {

    var imgsrc = 'http://sg.123rf.com/168nwm/' + supplier_name + '/' + cd_code + '/' + file_name + '.jpg';

    if (width == 0 || height == 0) var imgdiv = '<img src="' + imgsrc + '" style="min-width: 50px; min-height: 50px;" class="loading">';
    else var imgdiv = '<img src="' + imgsrc + '" style="width: ' + width + '; height: ' + height + '"; class="loading">';

    var imgphotog = '<div style="font-size: 1.1em; color: #DDD; margin-top: 2px;"><img src="/images/v2/icon_photog.gif" style="margin-bottom: -1px; margin-right: 3px;" title="Photographer" alt="Photographer" border="0">' + supplier_name + '</div>';

    return overlib(imgdiv + imgphotog, WIDTH, 10, ABOVE, HAUTO, VAUTO, BGCOLOR, '#888888', FGCOLOR, '#888888');
}

// new magnify functions using cache servers (v2)
function magnify_v2(cacheserver, supplier_name, cd_code, file_name, image_desc, width, height) {

    if (cacheserver == '') cacheserver = 'http://images.123rf.com/us';

    var imgsrc = cacheserver + '/400wm/' + supplier_name + '/' + cd_code + '/' + file_name + '.jpg';

    if (width == 0 || height ==0) var imgdiv = '<img src="' + imgsrc + '" style="min-width: 200px; min-height: 200px;" class="loading">';
    else var imgdiv = '<img src="' + imgsrc + '" style="width: ' + width + '; height: ' + height + '"; class="loading">';

    var imgdesc = '<div style="font-size: 1.1em; margin-top: 2px; margin-bottom: 1px; color: #FFF;">' + image_desc + '</div>';
    var imgphotog = '<div style="font-size: 1.1em; color: #DDD;"><img src="/images/v2/icon_photog.gif" style="margin-bottom: -1px; margin-right: 3px;" title="Photographer" alt="Photographer" border="0">' + supplier_name + '</div>';

    return overlib(imgdiv + imgdesc + imgphotog, ABOVE, HAUTO, VAUTO, BGCOLOR, '#888888', FGCOLOR, '#888888');

    // if (width == 0 || height == 0) return overlib('<img src="' + imgsrc + '" style="min-width: 200px; min-height: 200px;" class="loading">' + image_desc, ABOVE, HAUTO, VAUTO, BGCOLOR, '#888888', FGCOLOR, '#888888');
    // else return overlib('<img src="' + imgsrc + '" style="width: ' + width + '; height: ' + height + '"; class="loading">' + image_desc, ABOVE, HAUTO, VAUTO, BGCOLOR, '#888888', FGCOLOR, '#888888');

    // return overlib('<img src="' + imgsrc + '" style="min-height: 150px;" class="loading">', HAUTO, VAUTO, BGCOLOR, '#AAAAAA', FGCOLOR, '#AAAAAA');
}

function magnifysmall_v2(cacheserver, supplier_name, cd_code, file_name, width, height) {

    if (cacheserver == '') cacheserver = 'http://images.123rf.com/us';
    var imgsrc = cacheserver + '/168nwm/' + supplier_name + '/' + cd_code + '/' + file_name + '.jpg';

    if (width == 0 || height == 0) var imgdiv = '<img src="' + imgsrc + '" style="min-width: 50px; min-height: 50px;" class="loading">';
    else var imgdiv = '<img src="' + imgsrc + '" style="width: ' + width + '; height: ' + height + '"; class="loading">';

    var imgphotog = '<div style="font-size: 1.1em; color: #DDD; margin-top: 2px;"><img src="/images/v2/icon_photog.gif" style="margin-bottom: -1px; margin-right: 3px;" title="Photographer" alt="Photographer" border="0">' + supplier_name + '</div>';

    return overlib(imgdiv + imgphotog, WIDTH, 10, ABOVE, HAUTO, VAUTO, BGCOLOR, '#888888', FGCOLOR, '#888888');
}

// new magnify functions using cache servers (v3)
function magnify(supplier_name, cd_code, file_name, image_desc, width, height) {
    if (!window.cacheserver || cacheserver == '') cacheserver = 'http://sg.123rf.com';
    //var imgsrc = cacheserver + '/400wm/' + supplier_name + '/' + cd_code + '/' + file_name + '.jpg';
	var imgsrc ='https://www.ambassadoreckertimages.com/Admin/Images/Upload/' + supplier_name + '/' + cd_code + '/' + file_name + '.jpg';
	
//alert(imgsrc);
  //modified by js
    if (width == 0) var imgdiv = '<img src="' + imgsrc + '" style="min-width: 200px; min-height: 200px;" class="loading">';
    else var imgdiv = '<img src="' + imgsrc + '" style="width: ' + width + '"; class="loading">';

  //by lh
    //if (width == 0 || height ==0) var imgdiv = '<img src="' + imgsrc + '" style="min-width: 200px; min-height: 200px;" class="loading">';
    //else var imgdiv = '<img src="' + imgsrc + '" style="width: ' + width + '; height: ' + height + '"; class="loading">';


    var imgdesc = '<div style="font-size:small; margin-top: 2px; margin-bottom: 1px; color: #FFF;">' + image_desc + '</div>';
    var imgphotog = '';//'<div style="font-size: 1.1em; color: #DDD;"><img src="/images/v2/icon_photog.gif" style="margin-bottom: -1px; margin-right: 3px;" title="Photographer" alt="Photographer" border="0">' + supplier_name + '</div>';

    return overlib(imgdiv + imgdesc + imgphotog, ABOVE, HAUTO, VAUTO, BGCOLOR, '#888888', FGCOLOR, '#888888');

    // if (width == 0 || height == 0) return overlib('<img src="' + imgsrc + '" style="min-width: 200px; min-height: 200px;" class="loading">' + image_desc, ABOVE, HAUTO, VAUTO, BGCOLOR, '#888888', FGCOLOR, '#888888');
    // else return overlib('<img src="' + imgsrc + '" style="width: ' + width + '; height: ' + height + '"; class="loading">' + image_desc, ABOVE, HAUTO, VAUTO, BGCOLOR, '#888888', FGCOLOR, '#888888');

    // return overlib('<img src="' + imgsrc + '" style="min-height: 150px;" class="loading">', HAUTO, VAUTO, BGCOLOR, '#AAAAAA', FGCOLOR, '#AAAAAA');
}

function magnifysmall(supplier_name, cd_code, file_name, width, height) {
    if (!window.cacheserver || cacheserver == '') cacheserver = 'http://sg.123rf.com';
    var imgsrc = cacheserver + '/168nwm/' + supplier_name + '/' + cd_code + '/' + file_name + '.jpg';

    if (width == 0 || height == 0) var imgdiv = '<img src="' + imgsrc + '" style="min-width: 50px; min-height: 50px;" class="loading">';
    else var imgdiv = '<img src="' + imgsrc + '" style="width: ' + width + '; height: ' + height + '"; class="loading">';

    var imgphotog = '<div style="font-size: 1.1em; color: #DDD; margin-top: 2px;"><img src="/images/v2/icon_photog.gif" style="margin-bottom: -1px; margin-right: 3px;" title="Photographer" alt="Photographer" border="0">' + supplier_name + '</div>';

    return overlib(imgdiv + imgphotog, WIDTH, 10, ABOVE, HAUTO, VAUTO, BGCOLOR, '#888888', FGCOLOR, '#888888');
}


// reveal lightbox drop down box
function reveallb() {
    document.getElementById('lightbox_select').style.display = 'inline';
    document.getElementById('lightbox_text').style.display = 'none';

    document.getElementById('lightbox_select').focus();
}

// hide the lightbox drop down box while focus is lost
function hidelb() {
    document.getElementById('lightbox_select').style.display = 'none';
    document.getElementById('lightbox_text').style.display = 'inline';
}

// Remember Advanced Search bar state
function remembersearchbar(state) {
    var futdate = new Date();
    var expdate = futdate.getTime();
    expdate += 14 * 24 * 3600 * 1000 // expires in 14 days (milliseconds)
    futdate.setTime(expdate);

    setCookie('advsrch', state, futdate, '/');
}


// create new lightbox
function do_create () {
    var new_name = prompt('Please enter a name for the new lightbox.', '');
    if (new_name != null) {
        document.lightboxaction.text.value = new_name;
        document.lightboxaction.action.value = 'create';
        document.lightboxaction.submit();

        var futdate = new Date();
        var expdate = futdate.getTime();
        expdate += 14 * 24 * 3600 * 1000 // expires in 14 days (milliseconds)
        futdate.setTime(expdate);
        setCookie('lightid', '', futdate, '/');
    }
}

// rename lightbox
function do_rename (oldname, id) {
    oldname = decodeURI(oldname);
    var new_name = prompt('Please enter a new name for this lightbox.', oldname);
    if (new_name != null) {
        document.lightboxaction.text.value = new_name;
        document.lightboxaction.action.value = 'rename';
        document.lightboxaction.submit();

        var futdate = new Date();
        var expdate = futdate.getTime();
        expdate += 14 * 24 * 3600 * 1000 // expires in 14 days (milliseconds)
        futdate.setTime(expdate);
        setCookie('lightid', id, futdate, '/');
    }
}

// delete existing ligthbox
function do_delete (n) {
    if (confirm('Are you sure you want to delete this lightbox?')) {
        document.lightboxaction.text.value = n;
        document.lightboxaction.action.value = 'delete';
        document.lightboxaction.submit();
    }
}

function do_privacy(id, privacy)
{
  document.lightboxaction.text.value = privacy;
    document.lightboxaction.action.value = 'setprivacy';
    document.lightboxaction.submit();
}

function do_note()
{
  document.lightboxaction.text.value = document.getElementById('light_note').value;
    document.lightboxaction.action.value = 'note';
    document.lightboxaction.submit();
}

// remember current ligthbox
function rememberlightbox(id) {
    var futdate = new Date();
    var expdate = futdate.getTime();
    expdate += 14 * 24 * 3600 * 1000 // expires in 14 days (milliseconds)
    futdate.setTime(expdate);

    setCookie('lightid', id, futdate, '/');
    // alert(id);
}

// javascript reminder
function confirm_reminder(msg) {
    if (confirm(msg)) return true;
    return false;
}

// switch between color themes
function applytheme (color) {
    if (document.getElementById('logocolor') != null && document.getElementById('sbarcolor') != null) {

        // save current theme to a hidden variable, to be used on mouseover effects of pricing table
        if(document.getElementById('curtheme') != null) document.getElementById('curtheme').value = color;

        // reset the color theme buttons
        // the selected button will be changed later in the switch statement
        if(document.getElementById('orangetheme') != null) document.getElementById('orangetheme').className = 'orangetheme';
        if(document.getElementById('bluetheme') != null) document.getElementById('bluetheme').className = 'bluetheme';
        if(document.getElementById('greentheme') != null) document.getElementById('greentheme').className = 'greentheme';
        if(document.getElementById('silvertheme') != null) document.getElementById('silvertheme').className = 'silvertheme';
        if(document.getElementById('pinktheme') != null) document.getElementById('pinktheme').className = 'pinktheme';

        switch (color) {
            case 'orange':
                if (document.getElementById('logocolor') != null) document.getElementById('logocolor').className = 'logo logo_orange';
                if (document.getElementById('sbarcolor') != null) document.getElementById('sbarcolor').className = 'container_search_bar sbar_orange';
                if (document.getElementById('orangetheme') != null) document.getElementById('orangetheme').className = 'orangethemeon';
                if (document.getElementById('mainbg') != null) document.getElementById('mainbg').className = 'container_content_mainpage mainbg_orange';
                if (document.getElementById('container_advanced_search') != null) document.getElementById('container_advanced_search').className = 'advanced_search advsearch_orange';
                if (document.getElementById('promo_text') != null) document.getElementById('promo_text').className = 'advanced_serach promo_text advsearch_orange';

                // price table and pricing figures
                if (document.getElementById('price_table') != null) document.getElementById('price_table').className = 'price_table ptable_orange';
                if (document.getElementById('pricefigure_cred') != null) document.getElementById('pricefigure_cred').className = 'pricefigure pfig_orange';
                if (document.getElementById('pricefigure_subs') != null) document.getElementById('pricefigure_subs').className = 'pricefigure pfig_orange';

                // drop menu background
                if (document.getElementById('dropMenu_imgcat') != null) document.getElementById('dropMenu_imgcat').className = 'dropMenu imgcat dropMenu_orange';
                if (document.getElementById('dropMenu_photog') != null) document.getElementById('dropMenu_photog').className = 'dropMenu dropMenu_orange';
                if (document.getElementById('dropMenu_langsite') != null) document.getElementById('dropMenu_langsite').className = 'dropMenu dropMenu_orange';
                
                // blog                
                var divArray = document.getElementsByTagName('div');
                for (var i = 0; i < divArray.length; i++) {
                    if (divArray[i].id == 'title_blog') divArray[i].className = 'title_blog title_blog_orange';
                    else if (divArray[i].id == 'blog_info_bar') divArray[i].className = 'bg_shades blog_info_bar bg_shades_orange';
                    else if (divArray[i].id == 'header_blog') divArray[i].className = 'header_blog header_blog_orange';
                }
                
                break;
            case 'blue': case '': default:
                if (document.getElementById('logocolor') != null) document.getElementById('logocolor').className = 'logo logo_blue';
                if (document.getElementById('sbarcolor') != null) document.getElementById('sbarcolor').className = 'container_search_bar sbar_blue';
                if (document.getElementById('orangetheme') != null) document.getElementById('bluetheme').className = 'bluethemeon';
                if (document.getElementById('mainbg') != null) document.getElementById('mainbg').className = 'container_content_mainpage mainbg_blue';
                if (document.getElementById('container_advanced_search') != null) document.getElementById('container_advanced_search').className = 'advanced_search advsearch_blue';
                if (document.getElementById('promo_text') != null) document.getElementById('promo_text').className = 'advanced_serach promo_text advsearch_blue';

                // price table and pricing figures
                if (document.getElementById('price_table') != null) document.getElementById('price_table').className = 'price_table ptable_blue';
                if (document.getElementById('pricefigure_cred') != null) document.getElementById('pricefigure_cred').className = 'pricefigure pfig_blue';
                if (document.getElementById('pricefigure_subs') != null) document.getElementById('pricefigure_subs').className = 'pricefigure pfig_blue';

                // drop menu background
                if (document.getElementById('dropMenu_imgcat') != null) document.getElementById('dropMenu_imgcat').className = 'dropMenu imgcat dropMenu_blue';
                if (document.getElementById('dropMenu_photog') != null) document.getElementById('dropMenu_photog').className = 'dropMenu dropMenu_blue';
                if (document.getElementById('dropMenu_langsite') != null) document.getElementById('dropMenu_langsite').className = 'dropMenu dropMenu_blue';
                
                // blog  
                var divArray = document.getElementsByTagName('div');
                for (var i = 0; i < divArray.length; i++) {
                    if (divArray[i].id == 'title_blog') divArray[i].className = 'title_blog title_blog_blue';
                    else if (divArray[i].id == 'blog_info_bar') divArray[i].className = 'bg_shades blog_info_bar bg_shades_blue';
                    else if (divArray[i].id == 'header_blog') divArray[i].className = 'header_blog header_blog_blue';
                }

                break;
            case 'green':
                if (document.getElementById('logocolor') != null) document.getElementById('logocolor').className = 'logo logo_green';
                if (document.getElementById('sbarcolor') != null) document.getElementById('sbarcolor').className = 'container_search_bar sbar_green';
                if (document.getElementById('orangetheme') != null) document.getElementById('greentheme').className = 'greenthemeon';
                if (document.getElementById('mainbg') != null) document.getElementById('mainbg').className = 'container_content_mainpage mainbg_green';
                if (document.getElementById('container_advanced_search') != null) document.getElementById('container_advanced_search').className = 'advanced_search advsearch_green';
                if (document.getElementById('promo_text') != null) document.getElementById('promo_text').className = 'advanced_serach promo_text advsearch_green';

                // price table and pricing figures
                if (document.getElementById('price_table') != null) document.getElementById('price_table').className = 'price_table ptable_green';
                if (document.getElementById('pricefigure_cred') != null) document.getElementById('pricefigure_cred').className = 'pricefigure pfig_green';
                if (document.getElementById('pricefigure_subs') != null) document.getElementById('pricefigure_subs').className = 'pricefigure pfig_green';

                // drop menu background
                if (document.getElementById('dropMenu_imgcat') != null) document.getElementById('dropMenu_imgcat').className = 'dropMenu imgcat dropMenu_green';
                if (document.getElementById('dropMenu_photog') != null) document.getElementById('dropMenu_photog').className = 'dropMenu dropMenu_green';
                if (document.getElementById('dropMenu_langsite') != null) document.getElementById('dropMenu_langsite').className = 'dropMenu dropMenu_green';
                
                // blog
                var divArray = document.getElementsByTagName('div');
                for (var i = 0; i < divArray.length; i++) {
                    if (divArray[i].id == 'title_blog') divArray[i].className = 'title_blog title_blog_green';
                    else if (divArray[i].id == 'blog_info_bar') divArray[i].className = 'bg_shades blog_info_bar bg_shades_green';
                    else if (divArray[i].id == 'header_blog') divArray[i].className = 'header_blog header_blog_green';
                }

                break;
            case 'silver':
                if (document.getElementById('logocolor') != null) document.getElementById('logocolor').className = 'logo logo_silver';
                if (document.getElementById('sbarcolor') != null) document.getElementById('sbarcolor').className = 'container_search_bar sbar_silver';
                if (document.getElementById('orangetheme') != null) document.getElementById('silvertheme').className = 'silverthemeon';
                if (document.getElementById('mainbg') != null) document.getElementById('mainbg').className = 'container_content_mainpage mainbg_silver';
                if (document.getElementById('container_advanced_search') != null) document.getElementById('container_advanced_search').className = 'advanced_search advsearch_silver';
                if (document.getElementById('promo_text') != null) document.getElementById('promo_text').className = 'advanced_serach promo_text advsearch_silver';

                // price table and pricing figures
                if (document.getElementById('price_table') != null) document.getElementById('price_table').className = 'price_table ptable_silver';
                if (document.getElementById('pricefigure_cred') != null) document.getElementById('pricefigure_cred').className = 'pricefigure pfig_silver';
                if (document.getElementById('pricefigure_subs') != null) document.getElementById('pricefigure_subs').className = 'pricefigure pfig_silver';

                // drop menu background
                if (document.getElementById('dropMenu_imgcat') != null) document.getElementById('dropMenu_imgcat').className = 'dropMenu imgcat dropMenu_silver';
                if (document.getElementById('dropMenu_photog') != null) document.getElementById('dropMenu_photog').className = 'dropMenu dropMenu_silver';
                if (document.getElementById('dropMenu_langsite') != null) document.getElementById('dropMenu_langsite').className = 'dropMenu dropMenu_silver';
                
                // blog
                var divArray = document.getElementsByTagName('div');
                for (var i = 0; i < divArray.length; i++) {
                    if (divArray[i].id == 'title_blog') divArray[i].className = 'title_blog title_blog_silver';
                    else if (divArray[i].id == 'blog_info_bar') divArray[i].className = 'bg_shades blog_info_bar bg_shades_silver';
                    else if (divArray[i].id == 'header_blog') divArray[i].className = 'header_blog header_blog_silver';
                }

                break;
            case 'pink':
                if (document.getElementById('logocolor') != null) document.getElementById('logocolor').className = 'logo logo_pink';
                if (document.getElementById('sbarcolor') != null) document.getElementById('sbarcolor').className = 'container_search_bar sbar_pink';
                if (document.getElementById('orangetheme') != null) document.getElementById('pinktheme').className = 'pinkthemeon';
                if (document.getElementById('mainbg') != null) document.getElementById('mainbg').className = 'container_content_mainpage mainbg_pink';
                if (document.getElementById('container_advanced_search') != null) document.getElementById('container_advanced_search').className = 'advanced_search advsearch_pink';
                if (document.getElementById('promo_text') != null) document.getElementById('promo_text').className = 'advanced_serach promo_text advsearch_pink';

                // price table and pricing figures
                if (document.getElementById('price_table') != null) document.getElementById('price_table').className = 'price_table ptable_pink';
                if (document.getElementById('pricefigure_cred') != null) document.getElementById('pricefigure_cred').className = 'pricefigure pfig_pink';
                if (document.getElementById('pricefigure_subs') != null) document.getElementById('pricefigure_subs').className = 'pricefigure pfig_pink';

                // drop menu background
                if (document.getElementById('dropMenu_imgcat') != null) document.getElementById('dropMenu_imgcat').className = 'dropMenu imgcat dropMenu_pink';
                if (document.getElementById('dropMenu_photog') != null) document.getElementById('dropMenu_photog').className = 'dropMenu dropMenu_pink';
                if (document.getElementById('dropMenu_langsite') != null) document.getElementById('dropMenu_langsite').className = 'dropMenu dropMenu_pink';
                
                // blog
                var divArray = document.getElementsByTagName('div');
                for (var i = 0; i < divArray.length; i++) {
                    if (divArray[i].id == 'title_blog') divArray[i].className = 'title_blog title_blog_pink';
                    else if (divArray[i].id == 'blog_info_bar') divArray[i].className = 'bg_shades blog_info_bar bg_shades_pink';
                    else if (divArray[i].id == 'header_blog') divArray[i].className = 'header_blog header_blog_pink';
                }

                break;
        }

        // remember theme
        var futdate = new Date();
        var expdate = futdate.getTime();
        expdate += 14 * 24 * 3600 * 1000 // expires in 14 days (milliseconds)
        futdate.setTime(expdate);

        setCookie('123theme', color, futdate, '/');
    }
}


// Cookies functions
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function eraseCookie(name) {
  createCookie(name,"",-1);
}

function remember_perpage(perpage) {
    // remember items per page
    var futdate = new Date();
    var expdate = futdate.getTime();
    expdate += 14 * 24 * 3600 * 1000 // expires in 14 days (milliseconds)
    futdate.setTime(expdate);

    setCookie('perpage', perpage, futdate, '/');
}


var newWin = null;
function popUp(strURL, strType, strHeight, strWidth) {
  if (newWin != null && !newWin.closed) newWin.close();
  var strOptions="";
  if (strType=="console") strOptions="resizable,height=" + strHeight+",width=" + strWidth;
  if (strType=="fixed") strOptions="status,height=" + strHeight+",width=" + strWidth;
  if (strType=="elastic") strOptions="toolbar,menubar,scrollbars," + "resizable,location,height="+ strHeight+",width="+strWidth;
  newWin = window.open(strURL, 'newWin', strOptions);
  newWin.focus();
}

function toggle_colorpicker(color) {
    // var answer = window.open('http://www.123rf.com/colorpicker/?color=' + color,'ColorPicker','scalable=no,scrollbars=no,status=no,height=225,width=450,top=150,left=300');
    if (searchform.colorrange != null) searchform.colorrange[2].checked = true;
    popUp('http://www.123rf.com/colorpicker/?color=' + color, 'fixed', 225, 450);
    return false;
}

function toggle_colorpicker_forum(color) {
    // var answer = window.open('http://forum.123rf.com/colorpicker/?color=' + color,'ColorPicker','scalable=no,scrollbars=no,status=no,height=225,width=450,top=150,left=300');
    if (searchform.colorrange != null) searchform.colorrange[2].checked = true;
    popUp('http://forum.123rf.com/colorpicker/?color=' + color, 'fixed', 225, 450);
    return false;
}

function removecolor() {
    if (document.getElementById('colorpicker') != null) document.getElementById('colorpicker').style.background = '#AAAAAA';
    if (document.getElementById('colorhex') != null) document.getElementById('colorhex').value = '';
    // if (document.getElementById('hsv') != null) document.getElementById('hsv').value = '';
    if (document.getElementById('colorpicker_text') != null) document.getElementById('colorpicker_text').innerHTML = '<a href="javascript: void(0);" onclick="toggle_colorpicker(document.getElementById(\'colorhex\').value); return false;">No color preference</a>';
}

// process and combine all keywords into
function process_kw(count, type) {

    var string_kw = '';
    var count_checked = 0;
    var chkbox_kw;
    
    for (var i = 0; i <= count; i++) {
        
        // alert("document.form_searchkw.kw_" + i);
        
        if (type == '123') chkbox_kw = eval("document.form_searchkw.kw_" + i);
        else if (type == 'inm') chkbox_kw = eval("document.form_searchkw_inm.kw_inm_" + i);
        
        if (chkbox_kw) {
            if (chkbox_kw.checked) {
                // alert(chkbox_kw.value);              
                if (string_kw == '') string_kw = string_kw + chkbox_kw.value;
                else string_kw = string_kw + '_' + chkbox_kw.value;
                
                count_checked++;
            }
        }        
    }
   
    // alert(string_kw);
    
    if (!count_checked) alert('Please check at least one keyword and try again.');    
    else {
        if (type == '123') window.location = '/stock-photo/' + string_kw + '.html';
        // if (type == 'inm') window.parent.location = 'http://www.inmagine.com/searchterms/' + string_kw + '.html';
        if (type == 'inm') window.open('http://www.inmagine.com/searchterms/' + string_kw + '.html');
    }
}

// var answer = window.open('http://www.123rf.com/reportspam.php,'ColorPicker','scalable=no,scrollbars=no,status=no,height=225,width=450,top=150,left=300');

function $(v) { return(document.getElementById(v)); }
function $S(v) { return($(v).style); }
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function isset(v) { return((typeof(v)=='undefined' || v.length==0)?false:true); }
function XYwin(v) { var z=agent('msie')?Array(document.body.clientHeight,document.body.clientWidth):Array(window.innerHeight,window.innerWidth); return(isset(v)?z[v]:z); }

function getY( oElement )
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetTop;
oElement = oElement.offsetParent;
}
return iReturnValue;
}

function sexyTOG() {$S('sexyBG').display='none'; $S('sexyBOX').display='none';}
function sexyBOX(v,b) { setTimeout("sexyTOG()",8000); $S('sexyBG').height=(XYwin(0)*2.5)+'px'; $S('sexyBG').display='block'; $('sexyBOX').innerHTML=v+'<div class="sexyX"><br><img src=/image/loading.gif style= "vertical-align:middle;">&nbsp; Preparing for your download...<br><br>'+"<\/div>"; $S('sexyBOX').left=Math.round((XYwin(1)-b)/2)+'px'; $S('sexyBOX').width=b+'px'; $S('sexyBOX').display='block'; }

window.Blink = function(args){
  // Set the color and seconds below, e.g., [args,'COLOR',SECONDS]
 	args = (/,/.test(args))?  args.split(/,/):  [args,'#FFFF88',6];
 	var who = document.getElementById(args[0]);
 	var count = parseInt(args[2]);
 	if (--count <=0) {
  		who.style.backgroundColor = '';
  		if(who.focus) who.focus();
 	} else {
  		args[2]=count+'';
  		who.style.backgroundColor=(count%2==0)? '': args[1];
 	 	args='\"'+args.join(',')+'\"';
  		setTimeout("Blink("+args+")",500);
 	}
}
	
	
function tog_keywords(key,todo)
{
	//var keywordid = "keyword_"+key;
	
		var s; 
		var e;
		var addkeyword = "add_"+key;
		var deletekeyword = "delete_"+key;
	if (todo=='add') 
	{	
	//if click add	
		if (document.getElementById(addkeyword).src == 'http://www.123rf.com/image/icons/add.gif')
		{
			//if already added, then remove
			document.getElementById(addkeyword).src = 'http://www.123rf.com/image/icons/add_grey.gif';
			s=" "+document.searchform.word.value+" ";
			s=s.replace(new RegExp(" ", "g"),"  ");
			s=s.replace(new RegExp(" "+key+" ", "g")," ");
			s=s.replace(new RegExp("  ", "g")," ");			
		}	
		else
		{
			//if not added, then add, and remove from exclude word
			s=document.searchform.word.value + " " + key;
			document.getElementById(addkeyword).src = 'http://www.123rf.com/image/icons/add.gif';
			document.getElementById(deletekeyword).src = 'http://www.123rf.com/image/icons/delete_grey.gif';
			e=" "+document.searchform.exclude.value+" ";
			e=e.replace(new RegExp(" ", "g"),"  ");
			e=e.replace(new RegExp(" "+key+" ", "g")," ");
			e=e.replace(new RegExp("  ", "g")," ");			
			document.searchform.exclude.value = e.replace(/^\s+|\s+$/g,"");
		}	
	document.searchform.word.value = s.replace(/^\s+|\s+$/g,"");	
	}
	else
	{
		//if delete
		if (document.getElementById(deletekeyword).src == 'http://www.123rf.com/image/icons/delete.gif')
		{
			//if already in exclude, then remove from exclude
			document.getElementById(deletekeyword).src = 'http://www.123rf.com/image/icons/delete_grey.gif';
			e=" "+document.searchform.exclude.value+" ";
			e=e.replace(new RegExp(" ", "g"),"  ");
			e=e.replace(new RegExp(" "+key+" ", "g")," ");
			e=e.replace(new RegExp("  ", "g")," ");			
		}	
		else
		{
			//if not in exclude, add into exclude, and remove from search
			e=document.searchform.exclude.value + " " + key;
			document.getElementById(deletekeyword).src = 'http://www.123rf.com/image/icons/delete.gif';

			document.getElementById(addkeyword).src = 'http://www.123rf.com/image/icons/add_grey.gif';
			s=" "+document.searchform.word.value+" ";
			s=s.replace(new RegExp(" ", "g"),"  ");
			s=s.replace(new RegExp(" "+key+" ", "g")," ");
			s=s.replace(new RegExp("  ", "g")," ");	
			document.searchform.word.value = s.replace(/^\s+|\s+$/g,"");			

		}	
	document.searchform.exclude.value = e.replace(/^\s+|\s+$/g,"");
	}
	
	document.searchform.submit();

}
