function openPreview(redir_to,item_name,site,confirmation){
//opens a preview window with the specified path
//pass the full file name
      //cut img name to load
      
      
            //added for abcanet_v2 during testing
            var target_separate = true;
//            if(document.referrer.indexOf("abcanet-qa") > -1 || document.referrer.indexOf(":8088") > -1){
            if (site == "A") {
            //added for anet downloads
//                if (redir_to.indexOf("/web/downloads/preplay") > -1) {
                if (redir_to.indexOf("preplay") > -1) {
                    target_separate = true;
                }
                else {
                    target_separate = false;

                }
            }
                
      
      
            confirmed = true;
            site = blankNull(site);
            redir_full_fname = "";
            default_window_properties="width=550,height=650,resizeable,scrollbars";
		
			
			//jquery check
			jquery_installed = false;
			
			if(typeof jQuery == 'undefined') {
			}
			else {
			    jquery_installed = true;
			}
			//jquery check
			
            //if file is an image, it will be resized by DisplayPreview app
            if(item_name.indexOf("jpg")>-1){
                default_window_properties="0,0,resizeable,scrollbars";
            } 
            	
           if(blankNull(redir_to) != ""){
			    redir_full_fname = redir_to+".aspx?item="+item_name;
                
                if(confirmation=="true"){
				//	confirmed = window.open('/disclaimner.html, class="1b0n"');
                    //legal confirm is the full legal confirmation, kept in file '/js/site.js' 
                    if(typeof legalConfirm == 'undefined' || blankNull(legalConfirm)==""){
					
                    if(!jquery_installed){
                    //opens up regular js confirm
                        confirmed =  confirm(defaultLegal);
                    }
                    else {
                        //uses jquery confirm
			            confirmed =	jConfirm(defaultLegal,'Legal', function(r){
			            if(r){
        			        //alert(redir_full_fname + default_window_properties);
     	                    if (redir_full_fname.indexOf("player.aspx") > -1)
                                {
                                    default_window_properties="height=483,width=830,resizeable=yes,scrollbars=no";
                                }
                            url = redir_full_fname;
                            //added check for abcanet_v2 testing
                            if(target_separate){
                                previewWin = window.open(url, "preview", default_window_properties);
                            } 
                               
                            }
                            }); 
				   }
				}
                else {
                    if(!jquery_installed){
                    //opens up regular js confirm
                        confirmed =  confirm(defaultLegal);
                    }
                    else {
                    //uses jquery confirm
			            confirmed = jConfirm(legalConfirm,'Legal', function(r){
			            if(r){
        			        //alert(redir_full_fname + default_window_properties);
     	                    if (redir_full_fname.indexOf("player.aspx") > -1)
                                {
//Move                                    default_window_properties="height=474,width=830,resizeable=yes,scrollbars=no";

//Flow
                default_window_properties="height=420,width=655,resizeable=yes,scrollbars=no";
                                }
                            url = redir_full_fname;
                            //added check for abcanet_v2 testing
                            if(target_separate){
                                previewWin = window.open(url, "preview", default_window_properties);
                            }
                            }
                        }); 
                        }
                    }
                    
                }
                
                
                
               if(confirmed){                                     
     		      //  alert(redir_full_fname + default_window_properties);
     		      
     		      if (redir_full_fname.indexOf("player.aspx") > -1)
                        {
//Move                            default_window_properties="height=474,width=830,resizeable=yes,scrollbars=no";
//Flow
                default_window_properties="height=420,width=655,resizeable=yes,scrollbars=no";
                        }
                    url = redir_full_fname;
                       //added check for abcanet_v2 testing
                            if(target_separate){
                                previewWin = window.open(url, "preview", default_window_properties)
                            }
               }
               //abcanet_v2 testing
               if(!target_separate){
                    location.href = url;
               }
         }
}//end function openPreview(imgname)


function ImgNotLoaded(){
    resizeOuterTo(600,700);
    location.href = document.images[0].src;
}


function resizeOuterTo(w,h) {
 if (parseInt(navigator.appVersion)>3) {
   if (navigator.appName=="Netscape") {
    top.outerWidth=w;
    top.outerHeight=h;
   }
   else top.resizeTo(w,h);
 }
 self.resizeTo(w,h);
}

function maxWindow() {
     window.moveTo(0,0);
     window.resizeTo(screen.width, screen.height);
}

d = new Date();
yearT = y2k(d.getFullYear());



function downloadCartProc() {
    jQuery("#end_doc").bind("inview", function(isVisible) {

        //		            // Event is triggered once the element becomes visible in the browser's viewport, and once when it becomes invisible

        if (isVisible) {
            //alert('visible');

            $("#btnSubmit").removeAttr('disabled');
           // console.log("element #foobar became visible in the browser's viewport");

        } else {
            //alert('hidden');
            // console.log("element #foobar became invisible in the browser's viewport");
        }
    });
}


//Legal Disclaimers for each site
/* open a new browser window based on info passed to the function */ 

document.write(' <script language=javascript src="/js/site.js" > </script>');
 







defaultLegal = "ALL PHOTOGRAPHY IS COPYRIGHTED MATERIAL. IMAGES ARE NOT TO BE ARCHIVED, DUPLICATED, RESOLD, RETRANSMITTED OR USED FOR ANY OTHER PURPOSES WITHOUT WRITTEN PERMISSION OF ABC, INC.\n\n";
defaultLegal += "All photographs are the copyrighted property of ABC, its affiliated companies or licensors and are distributed to the press solely for the promotion of ABC programming and the ABC Television Network in the news or entertainment media owned or legally licensed by your company within the United States.  No international distribution is permitted without permission.\n\n";
defaultLegal += "You will affix to any photograph, the copyright notice, and credit the photographer wherever possible: (Copyright \u00A9 "+ yearT+" ABC, Inc. / photographer's name)\n\n";
defaultLegal += "The photographs cannot be sold or distributed to a third party, provided however that syndicates receiving these materials may distribute them to their subscribers solely for distribution in the news or entertainment media.  The licensee does not have the right to grant to others, including affiliated or related websites, the right to use the photographs.PHOTOS MUST BE POSTED AT A LOW RESOLUTION IN ORDER TO PREVENT IMAGE DOWNLOADING.\n\n";
defaultLegal += "ABC reserves all right, title and interest to the photographs and no rights other than those limited rights specifically described herein are granted to you.  The photographs remain the property of ABC.  Any other use of the photographs is a violation of the copyright laws.";


