function flagVisi()
{
   $('#old').toggle();
    $('#allflags').toggle();
    
    var origin=$('#next');
    if (origin.attr('className')=='next1') origin.removeClass().addClass('next2');
    else origin.removeClass().addClass('next1');     
}

function flipVisible(idname, visible)
{	
	obj = document.getElementById(idname);
	obj.style.display = visible;
}

function copy(thetext, copiedNotifier) 
{
	if (window.clipboardData) 
	{
		window.clipboardData.setData("Text",thetext);		
	} else 
	{
		var copier = 'copier';
		if(!document.getElementById(copier)) {
			var mydiv = document.createElement('div');
			mydiv.id = copier;
			document.body.appendChild(mydiv);
		}
		document.getElementById(copier).innerHTML = '';
		var divhtml = '<embed src="/images_icon/save_to_clipboard.swf" FlashVars="clipboard='+escape(thetext)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
		document.getElementById(copier).innerHTML = divhtml;		
	}
	
	document.getElementById(copiedNotifier).innerHTML = 'Copied';	
}


function displayInputSearchForm(searchKey, mysite)
{
    var words, ref, default_search_text;    
    default_search_text ='Software Search...';ref = document.referrer; 
    if (ref.indexOf('?') != -1 )
    {        
        mysitelength = mysite.length - 1;
        do_exit = ( (1==0) && (mysite.indexOf(ref.substr(0, mysitelength)) != -1) );
        if (!do_exit) 
        {
            cLocation = document.location + "|";
            if ( (mysite.indexOf(ref.substr(0, mysitelength)) == -1) && ( cLocation.indexOf('com_googlesearch') == -1 ) ) 
            {    
                qs = ref.substr(ref.indexOf('?')+1);
                qsa = qs.split('&');
                for (i=0;i<qsa.length;i++) 
                {
                    qsip = qsa[i].split('=');
                    if (qsip.length == 1) continue;
                    if (qsip[0] == 'q' || qsip[0] == 'p' || qsip[0] == 'query' || qsip[0] == 'searchword'|| qsip[0] == 'search'|| qsip[0] == 'qt') 
                    {
                        words = decodeURIComponent(qsip[1].replace(/\+/g,' '));
                    }
                }
            }
        }         
    }            
    
    if (words) 
    {        
        set_cookie("wsskqt",words,2010,12,31,"/",mysite);        
    } 
    else if(searchKey)    
    {         
        words = searchKey;
    }
    else if (!get_cookie ("wsskqt"))        
    {    
        words =default_search_text;
    } else 
    {
        words = get_cookie ("wsskqt");
    }
    
    var out = '';
    out = '<input style="border:1px solid #000" name="allw" type="text" size="50" onfocus="if(this.value==\''+ default_search_text +'\') this.value=\'\';" onblur="if(this.value==\'\') this.value=\'' + words + '\'";" value=\'' + words + '\' />';
    document.writeln(out);
}

function loadWindowsRelatedSoftware(mysite, tagSearch)
{    
        $.post(mysite + 'u/searchWindowsResult.php',{tagSearch : tagSearch},function(data){            
            document.getElementById('windows_result').innerHTML = data;
        } );
    return false;
}


function loadFeaturedProduct(mysite, tagSearch)
{        
        $.post(mysite + 'u/searchFeaturedProduct.php',{tagSearch : tagSearch},function(data){         
            document.getElementById('featured_product_affiliate').innerHTML = data;
        } );
    return false;
}

function print_secure_icon(id)
{
    var out='';
    if(id==1)
        out = 'From Avangate <a target="_blank" href="https://www.scanalert.com/RatingVerify?ref=secure.avangate.com"><img src="//images.scanalert.com/meter/secure.avangate.com/12.gif" alt="HACKER SAFE certified sites prevent over 99.9% of hacker crime." oncontextmenu="alert(\'Copying Prohibited by Law - HACKER SAFE is a Trademark of ScanAlert\'); return false;" border="0" width="115" height="32"></a>';
    else if(id==16)
        out = 'From Regnow <a target="_blank" href="//www.scanalert.com/RatingVerify?ref=www.regnow.com"><img width="94" height="54" border="0" src="//images.scanalert.com/meter/13-www.regnow.com.gif" alt="HACKERSAFE certified sites prevent over 99% of hacker crime." oncontextmenu="alert(\'Copying Prohibited by Law - HACKER SAFE  is a Trademark of ScanAlert\'); return false;"></a>';
    
    document.writeln(out);
}

$(document).ready(function () 
{
    CollapseAll(20);    
}    
)

function copy_notifier()
{
	document.getElementById(copier).innerHTML = '';
}

