﻿
// Remove the leading and trailing spaces from text in a textbox
//---------------------------------------------------
    function Trim(textbox)
    {		
        while(textbox.value.charAt(0)==' ')
		    textbox.value=textbox.value.substring(1,textbox.value.length )
	    while(textbox.value.charAt(textbox.value.length-1)==' ')
		    textbox.value=textbox.value.substring(0,textbox.value.length-1)
    }

    // Conversion Routines
    function UndefinedToBlank(value)
    {
        if (value == undefined)
            return '';
        else
            return value;
    }

    function UndefinedToZero(value)
    {
        if (value == undefined)
            return 0;
        else
            return value;
    }
    
    

// Popup Windows
//---------------------------------------------------
    function LaunchContactUsFormPopup(mode, subject)
    {
        refit = window.open('ContactUsForm.aspx?Mode=' + UndefinedToZero(mode) + '&Subject=' + UndefinedToBlank(subject),'ContactUsFormPopup','width=530,height=530,scrollbars=1,resizable=1');
    }
    function LaunchPopup(url)
    {
        refit = window.open(url,'Popup','width=530,height=530,scrollbars=1,resizable=1');
    }


    // Customize page Popups
    //---------------------------------------------------
        function gofonts()
        {
	        window.open('signfonts.aspx','win3','width=320,height=400');
        }
        function gocolors()
        {
	        refit = window.open('signcolors.aspx','gocolors','width=450,height=480');
        }
        function gotips() {
            refit = window.open('designtips.aspx', 'gotips', 'width=790,height=370,scrollbars=1,resizable=1');
        }

        function LaunchTextMaximizedTip()
        {
            refit = window.open('DesignTips_TextMaximized.aspx','TextMaximizedTip','width=790,height=400,scrollbars=1,resizable=1');
        }
        function LaunchPriceTextTip()
        {
            refit = window.open('DesignTips_PriceText.aspx','PriceTextTip','width=790,height=400,scrollbars=1,resizable=1');
        }
        
    // Image Library (and Customize) page Popups
    //---------------------------------------------------
        function LaunchImageUploadHelp() {
            refit = window.open('ImageUploadHelp.aspx', 'ImageUploadHelp', 'width=400,height=330,scrollbars=1,resizable=1');
        }


    // Sign Media Popups on About page 
    //---------------------------------------------------
        function goMedia_Economy()
        {
            refit = window.open('media_Economy.aspx','goMedia_Economy','width=300,height=400,scrollbars=1,resizable=1');
        }
        function goMedia_Standard()
        {
            refit = window.open('media_Standard.aspx','goMedia_Standard','width=300,height=430,scrollbars=1,resizable=1');
        }
        function goMedia_Glossy()
        {
            refit = window.open('media_Glossy.aspx','goMedia_Glossy','width=300,height=430,scrollbars=1,resizable=1');
        }
        function goMedia_Vinyl()
        {
            refit = window.open('media_Vinyl.aspx','goMedia_Vinyl','width=400,height=380,scrollbars=1,resizable=1');
        }
        function goMedia_VinylGrommets()
        {
            refit = window.open('media_VinylGrommets.aspx','goMedia_VinylGrommets','width=400,height=530,scrollbars=1,resizable=1');
        }
        function goMedia_WindowCling()
        {
            refit = window.open('media_WindowCling.aspx','goMedia_WindowCling','width=590,height=550,scrollbars=1,resizable=1');
        }
        function goMedia_WindowStick()
        {
            refit = window.open('media_WindowStick.aspx','goMedia_WindowStick','width=600,height=450,scrollbars=1,resizable=1');
        }
        function goMedia_WindowPerf()
        {
            refit = window.open('media_WindowPerf.aspx','goMedia_WindowPerf','width=770,height=520,scrollbars=1,resizable=1');
        }
        function goMedia_WallSticker() {
            refit = window.open('media_WallSticker.aspx', 'goMedia_WallSticker', 'width=400,height=470,scrollbars=1,resizable=1');
        }
        function goMedia_CoolerDoorSticker() {
            refit = window.open('media_CoolerDoorSticker.aspx', 'goMedia_CoolerDoorSticker', 'width=400,height=400,scrollbars=1,resizable=1');
        }
        function goMedia_SignicadeSignSticker() {
            refit = window.open('media_SignicadeSignSticker.aspx', 'goMedia_SignicadeSignSticker', 'width=400,height=420,scrollbars=1,resizable=1');
        }
        function goMedia_CounterTopperInsert() {
            refit = window.open('media_CounterTopperInsert.aspx', 'goMedia_CounterTopperInsert', 'width=400,height=430,scrollbars=1,resizable=1');
        }


        // Video Popups
        //---------------------------------------------------
            function goDownloadSciPosterTemplateVideo()
            {
	            window.open('http://images.graphicsland.com/videos/DownloadSciPosterTemplate/DownloadSciPosterTemplate.html','win1','width=720,height=640');
            }
            function goOrderSciPosterVideo()
            {
	            window.open('http://images.graphicsland.com/videos/OrderSciPoster/OrderSciPoster.html','win1','width=720,height=640');
            }



// Force BREAK-WORD (i.e. long file names) //
//aka makeDesignerHappy(dEl);
function breakWord(dEl){

    if(!dEl || dEl.nodeType !== 1){
      
        return false;

    } else if(dEl.currentStyle && typeof dEl.currentStyle.wordBreak === 'string'){
      
        //Lazy Function Definition Pattern, Peter's Blog
        //From http://peter.michaux.ca/article/3556

        breakWord = function(dEl){
            //For Internet Explorer
            dEl.runtimeStyle.wordBreak = 'break-all';
            return true;
        }
        
        return breakWord(dEl);
     
    }else if(document.createTreeWalker){

        //Faster Trim in Javascript, Flagrant Badassery
        //http://blog.stevenlevithan.com/archives/faster-trim-javascript

        var trim = function  (str) {
            str = str.replace(/^\s\s*/, '');
            var ws = /\s/,
            i = str.length;
            while (ws.test(str.charAt(--i)));
            return str.slice(0, i + 1);
        }
      
        //Lazy Function Definition Pattern, Peter's Blog
        //From http://peter.michaux.ca/article/3556
      
        breakWord = function(dEl){
        
            //For Opera, Safari, and Firefox
            var dWalker = document.createTreeWalker(dEl, NodeFilter.SHOW_TEXT, null, false);
            var node,s,c = String.fromCharCode('8203');
            while (dWalker.nextNode())
            {
                node = dWalker.currentNode;
                //we need to trim String otherwise Firefox will display 
                //incorect text-indent with space characters
                s = trim( node.nodeValue ) .split('').join(c);
                node.nodeValue = s;
            }
            return true;
        }
      
        return breakWord(dEl);      
      
    }else{
        return false;
    }
}
       
//Break All Words
void function(){
    var aEl = document.getElementsByTagName('div');
    var dEl,i;
    var sName = "break-word_JS";
    var oReg =  new RegExp('(\\s|^)' + sName + '(\\s|$)');
    for(i=0;dEl = aEl[i];i++){
        if(dEl.className.match(oReg)){
        breakWord(dEl);
        }
    }
}();  
/*--------------------------------------------*/