goinghome=0;
gadmin = ggetCookie("admin_level");
gadmin_links = ggetCookie("display_admin_menu");
var tbase = 'http://www.blendimages.com';
//var tbase = 'http://www.blendimages.ipntestdrive.com';
var home = '/index.html';
var basepath = tbase; // this could be set to '/CURRENT/'
var currentPageName = location.href;


var isindex = false;


if((currentPageName == tbase) || (currentPageName == tbase+'/') || (currentPageName == tbase+'/index.shtml') || (currentPageName == tbase+'/') || (currentPageName == tbase+'index.html')|| (currentPageName == "/") || (currentPageName == "index.shtml") || (currentPageName == "index_pre.shtml") ||(currentPageName == "") || currentPageName.indexOf('index')>0)
        isindex=true;


function showLicense(tier){
	if(tier=='CLV' || tier =='IMS' || tier== 'RAD'){
       		 window.open('/EULA/' + tier + '_EULA.pdf');
	} else {
       		 window.open('/EULA/Blend_RF_EULA.pdf');
	}
}

function ghome() {
	if(goinghome==1){
	} else {
		gsetCookie("gwhichstartpage","", "", "/", gGetCookieDom());
		if(document.qform.Keywords2.value == 'Keyword or image number(s)' || document.qform.Keywords2.value == ''){
			document.location='/user/search.shtml';
		} else {
			var gurl = document.qform.Keywords2.value + '';
			var orient = '';
			var theurl= '/SwishSearch?submit.x=0&submit.y=0&Keywords=' + gurl + orient ;
			document.location='' + theurl;
			goinghome=1;
		}
	}
}

function checksearchpageandremember(){
	var turl = self.location.href;
	if(turl.indexOf('SwishS')> 0){
		 gSetBackpage();
	}
}

if(typeof(gusername) == 'undefined' || gusername == ''){
	gsession = '';
	gsetCookie2('gmpsess','');
}


if(typeof(gsession) == 'undefined'){
	gsession = '';
} else {
	if(gsession == 'checkout'){
		tbase='http://www.blendimages.com';
	}
}
if(typeof(gusername) == 'undefined')
	gusername = '';

	var adminbar = '';

	/////// admin bar inline ///////
	if(gadmin && gusername && gsession)
	{
		adminbar += '<div id=navbar><font class=adminlabel>&nbsp;BLEND ADMIN:</font> <a href="/" target="left">Homepage</a>  | ';
		//write in the navbar here;
		if (gadmin_links && gadmin_links.toString().length > 1) //also have additional links to parse
		{
			var tnavObjs = eval(''+gadmin_links+'');
			for (i=0;i< tnavObjs.length;i++){
				adminbar += '<A href="' + tnavObjs[i]['lnk'] + '" class=>' + tnavObjs[i]['txt'] + '</a> | ';		
			}
				//adminbar += '<A href="/bin/Submissions">Portal</a>  ';		
		}
		adminbar += '</div>';
		if(!isindex)
			document.write(adminbar);
	}
	//////

if(typeof(baseurl) != 'undefined'){
	document.write('<div id="wrapperwide"><div id="innerWrapperwide"><div id="header" >');
	//document.write('<div id="header" >');
} else {
	document.write('<div id="wrapper">');
	document.write('	<div id="innerWrapper"');
	document.write('		<div id="header">');
}

   document.write('\
    <a href="' + home + '" target="_top"><img id=logo src="' + basepath + '/images/logo.gif" /></a>\
    <input type="hidden">\
   ');
   var advanced_search_url = ''; 
   if(typeof(baseurl) != 'undefined'){
    advanced_search_url = '<a href="" onclick="javascript:toggleadvanced(); return false;">';
    document.write('\
<div id="navContainer" ><div id="searchContainer"><form action="javascript:g();" method="get" name="risn">\
      <input type="hidden" name="max_res" id="max_res" value="200">\
      <input type="hidden" name="glo" id="glo" value="1">\
      <input id="Keywords" type="text" class="mainsearchbox" name="Keywords" onfocus="if(this.value==\'Keyword or image number(s)\'){this.value=\'\';}autodropset();if(typeof(autodropmode) !=\'undefined\' && autodropmode==1)toggleadvanced(\'1\');" value="Keyword or image number(s)"  />\
      <a href="javascript:g();">\
    ');
    }
   else
    {
     if (typeof(nosearchbox) == 'undefined')
      {
        advanced_search_url = '<a href="' + basepath + '/user/search.shtml">';
        document.write('\
          <div id="navContainer" ><div id="searchContainer"><form method="get" action="javascript: ghome();" enctype="application/x-www-form-urlencoded" name="qform">\
           <input type="text" id="Keywords2" name="Keywords2"  class="mainsearchbox" onfocus="if(this.value==\'Keyword or image number(s)\')this.value=\'\';" value="Keyword or image number(s)"  />\
           <a href="javascript:ghome();">\
        ');
      }
    }