function printBookmark()
{
    var book;
    book ='<span class="bookmark_con">\
<a href="javascript:void(0)" title="Favorites" alt="Favorites">\
<span class="favorites1"  onclick="return addBookmark(this);"></span>\
</a>\
<a target="_blank" alt="Del.icio.us" title="Del.icio.us"  href="http://del.icio.us/post?url='+window.location.href+'&title='+encodeURIComponent(document.title)+'"><span class="delicious1"></span></a>\
<a target="_blank"  alt="Digg it!"  title="Digg it!"  href="http://digg.com/submit?phase=2&amp;url='+window.location.href+'&title='+encodeURIComponent(document.title)+'"><span class="digg1"></span></a>\
<a target="_blank" alt="StumbleUpon" title="StumbleUpon"  href="http://www.stumbleupon.com/submit?url='+window.location.href+'&title='+encodeURIComponent(document.title)+'"><span class="stumbleupon1"></span></a>\
<a target="_blank"  alt="Google" title="Google"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk='+window.location.href+'&title='+encodeURIComponent(document.title)+'"><span class="google1"></span></a>\
<a target="_blank"  alt="Myspace" title="Myspace" href="http://www.myspace.com/Modules/PostTo/Pages/?u='+window.location.href+'&t='+encodeURIComponent(document.title)+'"><span class="mypace1"></span></a>\
<a target="_blank"  alt="Facebook" title="Facebook" href="http://www.facebook.com/sharer.php?u='+window.location.href+'&t='+encodeURIComponent(document.title)+'"><span class="pacebook1"></span></a>\
<a target="_blank"  alt="Reddit" title="Reddit" href="http://reddit.com/submit?url='+window.location.href+'&title='+encodeURIComponent(document.title)+'"><span class="reddit1"></span></a>\
</span>\
';

document.write(book);
}

function addBookmark(link) 
{
	var title = 'WareSeeker Free Download';
	var url = 'http://wareseeker.com';

	if(window.opera) {
		link.rel = 'sidebar';
		link.href = url;
		link.title = title;
		link.click();
	}
	else if(window.sidebar) window.sidebar.addPanel(title, url, '');
	else window.external.AddFavorite(url, title);
}


function CollapseAll(maxID)
{
        
    if($('#alls_action'))
        $("#alls_action").html("<span style=\"font-size:11px;color:#0066cc;cursor:pointer;\" onclick=\'JavaScript:ExpandAll(" + maxID + ");\'>Expand All</span>");
        
    var id=1;
    for (id=1; id <= maxID; id++) 
    {
        HideDetails(id);
        show(id);
    }
}

function ExpandAll(maxID)
{
    if($('#alls_action'))    
        $("#alls_action").html("<span style=\"font-size:11px;color:#CC0000;cursor:pointer;\" onclick=\'JavaScript:CollapseAll(" + maxID + ");\'>Collapse All</span>");
        
    var id=1;
    for (id=1; id <= maxID; id++) 
    {
        ShowDetails(id);
        show(id);
    }
}


function ShowDetails(id)
{
    if($("#show_" + id))    
        $("#show_" + id).html("<span style=\"font-size:11px;color:#CC0000;cursor:pointer;\" onclick=\'JavaScript:HideDetails(" + id + ");\'>Hide Details</span>");

    if($("#content_" + id))    
        $('#content_'+id).show();
}

function HideDetails(id)
{    
    if($("#show_" + id))   
        $("#show_" + id).html("<span style=\"font-size:11px;color:#0066cc;cursor:pointer;\" onclick=\'JavaScript:ShowDetails(" + id + ");\'>Show Detail</span>");

    if($("#content_" + id))
        $('#content_'+id).hide();
}

function show(id)
{               
    if(document.getElementById("intro_" + id) != null)       
    {              
        if(document.getElementById("intro_" + id).style.display == "block")    
            document.getElementById("intro_" + id).style.display = "none";    
        else    
            document.getElementById("intro_" + id).style.display = "block";
    }
    
    if(document.getElementById("button_" + id) != null)
    {        
        if(document.getElementById("button_" + id).className == "icon_hidden")
            document.getElementById("button_" + id).className = "icon_show";
        else
            document.getElementById("button_" + id).className = "icon_hidden";
    }
}


function set_cookie ( name, value, exp_y, exp_m, exp_d,path,domain,secure)
{
  var cookie_string = name + "=" + escape ( value );
  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }
  if ( path ) cookie_string += "; path=" + escape ( path );
  if ( domain ) cookie_string += "; domain=" + escape ( domain );  
  if ( secure ) cookie_string += "; secure";
  document.cookie = cookie_string;
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
  if ( results )
    return ( unescape ( results[1] ) );
  else
    return null;
}