/*
*/

   document.write('\
    <img id="btn-search" src="' + basepath + '/images/btn-search.gif" /></a></form>\
    <ul id="blue-header" class="horizontal_list">\
      <li>' + advanced_search_url + 'ADVANCED SEARCH</a><div class=verticaldivider>|</div></li>\
      <li><a href="/bin/FormSearch" target="_top">RESEARCH REQUEST</a><div class=verticaldivider>|</div></li> \
      <li><a href="/helpaccountinfo.shtml">HELP</a></li>\
    </ul>');
var loc = self.location.href.split('/');
var url = loc[0]+'/'+loc[1]+'/'+loc[2]+'/';

//Navbar

var style_subheader = "";
if(gadmin && gusername && gsession)
	style_subheader = "top:65px";
if(typeof(dsplkys) != 'undefined') 
	document.write('<ul id="black-subheader" style="'+style_subheader+'" class="horizontal_list">');
else
	document.write('<ul id="black-subheader" style="'+style_subheader+'"class="horizontal_list">');
	
         document.write('<li id="t-account"><a href="' + ( gsession && gusername ? tbase + '/bin/Profile' : tbase + '/user/login.shtml') + '">MY ACCOUNT</a></li>\
                 <li id="t-lightboxes"><a href="' + ( gsession  && gusername? tbase + '/SwishSearch?n=1&lb_view=1' : tbase + '/user/login.shtml') + '">LIGHTBOXES</a></li>\
                 <li id="t-galleries"><a href="' + tbase + '/gallery.shtml">GALLERIES</a></li>\
                 <li id="t-aboutus"><a href="' + tbase + '/aboutus_mission.shtml">ABOUT US</a></li>\
                 <li id="t-cdstore"><a href="' + tbase + '/cdstore.shtml">CD STORE</a></li>\
	');
document.write('</ul></div>');


document.write('<div id="navaddContainer"><ul id="black-header" class="horizontal_list">\
      <li id=first style="margin-top:-3px"><a id="icon-cart"></a><li><a href="' + (gsession  && gusername? tbase + '/SwishSearch?n=1&cartview=1' : tbase + '/user/login.shtml') + '">VIEW CART</a>&nbsp;</li>');

        if (gsession  && gusername) {
			document.write('<li id="signin"><a href="javascript: gsetCookie2\(\'username\',\'\'\);gsetCookie2\(\'gmpsess\',\'\'\);gsetCookie2\(\'gmpauth\',\'\'\);gsetCookie2\(\'firstname\',\'\'\);gsetCookie2\(\'gwhichuser\',\'\'\);gsetCookie2\(\'admin_level\',\'\'\);gsetCookie2\(\'display_admin_menu\',\'\'\);gsetCookie2\(\'salesImportSession\',\'\'\);top.location=\'/index.html\'">SIGN OUT</a><div class=verticaldivider>|</div></li>');
        } else { 
			document.write('<li id="signin"><a href="/user/login.shtml">SIGN IN</a><div class=verticaldivider>|</div></li>');
        }
document.write('				<li id="register' + ''  + '"><a href="/bin/Register" onclick="javascript:checksearchpageandremember();">REGISTER</a></li>\
                        </ul>');
		document.write('<div id="greeting' + (typeof(dsplkys) != 'undefined' ? 'results' : '') + '">');

                if(gsession && gusername && typeof(gfirstname) != 'undefined' && gfirstname) {
                        document.write('<font class=header >');
                        document.write('Welcome back, ' + gfirstname+'<br />');
                        document.write('</font>');
                }
document.write('  </div></div>              </div></div></div>');
//document.write('               </div></div></div>');
document.write('        </div>');

 

